在Ubuntu 18.04上安裝和配置Nginx

作者:西門人家

鏈接:http://www.lofter.com/lpost/1e67b34f_12e76d115

來源:LOFTER

安裝Nginx

Nginx的軟件包在Ubuntu默認軟件倉庫中可用。 安裝非常簡單,只需鍵入以下命令:

sudo apt update
sudo apt install nginx

安裝完成后,請檢查Nginx服務的狀態(tài)和版本:

sudo 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: en
Active: active (running) since Sat 2018-05-05 21:54:25 CST; 1 day 7h ago
Docs: man:nginx(8)
Main PID: 2188 (nginx)
Tasks: 5 (limit: 4471)
CGroup: /system.slice/nginx.service
├─2188 nginx: master process /usr/sbin/nginx -g daemon on; master_pro
├─2189 nginx: worker process
├─2190 nginx: worker process
├─2191 nginx: worker process
└─2192 nginx: worker process

5月 05 21:54:17 linuxidc systemd[1]: Starting A high performance web server and
5月 05 21:54:24 linuxidc nginx[2032]: nginx: [warn] conflicting server name "lin
5月 05 21:54:25 linuxidc nginx[2187]: nginx: [warn] conflicting server name "lin
5月 05 21:54:25 linuxidc systemd[1]: Started A high performance web server and a

sudo nginx -v

輸出:

nginx version: nginx/1.14.0 (Ubuntu)

使用systemctl管理Nginx服務

您可以像任何其他systemd單位一樣管理Nginx服務。 要停止Nginx服務,請運行:

sudo systemctl stop nginx

要再次啟動,請鍵入:

sudo systemctl start nginx

重新啟動Nginx服務:

sudo systemctl restart nginx

在進行一些配置更改后重新加載Nginx服務:

sudo systemctl reload nginx

如果你想禁用Nginx服務在啟動時啟動:

sudo systemctl disable nginx

并重新啟用它:

sudo systemctl enable nginx

也可以使用service管理Nginx服務

停止Nginx服務,請運行:

sudo service nginx stop

要再次啟動,請鍵入:

sudo service nginx start

重新啟動Nginx服務:

sudo service nginx restart

在進行一些配置更改后重新加載Nginx服務:

sudo service nginx reload 
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容