center os 7 安裝nginx


安裝配置nginx

1、下載安裝包nginx1.10.3

1.2---解壓到/usr/local

1.3---進入目錄 執行./configure

# ./configure,

報錯:

 

出現這個錯誤,是因為gcc包沒有安裝

# yum -y install gcc

# whereis gcc

 

安裝gcc之后,運行./configure,

報錯:

./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using --without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using --with-pcre=<path> option.

 

安裝pcre-devle 解決問題 

# yum -y install pcre-devel  

(這里我順便安裝了openssl  # yum -y install pcre-devel openssl openssl-devel )

執行 ./configure

 

如果報錯:

...Require the zlib library

...

則執行安裝

# yum install zlib-devel -y

 

1.4 -- opensslsha1

如果你想使用openssl功能 sha1功能 那么需要安裝opensslsha1

# yum install openssl openssl-devel

開啟ssl模塊 :

# ./configure --with-http_ssl_module

 

 

啟用”server_status”頁

# ./configure --with-http_stub_status_module

 

上述兩條命令同時啟用 可以使用如下命令:

# ./configure --with-http_stub_status_module --with-http_ssl_modile

 

1.5--##編譯 安裝

上面configure就通過了

執行make make install 命令 ##編譯 安裝

# make   

# make install

至此,nginx執行成功了。

 

1.6--配置環境變量

# whereis nginx

nginx:/usr/local/nginx

 

/etc/profile 中加入配置

# vim /etc/profile

在配置文件中加入:

#nginx configure

export NGINX_HOME=/usr/local/nginx

export PATH=$PATH:$NGINX_HOME/sbin

編譯完保存退出

 

# source /etc/profile

使配置生效 

整個過程,就安裝成功了

 

修改nginx,conf

2.1 啟動nginx

# cd /usr/local/nginx

# nginx -c conf/nginx.conf

啟動成功后,將在瀏覽器打開 ip加端口號  默認端口號是80

用瀏覽器打開看到帶有welcome to nginx 的頁面

 


免責聲明!

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



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