```
下載到本地上傳,http://cn2.php.net/get/php-7.1.16.tar.gz/from/this/mirror
```
或者wget
```
wget http://cn2.php.net/get/php-7.1.16.tar.gz/from/this/mirror
mv mirror php.tar.gz
```
解壓PHP包
```
tar xf php.tar.gz
```
打開PHP解壓好的目錄
```
cd php-7.1.16 /
```
yum安裝所需要的插件
```
yum install libxml2-devel curl-devel libjpeg-devel libpng-devel openssl-devel freetype-devel libxslt-devel -y
yum install http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y
yum install libmcrypt-devel -y
```
##
安裝PHP模塊
```
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --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-mcrypt
--with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath
--enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-gd
--enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --with-xmlrpc --enable-zip
--enable-soap --with-gettext --enable-opcache --with-xsl
```
查看下有沒有錯誤語法
```
echo $?
```
## 執行安裝:
```
make?&&?make?install
```
# PHP配置
安裝目錄下
拷貝文件到安裝好的目錄下
```
cp php.ini-development /usr/local/php/etc/php.ini
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d
cp www.conf.default www.conf
```
## 啟動PHP
```
usr/local/php/sbin
./php-fpm
```
# 配置nginx啟動PHP
```
cd usr/local/nginx/conf
```
## 刪除nginx.conf
```
rm -f nginx.conf
```
然后
## 復制nginx.conf.default 改名為nginx.conf
```
cp nginx.conf.default nginx.conf
```
```
vim nginx.conf
刪除注釋打開這段代碼,修改include 為fastcgi.conf
```
```
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
```
## 修改下面這段代碼添加 index.php
```
location / {
root html;
index index.php index.html index.htm;
}
```
## 重置nginx
```
cd usr/local/nginx/sbin
./nginx -s reload
```
## 啟動nginx
```
./nginx
```
進入到 nginx 里的html目錄下 寫一個index.php文件 試試輸出就可以