Ubuntu 20.04 安装 Nginx

1. 先更新 apt 包索引

apt update

2. 安装 Nginx

apt install nginx -y

3. 检查 Nginx 版本

# nginx -v
nginx version: nginx/1.18.0 (Ubuntu)

4. 检查 Nginx 服务状态

# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-05-25 15:00:36 UTC; 53s ago
       Docs: man:nginx(8)
   Main PID: 774358 (nginx)
      Tasks: 2 (limit: 1066)
     Memory: 5.7M
     CGroup: /system.slice/nginx.service
             ├─774358 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             └─774359 nginx: worker process

May 25 15:00:36 vultr systemd[1]: Starting A high performance web server and a reverse proxy server...
May 25 15:00:36 vultr systemd[1]: Started A high performance web server and a reverse proxy server.

5. 查看 Nginx 配置文件

cat /etc/nginx/nginx.conf

6. 重载 Nginx 配置

nginx -s reload

7. 停止或重启 Nginx

  • 配置文件位置在 /etc/nginx/,日志文件在 /var/log/nginx/
systemctl stop nginx  	# 停止服务
systemctl start nginx 	# 启动服务 
systemctl restart nginx   # 重启服务

猜你喜欢

转载自blog.csdn.net/u010953692/article/details/130877189