進入目錄
[root@LnmpLinux ~]# cd /usr/local/src
下載下傳Nginx
[root@LnmpLinux src]# wget http://nginx.org/download/nginx-1.6.3.tar.gz
解壓Nginx
[root@LnmpLinux src]# tar zxvf nginx-1.6.3.tar.gz
編譯安裝
[root@LnmpLinux src]# cd nginx-1.6.3
[root@LnmpLinux nginx-1.6.3]# ./configure --prefix=/usr/local/nginx --with-pcre
編譯過程中出現的問題:
./configure: error: the HTTP rewrite module requires the PCRE library.
解決方法
[root@LnmpLinux nginx-1.6.3]# yum list |grep pcre
[root@LnmpLinux nginx-1.6.3]# yum install -y pcre-devel
重新編譯安裝
[root@LnmpLinux nginx-1.6.3]# echo $?
[root@LnmpLinux nginx-1.6.3]# make && make install
啟動
當我們啟動的時候,會顯示已經被之前的Apahce占用了,要想啟動Nginx,我們得把Apahce停掉。
[root@LnmpLinux nginx-1.6.3]# /usr/local/apache2/bin/apachectl stop
再啟動Nginx
[root@LnmpLinux nginx-1.6.3]# /usr/local/nginx/sbin/nginx
檢視程序
[root@LnmpLinux nginx-1.6.3]# ps aux |grep nginx
監聽端口
[root@LnmpLinux nginx-1.6.3]# netstat -lnp |grep nginx
補充:
Nginx并沒有自己的啟動腳本,我們可以手動去寫一個Nginx啟動腳本,前提我們需要先解析php,我們知道Nginx和PHP在配置之前是不能聯系到一起的,需要去手動更改配置檔案,讓兩者産生聯系,能正常執行PHP,解析PHP網站
本文轉自 聽丶飛鳥說 51CTO部落格,原文連結:http://blog.51cto.com/286577399/1683344