Nignx基础操作
Nginx安装&卸载
使用yum安装、卸载nginx:
sudo yum -y install nginx # 安装 nginxsudo yum remove nginx # 卸载 nginx
安装成功后,默认的网站目录为: /usr/share/nginx/html
默认的配置文件为:/etc/nginx/nginx.conf
自定义配置文件目录为: /etc/nginx/conf.d/
Nginx 及其模块的工作方式在配置文件中确定。默认情况下,配置文件被命名nginx.conf 并放置在目录 /usr/local/nginx/conf、 /etc/nginx或 /usr/local/etc/nginx。
Nginx检查配置
nginx -t
Nginx启动
sudo service nginx start # 启动 nginx 服务systemctl start nginx
Nginx设置开机启动
sudo systemctl enable nginx # 设置开机启动systemctl enable nginx # 设置开机启动systemctl disable nginx # 禁用开机启动
Nginx常用操作
nginx -s stop # fast shutdown 快速关闭nginx -s quit # graceful shutdown 优雅关闭nginx -s reload # reloading the configuration file 重新加载配置文件nginx -s reopen # reopening the log files 重新打开日志文件sudo service nginx stop # 停止 nginx 服务sudo service nginx restart # 重启 nginx 服务sudo service nginx reload # 重新加载配置,一般是在修改过 nginx 配置文件时使用
Nginx查看运行状态
systemctl status nginx
