Centos7.4 安裝nginx和php-fpm:php
1. 安裝nginx:html
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y nginxmysql
systemctl restart nginxnginx
2. 配置php-fpmweb
項目目錄在/root/html下面,須要更改nginx默認目錄redis
查看nginx配置文件:sql
nginx -tcentos
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /root/html;
#修改全部root對應的目錄爲/var/www/html服務器
location ~ \.php$ {
root /root/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /root/html/$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}php7
從新加載nginx配置:
nginx -s reload
3. 安裝php-fpm:
用yum search all php-fpm安裝本身須要的版本
yum install -y php-fpm
這是PHP5的版本,要安裝高版本的php-fpm,須要按以下步驟:
1).安裝epel-release
經過命令:
yum -y install epel-release
2).安裝PHP7
終端再次運行以下命令:
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
3). yum查看
yum search php70w-fpm #PHP7.0
yum search php71w-fpm #PHP7.1
yum search php72w-fpm #PHP7.2
4). 安裝PHP 7.0、7.1的yum源,而後再執行:
安裝php 7.0以及擴展:
yum install php70w php70w-fpm php70w-cli php70w-common php70w-devel php70w-gd php70w-pdo php70w-mysql php70w-mbstring php70w-bcmath php70w-xml php70w-pecl-redis php70w-process php70w-intl php70w-xmlrpc php70w-soap php70w-ldap php70w-opcache
安裝php 7.1以及擴展:
yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath php71w-xml php71w-pecl-redis php71w-process php71w-intl php71w-xmlrpc php71w-soap php71w-ldap php71w-opcache
安裝php 7.2以及擴展:
yum install -y php72w php72w-fpm php72w-cli php72w-common php72w-devel php72w-gd php72w-pdo php72w-mysql php72w-mbstring php72w-bcmath php72w-xml php72w-pecl-redis php72w-process php72w-intl php72w-xmlrpc php72w-soap php72w-ldap php72w-opcache
5). 開啓服務
systemctl start php-fpm
6). 開機開啓服務
systemctl enable php-fpm
4. 寫一個PHP腳本phpinfo.php放到服務器web根目錄下:
<?php phpinfo();