Ubuntu22.04.2安装Nginx详细步骤!!

张彦鹏的博客 / 2023-07-29 / 原文

安装
更新软件包列表
apt update
安装nginx:
sudo apt install nginx -y
查看nginx服务是否启动
sudo systemctl status nginx
基础命令
查看版本
nginx -v
nginx version: nginx/1.18.0 (Ubuntu)

检查 配置文件
sudo nginx -t
正确返回结果:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

启动nginx
sudo nginx
停止服务
sudo nginx -s stop
重新加载配置文件
sudo nginx -s reload