linux 安裝與啟動nginx


linux系統為Centos 64位 

一、去http://nginx.org/download/上下載相應的版本下載nginx-1.8.0.tar.gz(注:還有更高版本的)。

二、解壓 tar -zxvf nginx-1.8.0.tar.gz

三、進入nginx-1.8.0/文件夾,設置一下配置信息 ./configure --prefix=/usr/local/nginx(安裝后的文件存放路徑)。

四、配置的時候可能會出現類似這樣的信息

./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-devel解決問題
yum -y install pcre-devel

安裝完成后再執行./configure --prefix=/usr/local/nginx

執行完后還有可能會出現這樣的問題:

checking for PCRE JIT support ... not found
checking for system md library ... not found
checking for system md5 library ... not found
checking for OpenSSL md5 crypto library ... not found
checking for sha1 in system md library ... not found
checking for OpenSSL sha1 crypto library ... not found
checking for zlib library ... found

解決辦法:

yum -y install openssl openssl-devel

 安裝完成后再執行./configure --prefix=/usr/local/nginx

 

 

出現這個說明,配置成功了!!~

五、make && make install

出現類似這樣的就表示安裝成功了

cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs'               || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' ||            mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html'               || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' ||            mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/root/setup/nginx/nginx-1.8.0'

 

安裝完后/usr/local/nginx 后出現幾個文件夾conf、html、logs、sbin

 

啟動nginx:

./usr/nginx/sbin/nginx

 

查看端口:

netstat -antp

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 19031/nginx
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 2771/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 906/sshd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2263/mysqld

 

 

nginx的80端口啟動了。

訪問安裝nginx的服務器地址,出現如下圖,說明成功了。

 


免責聲明!

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



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