CentOS7.5源码编译LNMP环境之PHP安装(三)

一、准备工作

1.1)源码包

libmcrypt-2.5.8.tar.bz2
php-5.6.13.tar.bz2

后续需要libzip-1.1.2.tar.gz可在线下载

1.2)解决依赖

[13:03:28 root@tuxing ~]#yum install php-pear -y 

//pear按照一定的分类来管理pear应用代码库,你
的pear代码可以组织到其中适当的目录中,其他人可以方便的检索并分享到你的成果;pear不仅仅是一个代码仓库,它同时也是一个标准,使用这个标准来书写你的php代码,将会增强你的程序的可读性,复用性,减少出错的几率;Pear通过两个类为你搭建了一个框架,实现了诸如析构函数,错误捕获功能,你通过继承就可以使用这些功能

1.3)PHP添加libmcrypt拓展

解压libmcrypt-2.5.8.tar.bz2包到目录中并编译

[13:04:49 root@tuxing software]#tar xf libmcrypt-2.5.8.tar.bz2 -C /usr/local/src/ ; cd /usr/local/src/libmcrypt-2.5.8/
[13:05:48 root@tuxing ~]#./configure --prefix=/usr/local/libmcrypt ; make ; make install ; cd

除开上面的依赖解决之外,还需要安装图片,xml,字体支持基本库,使用yum去安装,安装的时候,这些软件包自身也有依赖!

[13:07:33 root@tuxing ~]#yum install -y libxml2-devel libcurl-devel libjpeg-devel libpng-devel freetype freetype-devel libzip libzip-devel

1,4)需要添加到库文件路径

[13:07:33 root@tuxing ~]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf			#此行本有
/usr/local/libmcrypt/lib				#添加
/usr/local/mysql/lib  					#添加

[13:09:22 root@tuxing ~]#ldconfig 			#重新加载
[13:10:05 root@tuxing ~]#echo 'ldconfig' >> /etc/rc.local

二、编译安装php

1.1)解压至目录

[13:11:05 root@tuxing software]#tar xf php-5.6.13.tar.bz2 -C /usr/local/src/ ; cd /usr/local/src/php-5.6.13

1.2)源码编译

[13:12:17 root@tuxing php-5.6.13]# ./configure --prefix=/usr/local/php
–with-config-file-path=/usr/local/php --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --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-gd --enable-mysqlnd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --with-mcrypt=/usr/local/libmcrypt

出现如下就没有报错:

在这里插入图片描述
在执行如下:

[13:18:15 root@tuxing ~]#make -j 3 && make install ; cd		#过程有点长哈,慢慢等待!



[PEAR] Archive_Tar    - installed: 1.3.12
[PEAR] Console_Getopt - installed: 1.3.1
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util       - installed: 1.2.3
[PEAR] PEAR           - installed: 1.9.5
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/usr/local/src/php-5.6.13/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:          /usr/local/php/include/php/ext/pdo/		#出现此处则成功

注意!!!

若执行后出现提示libzip相关的报错,则需要安装libzip-1.1.2.tar.gz

1)先执行make clean
(2)在安装压缩支持库
[13:18:15 root@tuxing ~]#wget https://libzip.org/download/libzip-1.1.2.tar.gz	#在线下载到/software目录
(3)解压到指定目录
[13:25:51 root@tuxing software]#tar xf libzip-1.1.2.tar.gz -C /usr/local/src/ && cd /usr/local/src/libzip-1.1.24)编译
[13:27:39 root@tuxing libzip-1.1.2]#./configure --prefix=/usr/local/libzip && make && make install

在重新编译:php包
[13:12:17 root@tuxing php-5.6.13]# ./configure --prefix=/usr/local/php
–with-config-file-path=/usr/local/php --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --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-gd --enable-mysqlnd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --with-mcrypt=/usr/local/libmcrypt --with-pcre-dir=/usr/local/src/pcre-8.37/ --with-zlib-dir=/usr/local/libzip

三、配置php和php-fpm

1.1)PHP配置文件

[13:31:23 root@tuxing ~]#cp /usr/local/src/php-5.6.13/php.ini-production /usr/local/php/php.ini

1.2)PHP-FPM配置文件

[13:31:26 root@tuxing ~]#cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
这里是修改 /usr/local/php/etc/php-fpm.conf 运行用户和组改为nginx

1.3)PHP-FPM启动脚本

[13:32:23 root@tuxing ~]#cp /usr/local/src/php-5.6.13/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[13:33:14 root@tuxing ~]#chmod +x /etc/init.d/php-fpm		#加权限
[13:33:31 root@tuxing ~]#chkconfig php-fpm on				#开机启动
[13:33:38 root@tuxing ~]#/etc/init.d/php-fpm start			#启动脚本
Starting php-fpm  done
[13:33:56 root@tuxing ~]# ps -aux | grep php
root      72500  0.0  0.2 218592  4948 ?        Ss   13:33   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nobody    72501  0.0  0.2 220676  4860 ?        S    13:33   0:00 php-fpm: pool www
nobody    72502  0.0  0.2 220676  4860 ?        S    13:33   0:00 php-fpm: pool www
root      72986  0.0  0.0 112704   972 pts/1    S+   13:34   0:00 grep --color=auto php

1.4)测试LNMP的PHP支持

[13:34:10 root@tuxing ~]#echo "<?php phpinfo(); ?>" > /usr/local/nginx/html/index.php
[13:36:14 root@tuxing ~]#cat /usr/local/nginx/html/index.php
<?php phpinfo(); ?>

四、LNMP环境部署成功

这时候最后一步到来,使用浏览器访问http://IP地址/

在这里插入图片描述
1.到这里的时候,CentOS7.5源码编译安装LNMP环境就完成了!!!
2.若还有后续操作建议保存快照哟!!!
3.写的有问题随时提出我会加以改正!!!

发布了5 篇原创文章 · 获赞 1 · 访问量 213

猜你喜欢

转载自blog.csdn.net/weixin_44847002/article/details/105291547