LNMP環境部署之---PHP編譯安裝。

來源:互聯網
上載者:User

標籤:php編譯安裝技巧   軟體   

     LNMP環境部署之---PHP編譯安裝。


前兩篇文章是講關於Nginx和MySQL的編譯安裝,接下來要完成三個軟體中最難的一個環節,當然這隻是對還沒入門的同學說的。安裝過一遍後知道技巧後,自然就好簡單了,廢話不說,直入正題。



1)檢查確認Nginx及MySQL的安裝路徑:

[[email protected] ~]# ls -ld /application/

drwxr-xr-x 4 root root 4096 12月  9 07:52 /application/

[[email protected] ~]# ls -ld /application/nginx/

drwxr-xr-x 11 root root 4096 12月  1 21:48 /application/nginx/

2)檢查連接埠及啟動情況:

[[email protected] ~]# netstat -lntup|grep -E"80|3306"

tcp       0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1589/mysqld        

tcp       0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1629/nginx   

3)檢查軟體包     

[[email protected] ~]# rpm -qa zlib-devel libxml2-devellibjpeg-devel libjpeg-turbo-devel libconv-devel

zlib-devel-1.2.3-29.el6.x86_64

[[email protected] ~]# rpm -qa freetype-devellibpng-devel gd-devel libcurl-devel libxslt-devel

4)安裝需要的軟體包

a.以下是通過repo源安裝的軟體

[[email protected] ~]# yum install -y zlib-devellibxml2-devel libjpeg-devel libjpeg-turbo-devel libconv-devel freetype-devellibpng-devel gd-devel libcurl-devel libxslt-devel

b.yum源無法安裝的libiconv庫。

使用wget下載二進位軟體包,編譯安裝

[[email protected] ~]# cd /home/oldboy/tools/

[[email protected] tools]# wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

#### 可能下載逾時,請在IE瀏覽器下載後再rz上傳,比較好。

[[email protected] tools]# tar zxf libiconv-1.14.tar.gz

[[email protected] tools] # cd libiconv-1.14

[[email protected] libiconv-1.14] # ./configureprefix=/usr/local/libiconv

[[email protected] libiconv-1.14]make

[[email protected] libiconv-1.14]make install

 

c.epel源(第三方源)

[[email protected] ~] # wget -O /etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-6.repo

[[email protected] ~] # yum install libmcrypt-develmcrypt mhash -y

 

d、用軟連結

[[email protected] php-5.5.32]# ln -s/application/mysql/lib/libmysqlclient.so.18 /usr/lib64/

 

e、下載PHP

[[email protected] tools]# wget http://mirrors.sohu.com/php/php-5.5.32.tar.gz

f、建立phar.phar檔案

[[email protected] tools]# cd php-5.5.32

[[email protected] php-5.5.32]# touch ext/phar/phar.phar

 

[[email protected] ~] # cd /applicalition/php5.5.32/

[[email protected] php5.5.32] # ./configure \

--prefix=/application/php5.5.32 \

--with-mysql=/application/mysql/ \

--with-iconv-dir=/usr/local/libiconv \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-libxml-dir=/usr \

--enable-xml \

--disable-rpath \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--enable-mbregex \

--enable-fpm \

--enable-mbstring \

--with-mcrypt \

--with-gd \

--enable-gd-native-ttf \

--with-openssl \

--with-mhash \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-zip \

--enable-soap \

--enable-short-tags \

--enable-static \

--with-xsl \

--with-fpm-user=nginx \

--with-fpm-group=nginx \

--enable-ftp \

--enable-opcache=no

 

[[email protected] php5.5.32] # make&&makeinstall

 

 

 

php-5.3

--enable-safe-mode--enable-zend-multibyte --with-curlwrappers

 

3.2報錯分析及解決方案。

報錯2:

/home/lihua/tools/php-5.5.32/sapi/cli/php:error while loading shared libraries: libmysqlclient.so.18: cannot open sharedobject file: No such file or directory

解決方案1:

1、用軟連結

[[email protected] php-5.5.32]# ln -s/application/mysql/lib/libmysqlclient.so.18 /usr/lib64/

解決方案2:

2、把ld.so.conf加入/application/mysql/lib路徑。

[[email protected] php-5.5.32]# vi /etc/ld.so.conf

 

include ld.so.conf.d/*.conf

/application/mysql/lib

                                                             

~                                                                              

                                                                            

"/etc/ld.so.conf" 2L, 51C written

[[email protected] php-5.5.32]# ldconfig

報錯2:make: *** [ext/phar/phar.php] Error127

解決方案:是由於缺少檔案phar.phar,建立即可。

[[email protected] php-5.5.32]# touch ext/phar/phar.phar

[[email protected] php-5.5.32]# make

 

Build complete.

Don‘t forget to run ‘make test‘.

 

 

cp php.ini-production /appliction/php/lib/php.ini

配置php-fpm 設定檔

cp php-fpm.conf.default php-fpm.conf

啟動php-fpm

/application/php/sbin/php-fpm

lsof -i :9000

ps -ef |grep php-fpm

3.4 phpinfo()測試頁

[[email protected] conf ]# cd ../../html/blog/

echo "<?php phpinfo();?>">test_info.php在windows下的hosts解析(10.0.0.111為當前的機器的IP)命令如下:

 650) this.width=650;" title="2.png" alt="wKioL1iYgAvzLHfmAAAH2Y8X9nw757.png-wh_50" src="http://s2.51cto.com/wyfs02/M00/8D/56/wKioL1iYgAvzLHfmAAAH2Y8X9nw757.png-wh_500x0-wm_3-wmp_4-s_238407235.png" />


 650) this.width=650;" title="1.png" alt="wKiom1iYf8Ly8a5RAACrAc6t1zo380.png-wh_50" src="http://s5.51cto.com/wyfs02/M00/8D/59/wKiom1iYf8Ly8a5RAACrAc6t1zo380.png-wh_500x0-wm_3-wmp_4-s_46324664.png" />

 

能見到這個面頁,已經證明PHP安裝成功了。


本文出自 “pcjazz” 部落格,請務必保留此出處http://520527.blog.51cto.com/510527/1895893

LNMP環境部署之---PHP編譯安裝。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.