博客
关于我
linux下安装nginx
阅读量:239 次
发布时间:2019-03-01

本文共 974 字,大约阅读时间需要 3 分钟。

Nginx安装与配置指南

安装Nginx

安装Nginx前,需要先安装Nginx存储库:

sudo yum -y install epel-release

接着安装Nginx:

sudo yum -y install nginx

启动Nginx服务并开机自启:

sudo systemctl start nginxsudo systemctl enable nginx

配置Nginx

默认配置文件位于 /etc/nginx/nginx.conf,可以通过以下命令查看配置文件位置:

nginx -t

重新加载配置文件:

nginx -s reload

重启Nginx服务:

sudo systemctl restart nginx

关闭Nginx服务(可选保存正在工作的工作进程):

sudo nginx -s stop

退出Nginx并保存正在工作的工作进程:

sudo nginx -s quit

启动Nginx:

nginx

其他配置

防火墙设置

允许HTTP通信:

sudo firewall-cmd --permanent --zone=public --add-service=http

允许HTTPS通信:

sudo firewall-cmd --permanent --zone=public --add-service=https

重启防火墙:

sudo firewall-cmd --reload

删除Nginx

停止Nginx服务:

sudo service nginx stop

如果上述命令无效,可以使用:

ps aux|grep nginxkill -9 

删除Nginx的自动启动:

chkconfig nginx off

从源头删除Nginx:

rm -rf /usr/sbin/nginx /etc/nginx /etc/init.d/nginx

使用YUM清理:

sudo yum remove nginx -y

查找Nginx目录:

whereis nginx

删除相关目录:

rm -rf /usr/lib64/nginx /usr/share/nginx /var/lib/nginx /var/log/nginx

查找并删除Nginx文件:

find / -name 'nginx' -delete

转载地址:http://atnt.baihongyu.com/

你可能感兴趣的文章
python glob的安装和使用
查看>>
Python google drive API 下载,文件在哪里?
查看>>
Python GPS 模块:读取最新的 GPS 数据
查看>>
python grpc入门
查看>>
python gRPC测试helloworld
查看>>
python list,str的拼接与转换
查看>>
python matplotlib简单使用
查看>>
python os.system
查看>>
Python os.system执行多条语句,os.system的返回值以及与os.popen的区别
查看>>
Python os和sys模块
查看>>
python os文件/目录
查看>>
Python Package 之 Faker(随机姓名、电话)
查看>>
python pandas TimeStamps到夏令时的本地时间字符串
查看>>
Python Pandas 用顶行替换标题
查看>>
Python Pandas-从DataFrame按类别绘制多个条形图
查看>>
Python PyQt5 将不再显示此消息复选框添加到 QMessageBox
查看>>
Python PyQt5:如何使用 PyQt5 显示错误消息
查看>>
Python pytest 面试题!
查看>>
Python pytz 时区函数返回一个相差 9 分钟的时区
查看>>
python rabbitmq实现简单/持久/广播/组播/topic/rpc消息异步发送可配置Django
查看>>