最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

ubuntu14.04LTS安裝nginx+mariaDB+php7+YAF的方法

 更新時(shí)間:2016年05月31日 11:22:54   作者:keyunq  
這篇文章主要介紹了ubuntu14.04LTS安裝nginx+mariaDB+php7+YAF的方法,詳細(xì)講述了ubuntu14.04LTS環(huán)境下nginx+mariaDB+php7+YAF的安裝方法與相關(guān)注意事項(xiàng),需要的朋友可以參考下

本文講述了ubuntu14.04LTS安裝nginx+mariaDB+php7+YAF的方法。分享給大家供大家參考,具體如下:

ubuntu apt-get方式安裝nginx

參考:

http://nginx.org/en/linux_packages.html

首先

in order to authenticate the nginx repository signature and to eliminate warnings about missing PGP key during installation of the nginx package, it is necessary to add the key used to sign the nginx packages and repository to the apt program keyring.

下載密鑰

wget http://nginx.org/keys/nginx_signing.key

然后添加

sudo apt-key add nginx_signing.key

加入nginx的repository

cd /etc/apt/sources.list.d/
sudo vim nginx.list

若安裝穩(wěn)定版本,則輸入以下內(nèi)容

deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx

若最新版本,則輸入以下內(nèi)容:

deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx

然后安裝

apt-get update
apt-get install nginx

安裝完成

nginx -v
nginx version: nginx/1.8.0

MariaDB數(shù)據(jù)庫(kù)安裝

MariaDB是一個(gè)開源數(shù)據(jù)庫(kù)且100%與MySQL兼容,目標(biāo)是替代MySQL數(shù)據(jù)庫(kù)。

MariaDB的背景 :

2008年,MySQL被后來被Oracle在2010年收購(gòu)的Sun Microsystems收購(gòu)了。 最初被Sun公司的收購(gòu)由于符合項(xiàng)目的需要而受到MySQL社區(qū)的歡呼,但是這種情緒并沒有持續(xù)太久,接下來被Oracle的收購(gòu),不幸期望遠(yuǎn)遠(yuǎn)低于預(yù) 期。許多MySql的開發(fā)者離開了Sun和Oracle公司開始新的項(xiàng)目。在他們中間就有MySQL的創(chuàng)建者以及項(xiàng)目長(zhǎng)期技術(shù)帶頭人之一的Michael 'Monty' Widenius。Monty和他的團(tuán)隊(duì)創(chuàng)建了MySQL的一個(gè)fork版本并且命名它為MariaDB。

默認(rèn)上MariaDB的包并沒有在Ubuntu倉(cāng)庫(kù)中。要安裝MariaDB,我們首先要設(shè)置MariaDB倉(cāng)庫(kù)。

設(shè)置 MariaDB 倉(cāng)庫(kù)

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.3GolFM9PZ5 --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
gpg: requesting key 1BB943DB from hkp server keyserver.ubuntu.com
gpg: key 1BB943DB: public key "MariaDB Package Signing Key <package-signing-key@mariadb.org>" imported
gpg: Total number processed: 1
gpg:        imported: 1
sudo add-apt-repository 'deb http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main'

安裝 MariaDB :

sudo apt-get update
sudo apt-get install mariadb-server

在安裝中,你會(huì)被要求設(shè)置MariaDB的root密碼。

從命令行連接到MariaDB :

keyun@ubuntu-server:~$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 43
Server version: 10.0.23-MariaDB-1~trusty-log mariadb.org binary distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

MariaDB 服務(wù)

sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

以上只是在Ubuntu上裝完MariaDB,下面要設(shè)置MariaDB允許遠(yuǎn)程訪問

1、如果Ubuntu有設(shè)置防火墻或者iptables規(guī)則的話,請(qǐng)自行打開

2、3306端口是不是沒有打開?

使用nestat命令查看3306端口狀態(tài):

~# netstat -an | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN

從結(jié)果可以看出3306端口只是在IP 127.0.0.1上監(jiān)聽,所以拒絕了其他IP的訪問。

解決方法:修改/etc/mysql/my.cnf文件。打開文件,找到下面內(nèi)容:

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1

把上面這一行注釋掉或者把127.0.0.1換成合適的IP,建議注釋掉。

重新啟動(dòng)后,重新使用netstat檢測(cè):

~# netstat -an | grep 3306
tcp    0   0 0.0.0.0:3306      0.0.0.0:*        LISTEN

1. 把用戶權(quán)限分配各遠(yuǎn)程用戶。

登錄到mysql服務(wù)器,使用grant命令分配權(quán)限

復(fù)制代碼 代碼如下:
mysql> grant all on . to 你的用戶名如root@'%' identified by '你的密碼';

完成后使用mysql命令連接,提示成功,為了確保正確可以再遠(yuǎn)程登陸測(cè)試一下。

安裝PHP7

因?yàn)槭亲钚』惭b的ubuntu,先安裝make

sudo apt-get install make

下載源碼

sudo wget https://downloads.php.net/~ab/php-7.0.2RC1.tar.gz
sudo tar -zvxf php-7.0.2RC1.tar.gz
cd php-7.0.2RC1

根據(jù)鳥哥指示,安裝gcc4.8

使用新一點(diǎn)的編譯器, 推薦GCC 4.8以上, 因?yàn)橹挥蠫CC 4.8以上PHP才會(huì)開啟Global Register for opline and execute_data支持, 這個(gè)會(huì)帶來5%左右的性能提升(Wordpres的QPS角度衡量) 其實(shí)GCC 4.8以前的版本也支持, 但是我們發(fā)現(xiàn)它支持的有Bug, 所以必須是4.8以上的版本才會(huì)開啟這個(gè)特性.

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntu-toolchain-r/test 
sudo apt-get update
sudo apt-get install gcc-4.8 g++-4.8
sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade

查看版本

gcc --version
gcc (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

先安裝依賴

sudo apt-get install libxml2 
sudo apt-get install libxml2-dev 
sudo apt-get install openssl 
sudo apt-get install libssl-dev 
sudo apt-get install curl 
sudo apt-get install libcurl4-openssl-dev 
sudo apt-get install libgd-dev 
sudo apt-get install libxslt-dev

因本機(jī)lib目錄在/usr/lib/x86_64-linux-gnu

./configure –prefix=/usr/local/php –with-curl –with-freetype-dir –with-gd –with-gettext –with-iconv-dir –with-kerberos –with-libdir=lib/x86_64-linux-gnu –with-libxml-dir –with-mysqli –with-openssl –with-pcre-regex –with-pdo-mysql –with-pdo-sqlite –with-pear –with-png-dir –with-xmlrpc –with-xsl –with-zlib –enable-fpm –enable-bcmath –enable-libxml –enable-inline-optimization –enable-gd-native-ttf –enable-mbregex –enable-mbstring –enable-opcache –enable-pcntl –enable-shmop –enable-soap –enable-sockets –enable-sysvsem –enable-xml –enable-zip
sudo make
sudo make install
sudo cp php.ini-development /usr/local/php/lib/php.ini
sudo cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
sudo cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
sudo cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

最后一條命令,作用是php-fpm隨系統(tǒng)自啟動(dòng)。

利用php自帶的php-fpm管理工具,可以很方便的start,stop,restart
把管理工具從源碼包里放到php/sbin文件夾里,方便使用

sudo cp ./sapi/fpm/init.d.php-fpm /usr/local/php/sbin/
sudo cd /usr/local/php/sbin/
sudo chmod 755 init.d.php-fpm

配置nginx與php-fpm后,通過phpinfo(),看到如下

 

至此,php7安裝成功。

安裝apache ab壓測(cè)工具

sudo apt-get install apache2-utils

壓測(cè)一下

echo "hello world"
ab -n 1000 -c 20 http://10.81.36.158:9528/

QPS 7000左右

接下來開啟opcache

sudo vi /usr/local/php/lib/php.ini

找到opcache設(shè)置

添加以下內(nèi)容

zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1

重啟php-fpm

sudo kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid

或者

sudo /usr/local/php/sbin/init.d.php-fpm restart

再次測(cè)試,QPS上升到8000以上

開啟HugePages

參考:http://m.fzitv.net/article/85491.htm

再次測(cè)試,QPS偶爾能彪上10000

安裝YAF

sudo wget http://pecl.php.net/get/yaf-3.0.2.tgz
sudo tar -zvxf yaf-3.0.2.tgz

解壓縮以后, 進(jìn)入Yaf的源碼目錄, 依次執(zhí)行(其中PHP_BIN是PHP的bin目錄):

sudo /usr/local/php/bin/phpize

報(bào)錯(cuò):

Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

解決辦法:

sudo apt-get install m4
sudo apt-get install autoconf
sudo apt-get install libpcre3 libpcre3-dev 

phpize執(zhí)行后:

sudo ./configure --with-php-config=/usr/local/php/bin/php-config
sudo make
sudo make install
Installing shared extensions:   /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/

安裝成功,修改php.ini,加入yaf擴(kuò)展

extension=yaf.so

重啟php-fpm,查看phpinfo()

 

安裝yaf成功

PS:使用PDO過程中,出現(xiàn) SQLSTATE[HY000] [2002] No such file or directory 錯(cuò)誤

經(jīng)查,是mysql.sock找不到

在phpinfo()中,看到pdo_mysql.default_socket的值是/tmp/mysql.sock

 

但是在服務(wù)器上并沒有這個(gè)文件

通過sudo service mysql status 命令

* /usr/bin/mysqladmin Ver 9.1 Distrib 10.0.23-MariaDB, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Server version     10.0.23-MariaDB-1~trusty-log
Protocol version    10
Connection       Localhost via UNIX socket
UNIX socket       /var/run/mysqld/mysqld.sock
Uptime:         3 min 28 sec

找到sock文件的位置在/var/run/mysqld/mysqld.sock

于是在/tmp下 做個(gè)軟鏈接

sudo ln -s /var/run/mysqld/mysqld.sock mysql.sock

問題解決

通過localhost無法訪問到數(shù)據(jù)庫(kù),但是通過IP可以

分析:這是典型的socket沒有正確設(shè)置的情況。

連接MySQL數(shù)據(jù)庫(kù)有兩種方式:TCP/IP(一般理解的端口的那種)和Unix套接字(一般叫socket或者sock)。大部分情況下,可以用localhost代表本機(jī)127.0.0.1,但是在MySQL連接時(shí),二者不可混用,而且MySQL中權(quán)限設(shè)置中l(wèi)ocalhost與127.0.0.1也是分開設(shè)置的。當(dāng)設(shè)置為127.0.0.1時(shí),系統(tǒng)通過TCP/IP方式連接數(shù)據(jù)庫(kù);當(dāng)設(shè)置為localhost時(shí),系統(tǒng)通過socket方式連接數(shù)據(jù)庫(kù)。

根據(jù)上面的sudo service mysql status命令

得到sock文件的位置在/var/run/mysqld/mysqld.sock

于是,修改php.ini

pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock

重啟php-fpm

問題解決

希望本文所述對(duì)大家ubuntu服務(wù)器配置有所幫助。

相關(guān)文章

  • 服務(wù)器常見問題匯總(常見故障及相應(yīng)的解決方法)

    服務(wù)器常見問題匯總(常見故障及相應(yīng)的解決方法)

    服務(wù)器一般是很少出現(xiàn)問題的,一旦出現(xiàn)問題,怎樣去積極的搶救呢?我們不能坐以待斃,原因一旦服務(wù)器故障,那么該服務(wù)器上的所有網(wǎng)站將都會(huì)無法打開。對(duì)于一個(gè)企業(yè)來說,網(wǎng)站就是他們的命脈,損失是巨大的
    2017-04-04
  • Linux系統(tǒng)查看服務(wù)器帶寬及網(wǎng)絡(luò)使用情況的具體方法

    Linux系統(tǒng)查看服務(wù)器帶寬及網(wǎng)絡(luò)使用情況的具體方法

    Linux系統(tǒng)中如何查看服務(wù)器帶寬?本篇文章主要和大家分享一下Linux系統(tǒng)中查看服務(wù)器帶寬的方法,對(duì)linux查看服務(wù)器帶寬具體方法感興趣的朋友跟隨小編一起看看吧
    2022-11-11
  • 完美解決IIS和APACHE的301重定向(帶參數(shù))

    完美解決IIS和APACHE的301重定向(帶參數(shù))

    感覺BAIDU spider對(duì)404的重定向似乎無動(dòng)于衷,于是近日干脆對(duì)原失效的鏈接重新設(shè)置301重定向。
    2010-11-11
  • 寶塔面板中mongodb的配置教程分享

    寶塔面板中mongodb的配置教程分享

    MongoDB是一個(gè)基于分布式文件存儲(chǔ)的數(shù)據(jù)庫(kù),由C++語言編寫。旨在為WEB應(yīng)用提供可擴(kuò)展的高性能數(shù)據(jù)存儲(chǔ)解決方案,下面我們來講講如何在寶塔面板中配置mongodb吧
    2023-08-08
  • 寶塔面板安裝部署SSL證書的教程

    寶塔面板安裝部署SSL證書的教程

    SSL證書是網(wǎng)站實(shí)現(xiàn)https加密訪問的關(guān)鍵要素,它通常是安裝部署在Web服務(wù)器上,本文主要介紹了寶塔面板安裝部署SSL證書的教程,具有一定的參考價(jià)值,感興趣的可以了解一下
    2023-08-08
  • 使用HMAILSERVER搭建郵件服務(wù)器圖文教程

    使用HMAILSERVER搭建郵件服務(wù)器圖文教程

    本文沒有什么高深的技術(shù)內(nèi)容,只是以windows server 2008 為例,使用HMAILServer,介紹搭建郵件服務(wù)器的全過程,供參考
    2016-10-10
  • cwrsync server 服務(wù)啟動(dòng)失敗的解決方法小結(jié)

    cwrsync server 服務(wù)啟動(dòng)失敗的解決方法小結(jié)

    因?yàn)榉?wù)器用cwrsync用來同步數(shù)據(jù),有時(shí)候連接不上的時(shí)候,到服務(wù)器上查看cwrsync server停止了,啟動(dòng)時(shí)就提示啟動(dòng)失敗
    2012-06-06
  • 最好懂的HTTPS講解

    最好懂的HTTPS講解

    這篇文章主要介紹了最好懂的HTTPS講解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2020-03-03
  • Mac下搭建php開發(fā)環(huán)境教程

    Mac下搭建php開發(fā)環(huán)境教程

    這篇文章主要介紹了Mac下搭建php開發(fā)環(huán)境教程,Mac OS X 內(nèi)置了Apache 和 PHP,這樣使用起來非常方便。本文以Mac OS X 10.6.3為例,需要的朋友可以參考下
    2014-05-05
  • 使用RSYNC在服務(wù)器間鏡像或者備份目錄和文件

    使用RSYNC在服務(wù)器間鏡像或者備份目錄和文件

    rsync是個(gè)真正的鏡像工具,它能相應(yīng)地刪除本地文件萬一服務(wù)器上的文件被刪除,這一點(diǎn)比wget好,在鏡像目錄的同時(shí)也能排除某些目錄及文件。速度非???
    2010-03-03

最新評(píng)論

大新县| 清丰县| 汉寿县| 诸暨市| 松阳县| 大荔县| 沈丘县| 布拖县| 中宁县| 扎兰屯市| 云龙县| 丰镇市| 祁门县| 富宁县| 阜城县| 莱州市| 英山县| 南澳县| 陆丰市| 新乡市| 麻城市| 潜山县| 潢川县| 抚远县| 罗源县| 随州市| 东宁县| 通道| 临夏市| 江安县| 蒙阴县| 太仓市| 兴隆县| 安庆市| 枣庄市| 阜新市| 延长县| 永定县| 台湾省| 平度市| 旬阳县|