安装
vi /etc/yum.repos.d/Nginx.repo [Nginx] name=Nginx repo baseurl=http://Nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
安装
yum install Nginx
启动
systemctl start Nginx
设置
开机自启动
systemctl enable Nginx
防火墙设置
firewall-cmd --zone=public --permanent --add-service=http firewall-cmd --reload
使用nobody用户运行
vi /etc/Nginx/Nginx.conf user nobody;
重载生效
Nginx -s reload
新建网站
新建网站目录
mkdir -p /www/domain
新建网站配置
vi /etc/Nginx/conf.d/domain.conf server { listen 80; server_name domain; root /www/domain; index index.html index.htm index.PHP; location / { try_files $uri $uri/ /index.PHP; } location ~ \.PHP$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.PHP; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
注意:目录/etc/Nginx/conf.d/default.conf是默认网站,使用的server_name是localhost:80。