Linux CentOS8 安裝 Nginx


使用 yum 直接安裝:

yum install nginx

運行完成會出現 Complete! 表示安裝成功。

Linux sudo 命令以系統管理者的身份執行指令,也就是說,經由 sudo 所執行的指令就好像是 root 親自執行。
我都是使用root賬號直接操作的,非root賬號的朋友可以帶上 sudo。

啟用並啟動Nginx服務:

sudo systemctl enable nginx
sudo systemctl start nginx

停止服務:

sudo systemctl stop nginx

要驗證服務是否正在運行,檢查其狀態:

sudo systemctl status nginx

安裝完后訪問我們的站點即可看到紅白色的

Welcome to nginx on Red Hat Enterprise Linux!

不得不說比Windows的看起來有排面多了。

然后需要改配置。。給我愁的,搞了半天沒找到裝在哪里了。

查看nginx安裝目錄

Linux 中的 ps 命令是 Process Status 的縮寫。ps命令用來列出系統中當前運行的那些進程。
| 符號,是個管道符號,表示ps 和 grep 命令同時執行;
grep 命令是查找(Global Regular Expression Print),能使用正則表達式搜索文本,然后把匹配的行顯示出來;

輸入命令

ps  -ef | grep nginx

返回結果包含了安裝目錄 :

root      344802       1  0 09:08 ?        00:00:00 nginx: master process /usr/sbin/nginx
nginx     344803  344802  0 09:08 ?        00:00:00 nginx: worker process
root      392857  392766  0 15:04 pts/1    00:00:00 grep --color=auto nginx

但是我發現這里沒有配置文件 - -

查看nginx.conf配置文件目錄

輸入命令

nginx -t

返回結果包含配置文件目錄
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

這樣就找到了配置文件所在的位置,更改即可。
改完之后不要忘記重啟一下

nginx -s reload


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM