安装
添加源,可以参考官网安装说明
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。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。