centos7 安裝nginx 完整步驟

2021-10-01 23:35:27 字數 1819 閱讀 4224

安裝pcre和pcre-devel

pcre(perl compatible regular expressions) 是乙個perl庫,包括 perl 相容的正規表示式庫。

nginx 的 http 模組使用 pcre 來解析正規表示式,pcre-devel 是使用 pcre 開發的乙個二次開發庫。

yum install -y pcre pcre-devel

安裝zlib zlib提供了很多壓縮和解方式,nginx需要zlib對http進行gzip

yum install -y zlib zlib-devel

安裝openssl openssl是乙個安全套接字層密碼庫,nginx要支援https,需要使用openssl

yum install -y openssl openssl-devel

wget

解壓

tar -zxvf nginx-1.14.0.tar.gz

cd到檔案路徑

cd nginx-1.14.0/

編譯

./configure

安裝

make && make install

如果您正在執行防火牆,請執行以下命令以允許http和https通訊:

firewall-cmd --permanent --zone=public --add-service=http

配置nginx開機啟動,切換到/lib/systemd/system/目錄,建立nginx.service檔案vim nginx.service

cd /lib/systemd/system/

vim nginx.service

檔案內容如下:

[unit]

description=nginx

after=network.target

[service]

type=forking

execstart=/usr/local/nginx/sbin/nginx

execreload=/usr/local/nginx/sbin/nginx reload

execstop=/usr/local/nginx/sbin/nginx quit

privatetmp=true

[install]

wantedby=multi-user.target

退出並儲存檔案,執行systemctl enable nginx.service使nginx開機啟動

systemctl enable nginx.service

啟動校驗:

systemctl start nginx.service    #啟動nginx

systemctl stop nginx.service #結束nginx

systemctl restart nginx.service #重啟nginx

輸入http://伺服器ip/ 如果能看到nginx的介面,就表示安裝成功了

重新整理nginx配置檔案:  進入到/usr/local/nginx/sbin 目錄下,執行  ./nginx -s reload

centos7安裝nginx與nginx配置檔案

yum install gcc c nginx原始碼編譯需要 yum install y pcre pcre devel nginx 的 http 模組使用 pcre 來解析正規表示式yum install y zlib zlib devel nginx 使用zlib對http包的內容進行gzipy...

Centos7 編譯安裝Nginx

nginx版本分開發版和穩定版,生產環境使用穩定版,實驗新功能,新特性可以使用開發版。安裝nginx編譯需要依賴的包 yum install gcc gcc c wget yum install pcre devel zlib devel openssl devel說明 zlib nginx提供gz...

CentOs7如何安裝nginx?

首先來說一下nginx是什麼有什麼作用,nginx是俄羅斯人開發的乙個開源的高效能的伺服器軟體,他主要用來左負載均衡或者反向 解決跨域問題等。nginx安裝 1 安裝必備工具工具 假設沒有安裝的話 yum y install wget gcc gcc c wgettar zxvf 你的安裝包名4 安...