nginx
1 安装
1.1 添加 nginx 的 yum 源
创建文件 /etc/yum.repos.d/nginx.repo
, 文件中写入如下内容:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/x86_64/
gpgcheck=0
enabled=1
1.2 安装
yum install -y nginx
2 nginx 服务管理
systemctl start nginx # 开启nginx
systemctl stop nginx # 停止nginx
systemctl restart nginx # 重启nginx
systemctl reload nginx # 在不关闭服务的前提下 ,重新加载配置
systemctl status nginx # 查看服务的状态
systemctl enable nginx # 设置开机自启动
systemctl disable nginx # 取消开机自启动
要想 nginx 成功运行,我们需要关闭防火墙
# 关闭linux防火墙
systemctl stop firewalld
# 永久关闭防火墙
systemctl disabled firewalld
并且关闭 SELinux
打开 selinux 配置文件
vim /etc/selinux/config
将 SELINUX=enforcing 改为 SELINUX=disabled,保存后退出。
最后重启主机。
3 nginx 配置文件位置
/etc/nginx/nginx.conf
/etc/nginx/conf.d/*.conf;