CentOS7.4安装nginx和php5.40

一.安装nginx(这里我安装的是1.15)

1.安装必要的依赖

yum install pcre pcre-devel openssl openssl-devel -y

2.添加用户群组

useradd nginx -s /sbin/nologin -M

3.安装nginx

tar -zxvf nginx-1.15.6.tar.gz

cd  nginx-1.15.6

./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

make && make install

二.安装php

1.安装必要的依赖

yum install bzip2-devel libmcrypt-devel libxml2-devel libjpeg-devel libpng-devel freetype-devel libicu-devel libxslt* curl curl-devel libxslt-devel* -y

2.安装libmcrypt

tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install
sleep 2
/sbin/ldconfig 

3.安装php

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/conf.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --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=/usr/local/curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-opcache=no --enable-intl --with-xsl

make && make install

cp php.ini-production /usr/local/php/etc/php.ini

cp /usr/local/php/etc/php-fpm.conf.default  usr/local/php/etc/php-fpm.conf

4.错误处理

CentOS7.4安装nginx和php5.40

编译的时候加 --enable-opcache=no

CentOS7.4安装nginx和php5.40# 添加搜索路径到配置文件
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
# 更新配置
ldconfig -v