LNMP环境部署之---PHP编译安装。
前两篇文章是讲关于Nginx和MySQL的编译安装,接下来要完成三个软件中最难的一个环节,当然这只是对还没入门的同学说的。安装过一遍后知道技巧后,自然就好简单了,废话不说,直入正题。
1)检查确认Nginx及MySQL的安装路径:
[root@web01 ~]# ls -ld /application/
drwxr-xr-x 4 root root 4096 12月 9 07:52 /application/
[root@web01 ~]# ls -ld /application/nginx/
drwxr-xr-x 11 root root 4096 12月 1 21:48 /application/nginx/
2)检查端口及启动情况:
[root@oldboy ~]# 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)检查软件包
[root@oldboy ~]# rpm -qa zlib-devel libxml2-devellibjpeg-devel libjpeg-turbo-devel libconv-devel
zlib-devel-1.2.3-29.el6.x86_64
[root@oldboy ~]# rpm -qa freetype-devellibpng-devel gd-devel libcurl-devel libxslt-devel
4)安装需要的软件包
a.以下是通过repo源安装的软件
[root@oldboy ~]# 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下载二进制软件包,编译安装
[root@oldboy ~]# cd /home/oldboy/tools/
[root@oldboy tools]# wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
#### 可能下载超时,请在IE浏览器下载后再rz上传,比较好。
[root@oldboy tools]# tar zxf libiconv-1.14.tar.gz
[root@oldboy tools] # cd libiconv-1.14
[root@oldboy libiconv-1.14] # ./configureprefix=/usr/local/libiconv
[root@oldboy libiconv-1.14]make
[root@oldboy libiconv-1.14]make install
c.epel源(第三方源)
[root@oldboy ~] # wget -O /etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-6.repo
[root@oldboy ~] # yum install libmcrypt-develmcrypt mhash -y
d、用软链接
[root@LNMP php-5.5.32]# ln -s/application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
e、下载PHP
[root@LNMP tools]# wget http://mirrors.sohu.com/php/php-5.5.32.tar.gz
f、创建phar.phar文件
[root@LNMP tools]# cd php-5.5.32
[root@LNMP php-5.5.32]# touch ext/phar/phar.phar
[root@oldboy ~] # cd /applicalition/php5.5.32/
[root@oldboy 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
[root@oldboy 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、用软链接
[root@LNMP php-5.5.32]# ln -s/application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
解决方法2:
2、把ld.so.conf加入/application/mysql/lib路径。
[root@LNMP 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
[root@LNMP php-5.5.32]# ldconfig
报错2:make: *** [ext/phar/phar.php] Error127
解决方法:是由于缺少文件phar.phar,创建即可。
[root@LNMP php-5.5.32]# touch ext/phar/phar.phar
[root@LNMP 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()测试页
[root@LNMP conf ]# cd ../../html/blog/
echo "<?php phpinfo();?>">test_info.php在windows下的hosts解析(10.0.0.111为当前的机器的IP)命令如下:
能见到这个面页,已经证明PHP安装成功了。