在Ubuntu 18.04上安裝和配置Nginx

作者:西門人家

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

來源:LOFTER

安裝Nginx

Nginx的軟件包在Ubuntu默認(rèn)軟件倉(cāng)庫(kù)中可用。 安裝非常簡(jiǎn)單,只需鍵入以下命令:

sudo apt update
sudo apt install nginx

安裝完成后,請(qǐng)檢查Nginx服務(wù)的狀態(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服務(wù)

您可以像任何其他systemd單位一樣管理Nginx服務(wù)。 要停止Nginx服務(wù),請(qǐng)運(yùn)行:

sudo systemctl stop nginx

要再次啟動(dòng),請(qǐng)鍵入:

sudo systemctl start nginx

重新啟動(dòng)Nginx服務(wù):

sudo systemctl restart nginx

在進(jìn)行一些配置更改后重新加載Nginx服務(wù):

sudo systemctl reload nginx

如果你想禁用Nginx服務(wù)在啟動(dòng)時(shí)啟動(dòng):

sudo systemctl disable nginx

并重新啟用它:

sudo systemctl enable nginx

也可以使用service管理Nginx服務(wù)

停止Nginx服務(wù),請(qǐng)運(yùn)行:

sudo service nginx stop

要再次啟動(dòng),請(qǐng)鍵入:

sudo service nginx start

重新啟動(dòng)Nginx服務(wù):

sudo service nginx restart

在進(jìn)行一些配置更改后重新加載Nginx服務(wù):

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

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容