Linux CentOS7 安装php简要过程以及nginx


Copy From  https://www.cnblogs.com/freeweb/p/5425554.html

修改了下:

1. 下载php源码:

wget  http://cn2.php.net/distributions/php-7.1.12.tar.gz

2.解压缩

tar -xzvf php....

3.原博主安装了很多依赖的库 主要有:

yum -y install libxml2
yum -y install libxml2-devel

yum -y install openssl
yum -y install openssl-devel
yum -y install curl
yum -y install curl-devel
yum -y install libjpeg
yum -y install libjpeg-devel
yum -y install libpng
yum -y install libpng-devel
yum -y install freetype
yum -y install freetype-devel
yum -y install pcre
yum -y install pcre-devel
yum -y install libxslt
yum -y install libxslt-devel
yum -y install bzip2
yum -y install bzip2-devel

我这边因为安装的CentOS比较全 所以没有需要

4. 配置一下:
直接copy原博主
./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip

5.安装
make && make install

6.添加非root用户
groupadd www-data
useradd -g www-data www-data

7.增加配置文件配置:
cp php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp sapi/fpm/php-fpm /usr/local/bin

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

8. 修改增加用户
vim /usr/local/php/etc/php-fpm.d/www.conf
user 和group 修改为 www-data

9. 启动
/usr/local/bin/php-fpm

10.netstat -tln | grep 9000 查看是否启动正常

修改nginx 主要修改的地方:
vim /usr/local/nginx/nginx.conf

location / {
root html;
index index.html index.htm index.php;
}

location ~* \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

最上面也得 加上使用的用户.

user www-data;











相关