Centos 7 安裝nginx指定版本


官方版本列表:http://nginx.org/download/

1.安裝

wget http://nginx.org/download/nginx-1.10.3.tar.gz
tar -zxvf nginx-1.10.3.tar.gz
cd nginx-1.10.3
./configure
make && make install

 

編譯時添加模塊

./configure --with-http_stub_status_module --with-http_ssl_module

 

*./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 https://blog.csdn.net/one312/article/details/104087364
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 

 


https://blog.csdn.net/testcs_dn/article/details/51461750

https://www.cnblogs.com/karrya/p/11851496.html

https://www.cnblogs.com/czlun/articles/7010601.html

https://blog.csdn.net/testcs_dn/article/details/51461999

https://www.cnblogs.com/yan-zm/p/12217118.html

 


免責聲明!

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



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