温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

LNMP—PHP的编译安装

发布时间:2020-06-29 17:47:59 来源:网络 阅读:899 作者:听丶飞鸟说 栏目:web开发

    按照LNMP的顺序,我们应该先编译MySQL,再编译PHP,最后编译Nginx,因为LNMP的MySQL和LAMP的MySQL编译一样,所以我们就略过,不再阐述了具体可以看这个链接http://286577399.blog.51cto.com/10467610/1671029

    另外补充一个MySQL的源码网站:http://mirrors.sohu.com/mysql/

    还需要注意一个问题,那就是我们单独配置LNMP的思路是不对的,我们的思路应该也必须是LAMP+Nginx,即LANMP;而我们想当然会认为LNMP+Apache也行,但是这样的的思路是错误的,这一点需要注意一下。

    下面直接进入LNMP的PHP编译:

[root@LnmpLinux support-files]# cd /usr/local/src

    下载

[root@LnmpLinux src]# wget http://cn2.php.net/distributions/php-5.6.12.tar.bz2

    解压

[root@LnmpLinux src]# tar jxvf php-5.6.12.tar.bz2

    创建用户

[root@LnmpLinux src]# useradd -s /sbin/nologin php-fpm

    进入php目录编译

[root@LnmpLinux src]# cd php-5.6.12

[root@LnmpLinux php-5.6.12]# ./configure --prefix=/usr/local/php2 --with-config-file-path=/usr/local/php2/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --enable-zend-multibyte --disable-ipv6 --with-pear --with-curl --with-openssl


我们应该注意的问题:

    在上面编译安装过程中,有两行用“红字”标示出来,如下所示:

   --prefix=/usr/local/php2 --with-config-file-path=/usr/local/php2/etc

因为我们是在LAMP的基础上,进行LNMP的编译安装,LAMP中已经编译过PHP了,所以我们要对LNMP中的PHP的目录做一下更改,及上面编译命令中的绿字部分,有利于我们区分开来,对于此点更改下文中均会以“绿字”标示出来

安装过程中出现的问题解决方法:

问题一

    configure: error: jpeglib.h not found.

    [root@LnmpLinux php-5.6.12]# yum list |grep jpeg

    [root@LnmpLinux php-5.6.12]# yum install -y libjpeg-turbo-devel

    重新编译安装

问题二

    configure: error: mcrypt.h not found. Please reinstall libmcrypt.

    需安装epel

    [root@LnmpLinux php-5.6.12]# rpm -ivh 'http://www.lishiming.net/data/p_w_upload/forum/epel-release-6-8_32.noarch.rpm'

    [root@LnmpLinux php-5.6.12]# yum list |grep mcry

    [root@LnmpLinux php-5.6.12]# yum install -y libmcrypt-devel

    重新编译安装


[root@LnmpLinux php-5.6.12]# make && make install

[root@LnmpLinux php-5.6.12]# echo $?

0

制作php全局配置文件

[root@LnmpLinux php-5.6.12]# cp php.ini-production /usr/local/php2/etc/php.ini

制作启动脚本

[root@LnmpLinux php-5.6.12]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

授予启动脚本权限

[root@LnmpLinux php-5.6.12]# chmod 755 /etc/init.d/php-fpm

加入启动进程

[root@LnmpLinux php-5.6.12]# chkconfig --add php-fpm

开机自动启动

[root@LnmpLinux php-5.6.12]# chkconfig php-fpm on

设置php-fpm的配置文件

[root@LnmpLinux php-5.6.12]# cd /usr/local/php2/etc

[root@LnmpLinux etc]# mv  php-fpm.conf.default  php-fpm.conf

检查有无语法错误

[root@LnmpLinux etc]# /usr/local/php2/sbin/php-fpm -t

启动服务

[root@LnmpLinux etc]# service php-fpm start

查看进程

[root@LnmpLinux etc]# ps aux |grep php-fpm

监听端口

[root@LnmpLinux etc]# netstat -lnp |grep php-fpm


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI