CentOS下,yum安装nginx

一,准备篇
1,配置网络&关闭SELINUX&配置防火墙

配置网络&关闭SELINUX&配置防火墙

2,创建www用户
groupadd www && useradd -g www -s /bin/false www
二,安装篇
1,添加nginx官方yum源
vi /etc/yum.repos.d/nginx.repo
CentOS 6
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=1
enabled=1
CentOS 7
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=1
enabled=1
2,下载nginx签名密钥
rpm --import http://nginx.org/keys/nginx_signing.key
3,yum安装
yum -y install nginx
4,启动nginx
CentOS 6
service nginx start
CentOS 7
systemctl start nginx.service
systemctl enable nginx.service
5,状态管理命令
CentOS 6
/etc/rc.d/init.d/nginx
service nginx start
service nginx stop
service nginx restart
service nginx condrestart
service nginx try-restart
service nginx force-reload
service nginx upgrade
service nginx reload
service nginx status
service nginx help
service nginx configtest
service nginx check-reload
chkconfig nginx on                       #启用开机自启
chkconfig nginx off                      #禁用开机自启
CentOS 7
/usr/lib/systemd/system/nginx.service
systemctl start nginx.service
systemctl stop nginx.service
systemctl restart nginx.service
systemctl reload nginx.service
systemctl status nginx.service
systemctl enable nginx.service             #启用开机自启
systemctl disable nginx.service            #禁用开机自启
6,相关软件目录及文件位置
/usr/sbin/nginx
/etc/nginx/nginx.conf
/var/lock/subsys/nginx
/var/run/nginx.pid
三,优化篇

暂无

参考文章

NGINX Yum存储库官方指南

推荐阅读更多精彩内容