CentOS配置NGINX的PHP环境

创建网络用户

groupadd www-data
useradd -g www-data www-data -M -s /usr/sbin/nologin

NGINX全局配置(nginx.conf)

user www-data;
worker_processes 2;

NGINX站点配置(default)

root   /var/www/html;
index  index.php index.html index.htm;
location / {
    root /var/www/html;
    try_files $uri $uri/ /index.html;
}
location ~ \.php$ {
    root   /var/www/html;
    fastcgi_pass   unix:/var/run/php5-fpm.sock;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

PHP-FPM配置

listen = /var/run/php5-fpm.sock
user = www-data
group = www-data

更改目录权限

chown -R www-data:www-data /var/www/html

防火墙配置

iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 443 -j ACCEPT
service iptables save

标签: none

添加新评论

www.000webhost.com