本打算安装7.2的,但yum里似乎还 没有7.2的源,索性安装7.2吧。
1、添加yum源
sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
2、yum安装php7.1
sudo yum install -y mod_php71w php71w-cli php71w-common php71w-gd php71w-mbstring php71w-mcrypt php71w-mysqlnd php71w-xml
3、配置7.2
sudo cp /etc/php.ini /etc/php.ini.bak
sudo vi /etc/php.ini
4、安装nginx
yum install nginx
5、启动nginx
systemctl start nginx.service
安装好nginx后,默认的网站根目录在 /usr/share/nginx/html
nginx的配置文件在:/etc/nginx/nginx.conf
参考:https://www.vultr.com/docs/how-to-install-php-7-x-on-centos-7