ubuntu安装nginx
时间: 2023-11-14 19:09:31 浏览: 138
ubuntu下编译安装nginx
好的,以下是在 Ubuntu 上安装 Nginx 的步骤:
1. 打开终端,输入以下命令更新软件包列表:
```
sudo apt update
```
2. 安装 Nginx:
```
sudo apt install nginx
```
3. 启动 Nginx 服务:
```
sudo systemctl start nginx
```
4. 确认 Nginx 是否已经启动:
```
sudo systemctl status nginx
```
如果 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 Mon 2021-08-23 14:22:12 UTC; 1min 30s ago
Docs: man:nginx(8)
Process: 1234 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 1235 (nginx)
Tasks: 2 (limit: 1137)
Memory: 3.9M
CGroup: /system.slice/nginx.service
├─1235 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─1236 nginx: worker process
Aug 23 14:22:12 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 23 14:22:12 ubuntu systemd[1]: Started A high performance web server and a reverse proxy server.
```
5. 如果你想让 Nginx 在系统启动时自动启动,可以输入以下命令:
```
sudo systemctl enable nginx
```
6. 现在你可以在浏览器中输入服务器的 IP 地址,应该能够看到 Nginx 的欢迎页面。
阅读全文