Nginx常见的使用

添加源

sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

安装Nginx

sudo yum install -y nginx

启动Nginx

sudo systemctl start nginx.service

验收

如果一切进展顺利的话,现在你可以通过你的域名或IP来访问你的Web页面来预览一下Nginx的默认页面;

CentOS 7 开机启动Nginx

sudo systemctl enable nginx.service

开放80端口

##Add
firewall-cmd --permanent --zone=public --add-port=80/tcp
##Reload
firewall-cmd --reload

默认目录

网站文件存放默认目录
/usr/share/nginx/html
网站默认站点配置
/etc/nginx/conf.d/default.conf
自定义Nginx站点配置文件存放目录
/etc/nginx/conf.d/
Nginx全局配置
/etc/nginx/nginx.conf

Nginx命令相关

1)以754的权限保存在目录:

/usr/lib/systemd/system
(2)设置开机自启动

systemctl enable nginx.service 
(3)启动nginx服务

systemctl start nginx.service
(4)停止开机自启动

systemctl disable nginx.service
(5)查看服务当前状态

systemctl status nginx.service
(6)重新启动服务

systemctl restart nginx.service
(7)查看所有已启动的服务

systemctl list-units --type=service

Nginx配置域名隐射到端口