Centos 7 安裝nginx指定版本

2022-03-24 06:22:39 字數 2425 閱讀 1966

官方版本列表:

1.安裝

wget nginx-1.10.3.tar.gz

tar -zxvf nginx-1.10.3.tar.gz

cd nginx-1.10.3./configure

make && make install

編譯時新增模組

*./configure: error: the http rewrite module requires the pcre library 解決方案

yum -y install pcre-devel

#debian

apt-get install libpcre3 libpcre3-dev

*./configure: error: ssl modules require the openssl library. 解決方案

yum -y install openssl openssl-devel

#debian

sudo apt-get install libssl-dev

sudo apt-get install libssl0.9.8

* ./configure: error: c compiler cc is not found 解決方案

yum -y install gcc gcc-c++ autoconf automake make

#debian安裝方法

apt-get install linux-headers-$(uname -r | sed 's,[^-]*-[^-]*-,,')

apt-get install build-essential

* make: *** no rule to make target `build', needed by `default'.  stop. 解決方案:

* zlib library

yum -y install make zlib-devel gcc-c++ libtool openssl openssl-devel

#debian

apt-get install zlib1g

apt-get install zlib1g.dev

2.配置

* 配置檔案路徑(可能不一樣)/usr/local/nginx/conf/nginx.conf

#

配置服務

vi /lib/systemd/system/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

#

常用命令

systemctl start nginx.service #

啟動nginx

systemctl stop nginx.service #

結束nginx

systemctl restart nginx.service #

重啟nginx

3.防火牆配置

埠放行:

firewall-cmd --zone=public --list-ports  #

查詢放行的埠

firewall-cmd --zone=public --add-port=80/tcp --permanent #

新增放行埠(80埠)

firewall-cmd --reload #

一定要重啟防火牆

或者直接關閉防火牆:

systemctl stop firewalld.service

systemctl disable firewalld.service

附:配置檔案編輯

vi /usr/local/nginx/conf/nginx.conf

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 安...