LNMP之編譯安裝PHP5.5.30
創(chuàng)新互聯(lián)建站自2013年起,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元克拉瑪依做網(wǎng)站,已為上家服務(wù),為克拉瑪依各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:189808205751、編譯前操作:
1.1、netstat -tulnp | egrep "80|3306" tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 25392/nginx tcp 0 0 :::3306 :::* LISTEN 53278/mysqld1.2、yum install zlib libxml libjpeg libjpeg-devel freetype-devel libpng libpng-devel curl curl-devel libiconv zlib-devel libxml2-devel -y#國(guó)際化本地化字符集轉(zhuǎn)換軟件包
1.3、wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz tar xf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local/libconv1.14 make && make install1.4、wget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz tar xf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure --prefix=/usr/local/libmcrypt2.5.8 make && make install /sbin/ldconfig cd libltdl/ ./configure --enable-ltdl-install make && make install1.5、wget http://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz tar xf mhash-0.9.9.9.tar.gz cd mhash-0.9.9.9 ./configure --prefix=/usr/local/mhash0.9.9.9 make && make install1.6、 ln -s /usr/local/libmcrypt2.5.8/lib/libmcrypt.la /usr/lib/libmcrypt.la ln -s /usr/local/libmcrypt2.5.8/lib/libmcrypt.so /usr/lib/libmcrypt.so ln -s /usr/local/libmcrypt2.5.8/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4 ln -s /usr/local/libmcrypt2.5.8/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8 ln -s /usr/local/mhash0.9.9.9/lib/libmhash.a /usr/lib/libmhash.a ln -s /usr/local/mhash0.9.9.9/lib/libmhash.la /usr/lib/libmhash.la ln -s /usr/local/mhash0.9.9.9/lib/libmhash.so /usr/lib/libmhash.so ln -s /usr/local/mhash0.9.9.9/lib/libmhash.so.2 /usr/lib/libmhash.so.2 ln -s /usr/local/mhash0.9.9.9/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1 ln -s /usr/local/libmcrypt2.5.8/bin/libmcrypt-config /usr/bin/libmcrypt-config ln -s /usr/local/libmcrypt2.5.8/include/mcrypt.h /usr/local/include/mcrypt.h1.7、wget http://nchc.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz tar xf mcrypt-2.6.8.tar.gz cd mcrypt-2.6.8 /sbin/ldconfig export LD_LIBRARY_PATH=/usr/local/libmcrypt2.5.8/lib:/usr/local/lib:/usr/local/mhash0.9.9.9/lib export LDFLAGS="-L/usr/local/libmcrypt2.5.8/lib -I/usr/local/mhash0.9.9.9/include/" export CFLAGS="-I/usr/local/mhash0.9.9.9/include/" ./configure --prefix=/usr/local/mcrypt2.6.8 --with-libmcrypt-prefix=/usr/local/libmcrypt2.5.8 make && make install錯(cuò)誤1、./configure錯(cuò)誤及解決方案
*** Could not run libmcrypt test program, checking why... *** The test program compiled, but did not run. This usually means *** that the run-time linker is not finding LIBMCRYPT or finding the wrong *** version of LIBMCRYPT. If it is not finding LIBMCRYPT, you'll need to set your *** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point *** to the installed location Also, make sure you have run ldconfig if that *** is required on your system *** *** If you have an old version installed, it is best to remove it, although *** you may also be able to get things to work by modifying LD_LIBRARY_PATH *** configure: error: *** libmcrypt was not found 解決方法: export LD_LIBRARY_PATH=/usr/local/libmcrypt2.5.8/lib:/usr/local/lib:/usr/local/mhash0.9.9.9/lib export LDFLAGS="-L/usr/local/libmcrypt2.5.8/lib -I/usr/local/mhash0.9.9.9/include/" export CFLAGS="-I/usr/local/mhash0.9.9.9/include/"2編譯安裝及配置php
2.1安裝編譯php5.5.30
wget http://cn2.php.net/distributions/php-5.5.30.tar.bz2 tar jxf php-5.5.30.tar.bz2 cd php-5.5.30 ./configure --prefix=/usr/local/php5.5.30 --with-mysql=/usr/local/mysql5.6.27 --with-iconv-dir=/usr/local/libconv1.14 --enable-fpm --enable-sockets --enable-sysvsem --enable-mbstring --enable-pcntl --enable-gd-native-ttf --enable-zip --enable-shmop --enable-inline-optimization --enable-bcmath --enable-ftp --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-openssl --with-mhash --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-xmlrpc --with-curl --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx ln -s /usr/local/mysql5.6.27/lib/libmysqlclient.so.18 /usr/lib make && make install錯(cuò)誤2、./configure錯(cuò)誤及解決方案:
configure: error: libmcrypt version 2.5.6 or greater required 解決方法: rpm -ivh "http://mirrors.ustc.edu.cn/epel/6Server/x86_64/epel-release-6-8.noarch.rpm" yum install -y libmcrypt-devel2.2、配置php參數(shù):
cp /root/php-5.5.30/php.ini-production /usr/local/php5.5.30/lib/php.ini cd /usr/local/php5.5.30/etc cp php-fpm.conf.default php-fpm.conf vim php-fpm.conf #修改fastcgi的參數(shù)文件php-fpm.conf的相關(guān)選項(xiàng)值: pid = /usr/local/php5.5.30/var/run/php-fpm.pid pm.max_children = 40 pm.start_servers = 3 pm.min_spare_servers = 3 pm.max_spare_servers = 8 /usr/local/php5.5.30/sbin/php-fpm -t /usr/local/php5.5.30/sbin/php-fpm netstat -tulnp | grep 90002.3修改ngnix的配置文件nginx.conf(/usr/local/nginx-1.8.0/conf/nginx.conf)
在server標(biāo)簽的server_name下添加一行為(indexindex.php)的配置代碼
listen 80; server_name www.fnw.com; index index.php;把server中的以下內(nèi)容注釋掉:
#location / { # root html; # index index.html index.htm; #}在server中添加以下內(nèi)容
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_param SCRIPT_FILENAME /usr/local/nginx1.8/html/$fastcgi_script_name; include fastcgi_params; }如果nginx沒(méi)有啟動(dòng)則執(zhí)行:/usr/local/nginx-1.8.0/sbin/nginx
若nginx服務(wù)器已經(jīng)啟動(dòng)則執(zhí)行:/usr/local/nginx-1.8.0/sbin/nginx -s reload
3、測(cè)試nginx,php,mysql是否成功:
3.1、測(cè)試php,ngnix是否配置成功
[root@fnw html]# cat >> index.php <<EOF <?php phpinfo(); ?> EOF[root@fnw html]# netstat -tulnp | egrep "80|3306|9000" tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 47013/nginx tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 43900/php-fpm tcp 0 0 :::3306 :::* LISTEN 1394/mysqld在網(wǎng)頁(yè)瀏覽器中輸入 http://192.168.1.168
3.2、測(cè)試php和mysql是否可以連接成功:
給高級(jí)管理員root用戶管理MySQL 中所有數(shù)據(jù)庫(kù)的權(quán)限。192.168.1.168被管理主機(jī)的ip地址。
grant all on *.* to root@’192.168.1.168’修改root用戶密碼
update mysql.user set password=PASSWORD('123456') where host='192.168.1.168' and user='root';在index.php文件中輸入
<?php $mysql_conn=mysql_connect('192.168.1.168','root','123456') or die(); if($mysql_conn){ echo "Successful"; }else{ echo "Failure"; } mysql_close($mysql_conn); ?>4、配置fpm服務(wù)文件
4.1 修改php-fpm的配置文件
cp php-5.5.30/sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm修改/etc/init.d/php-fpm 文件中13到18行的內(nèi)容為:
13prefix=/usr/local/php5.5.30#php5.5.30的安裝路徑 14exec_prefix=${prefix}#php5.5.30的命令執(zhí)行路徑(和安裝路徑一樣) 15 16php_fpm_BIN=${exec_prefix}/sbin/php-fpm #fastcgi php-fpm執(zhí)行命名 17php_fpm_CONF=${prefix}/etc/php-fpm.conf#php-fpm的配置文件 18php_fpm_PID=${prefix}/var/run/php-fpm.pid#php-fpm的進(jìn)程號(hào)(pid)
編輯好之后用vim查看結(jié)果:
vim /etc/init.d/php-fpm #! /bin/sh ### BEGIN INIT INFO # Provides: php-fpm # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts php-fpm # Description: starts the PHP FastCGI Process Manager daemon ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions prefix=/usr/local/php5.5.30 exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php-fpm php_fpm_CONF=${prefix}/etc/php-fpm.conf php_fpm_PID=${prefix}/var/run/php-fpm.pid php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID" wait_for_pid () { try=0 while test $try -lt 35 ; do case "$1" in 'created') if [ -f "$2" ] ; then try='' break fi ;; 'removed') if [ ! -f "$2" ] ; then try='' break fi ;; esac echo -n . try=`expr $try + 1` sleep 1 done } case "$1" in start) echo -n "Starting php-fpm " $php_fpm_BIN --daemonize $php_opts if [ "$?" != 0 ] ; then echo " failed" exit 1 fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; stop) echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed. Use force-quit" exit 1 else echo " done" fi ;; status) if [ ! -r $php_fpm_PID ] ; then echo "php-fpm is stopped" exit 0 fi PID=`cat $php_fpm_PID` if ps -p $PID | grep -q $PID; then echo "php-fpm (pid $PID) is running..." else echo "php-fpm dead but pid file exists" fi ;; force-quit) echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $0 stop $0 start ;; reload) echo -n "Reload service php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload|status}" exit 1 ;; esac4.2、給php-fpm添加到只啟動(dòng)服務(wù)里
#給php-fpm加執(zhí)行權(quán)限
chmod +x /etc/init.d/php-fpm#添加php-fpm服務(wù)。chkconfig確保每個(gè)運(yùn)行級(jí)有一項(xiàng)啟動(dòng)(S)或者殺死(K)入口。如有缺少,則會(huì)從缺省的init腳本自動(dòng)建立
chkconfig --add php-fpm#設(shè)置php-fpm在開(kāi)啟時(shí)候的運(yùn)行級(jí)別的狀態(tài),默認(rèn)級(jí)別為2、3、4、5
chkconfig php-fpm on#檢查php-fpm的啟動(dòng)級(jí)別
chkconfig --list php-fpm php-fpm 0:off1:off2:on3:on4:on5:on6:off4.3測(cè)試php-fpm的啟動(dòng)服務(wù):
4.3.1、啟動(dòng)php-fpm服務(wù)
[root@fnw run]# service php-fpm start Starting php-fpm done4.3.2、重啟php-fpm服務(wù)
[root@fnw run]# service php-fpm restart Gracefully shutting down php-fpm . done Starting php-fpm done4.3.3、平滑重啟php-fpm服務(wù)
[root@fnw run]# service php-fpm reload Reload service php-fpm done4.3.4、查看php-fpm運(yùn)行狀態(tài)
[root@fnw run]# service php-fpm status php-fpm (pid 49776) is running...4.3.5、停止php-fpm運(yùn)行狀態(tài)以后再看。
[root@fnw run]# service php-fpm stop Gracefully shutting down php-fpm . done [root@fnw run]# service php-fpm status php-fpm is stopped另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
分享文章:基于CentOS6.5環(huán)境之下的LNMP之編譯安裝PHP5.5.30-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://muchs.cn/article24/cdesje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣、網(wǎng)站建設(shè)、動(dòng)態(tài)網(wǎng)站、移動(dòng)網(wǎng)站建設(shè)、服務(wù)器托管、定制開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容