更新最新源

1
yum update

##一、安装PHP

删除之前的 php 版本

1
yum remove php* php-common

rpm 安装 PHP7 相应的 yum源

1
2
3
4
5
6
CentOS/RHEL 7.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
CentOS/RHEL 6.x:
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

yum安装php7

1
yum install php70w php70w-opcache

安装其他插件(选装)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
php70w
php70w-bcmath
php70w-cli
php70w-common
php70w-dba
php70w-devel
php70w-embedded
php70w-enchant
php70w-fpm
php70w-gd
php70w-imap
php70w-interbase
php70w-intl
php70w-ldap
php70w-mbstring
php70w-mcrypt
php70w-mysql
php70w-mysqlnd
php70w-odbc
php70w-opcache
php70w-pdo
php70w-pdo_dblib
php70w-pear
php70w-pecl-apcu
php70w-pecl-imagick
php70w-pecl-xdebug
php70w-pgsql
php70w-phpdbg
php70w-process
php70w-pspell
php70w-recode
php70w-snmp
php70w-soap
php70w-tidy
php70w-xml
php70w-xmlrpc

##二、安装Nginx

1
yum install nginx

##三、配置Nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
server {
listen 80;
server_name open-cbh.kmlidc.com;
root /home/wwwroot/openApi;
index index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
root /home/wwwroot/openApi;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/wwwroot/openApi$fastcgi_script_name;
include fastcgi_params;
}
}

##安装php-fpm

install php70w-fpm```
1
2
启动php-fpm

$whereis php-fpm

$/usr/local/php/sbin/php-fpm

1
2
查看端口和进程

ps -ef|grep php-fpm

netstat -tnl | grep 9000

```

开机启动php-fpm

开机启动的配置文件是:/etc/rc.local ,加入 /usr/local/php/sbin/php-fpm 即可