Ubuntu下安装、运行Nginx

发布于:2024-06-25 ⋅ 阅读:(125) ⋅ 点赞:(0)

安装Ubuntu桌面系统(虚拟机)_虚拟机安装ubuntu桌面版-CSDN博客

默认情况下,Ubuntu并没有安装Nginx服务。用户可以使用以下命令安装Nginx服务及其相关的组件:

liu@ubuntu:~$ sudo apt install nginx

安装完成之后,使用以下命令启用和启动Nginx服务:

liu@ubuntu:~$ sudo systemctl enable nginx
liu@ubuntu:~$ sudo systemctl start nginx

然后查看NFS服务状态,如下所示:

liu@ubuntu:~$ 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 Tue 2024-01-23 16:45:33 CST; 2min 32s ago
       Docs: man:nginx(8)
   Main PID: 266718 (nginx)
      Tasks: 3 (limit: 4555)
     Memory: 3.9M
        CPU: 36ms
     CGroup: /system.slice/nginx.service
             ├─266718 "nginx: ubuntu process /usr/sbin/nginx -g daemon on; ubuntu_process on;"
             ├─266721 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             └─266722 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

1月 23 16:45:33 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
1月 23 16:45:33 ubuntu systemd[1]: Started A high performance web server and a reverse proxy server.
.

可以发现,Nginx服务已经正常启动了。

用户可以找个浏览器访问Nginx,如下图所示。

本文节选自《Ubuntu Linux运维从零开始学》,获出版社和作者授权发布。

《Ubuntu Linux运维从零开始学 肖志健 清华大学出版社9787302662525》【摘要 书评 试读】- 京东图书 (jd.com)