Centos 7安装nginx

nginx官方站点:nginx.org

分为mainline和stable两个分支。我们选择stable。

对常见发行版,站点提供了pre-built package:

http://nginx.org/en/linux_packages.html#stable

比如我用的centos 7.x,按照其提供的例子写一个nginx.repo:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

然后就可以sudo yum install nginx了。

使用systemctl [start|stop] nginx来启动/停止nginx server。

为了安全,我们最好修改网站的user和group。原则是网站的owner和nginx process的user不能相同,这样nginx运行时就不能向网站进行任意的写操作。

原文地址:https://www.cnblogs.com/byeyear/p/9261077.html