centos 安装 nginx


# 安装
sudo yum install nginx

# 启动/关闭/重载/开机自启/关闭开机自启
sudo systemctl [start/stop/reload/enable/disable] nginx

sudo systemctl start nginx

sudo systemctl stop nginx

sudo systemctl  enable nginx

# nginx相关命令
# 检查配置文件(修改nginx.conf 或 nginx/conf.d/*.conf内的内容后使用)
sudo nginx -t
# 重载配置文件(检查 提示没有问题后 重载下配置文件即可生效)
sudo nginx -s reload

验证Nginx是否正确安装并运行
curl http://localhost/您应该会看到Nginx的欢迎页面输出。如果您能看到这个页面,那么Nginx已经成功安装并运行在您的CentOS系统上了。

 

查看状态:

# 查看 Nginx 版本
nginx -v
nginx version: nginx/1.20.1
# 查看 Nginx 安装目录
rpm -ql nginx