Nginx环境部署

Nginx环境部署

阿简
2024-09-28 / 0 评论 / 3 阅读 / 正在检测是否收录...

Ubuntu/Debian 上安装 Nginx

# 更新包索引
sudo apt update

# 安装 Nginx
sudo apt install nginx

# 启动 Nginx
sudo systemctl start nginx

# 设置开机自启
sudo systemctl enable nginx

# 检查 Nginx 状态
sudo systemctl status nginx

2. 在 CentOS 上安装 Nginx

# 安装 EPEL 仓库
sudo yum install epel-release

# 安装 Nginx
sudo yum install nginx

# 启动 Nginx
sudo systemctl start nginx

# 设置开机自启
sudo systemctl enable nginx

# 检查 Nginx 状态
sudo systemctl status nginx

Rocky Linux 上安装 Nginx

# 安装 EPEL 仓库
sudo dnf install epel-release

# 安装 Nginx
sudo dnf install nginx

# 启动 Nginx
sudo systemctl start nginx

# 设置开机自启
sudo systemctl enable nginx

# 检查 Nginx 状态
sudo systemctl status nginx

验证安装

访问 http://localhost 来验证 Nginx 是否成功运行。
应该能看到 Nginx 的默认欢迎页面。

要检查 Nginx 版本、重载和重启,可以使用以下命令:

检查版本

nginx -v

重载 Nginx

sudo systemctl reload nginx

重启 Nginx

sudo systemctl restart nginx

重载会应用配置文件的更改,而重启会停止再启动 Nginx。

0

评论 (0)

取消