安装php
- 如果安装了php,先卸载
yum remove php* php-common
- rpm安装php7的源
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装php和相关拓展
php 7
yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64
- php 5.6
yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64
安装php-fpm
php 7
yum install php70w-fpm
- php5.6
yum install php56w-fpm
- 检查php版本
php -v
配置nginx
server {
listen 2333;
root /data/projectName/public;
access_log /var/log/nginx/2333.port.log;
error_log /var/log/nginx/2333.port.error.log;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}