LNMP环境部署之---PHP编译安装。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LNMP环境部署之---PHP编译安装。相关的知识,希望对你有一定的参考价值。

     LNMP环境部署之---php编译安装。


前两篇文章是讲关于nginxmysql的编译安装,接下来要完成三个软件中最难的一个环节,当然这只是对还没入门的同学说的。安装过一遍后知道技巧后,自然就好简单了,废话不说,直入正题。



1)检查确认NginxMySQL的安装路径:

[[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

报错2make: *** [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.phpwindows下的hosts解析(10.0.0.111为当前的机器的IP)命令如下:

 技术分享


 技术分享

 

能见到这个面页,已经证明PHP安装成功了。


本文出自 “pcjazz” 博客,请务必保留此出处http://520527.blog.51cto.com/510527/1895431

以上是关于LNMP环境部署之---PHP编译安装。的主要内容,如果未能解决你的问题,请参考以下文章

基于CentOS6.5环境之下的LNMP之编译安装PHP5.5.30

lnmp环境搭建之编译安装php-5.3.27.tar.gz

LNMP环境搭建之编译安装指南(php-5.3.27.tar.gz)

LNMP之PHP 编译安装

LNMP之编译安装PHP出现的问题

LNMP之编译安装PHP出现的问题