CentOS7编译安装新版LNMP环境

2019-10-13 20:27:07王冬梅

错误:configure: error: xml2-config not found. Please check your libxml2 installation.
解决办法:yum -y install libxml2-devel

错误:configure: error: Please reinstall the libcurl distribution -easy.h should be in <curl-dir>/include/curl/
解决办法:yum -y install libcurl-devel

错误:configure: error: jpeglib.h not found.
解决办法:yum -y install libjpeg-turbo-devel

错误:configure: error: png.h not found.
解决办法:yum -y install libpng-devel

错误:configure: error: freetype-config not found.
解决办法:configure: error: mcrypt.h not found. Please reinstall libmcrypt.

错误:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决办法:yum -y install libmcrypt-devel

安装php

[root@localhost php-5.3.27]# make && make install

以上每一个步骤,如果没有完全执行正确,那么下一步是无法进行的,使用 echo $? 看结果是否为 “0” , 如果不是,就是没有执行正确。

修改配置文件

cp php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/php/etc/php-fpm.conf

把如下内容写入该文件:

[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
user = php-fpm
group = php-fpm
listen.owner = nobody
listen.group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024

保存配置文件后,检验配置是否正确的方法为:

/usr/local/php/sbin/php-fpm -t

如果出现诸如 “test is successful” 字样,说明配置没有问题。

启动php-fpm

cp /usr/local/src/php-5.5.23/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
service php-fpm start


如果想让它开机启动,执行:

chkconfig php-fpm on

检测是否启动:

ps aux |grep php-fpm

看看是不是有很多个进程(大概20多个)。

安装nginx

下载nginx

cd /usr/local/src/
wget http://nginx.org/download/nginx-1.7.12.tar.gz

解压nginx

tar zxvf nginx-1.7.12.tar.gz

配置编译参数

cd nginx-1.7.12
./configure 
--prefix=/usr/local/nginx 
--with-http_realip_module 
--with-http_sub_module 
--with-http_gzip_static_module 
--with-http_stub_status_module 
--with-pcre

报错:./configure: error: the HTTP rewrite module requires the PCRE library.
解决办法: