[[email protected] /]# mkdir /usr/local/nginx
[[email protected] /]# cd /usr/local/nginx
http://tengine.taobao.org/download_cn.html
本次下載的版本是2.3.2,下載完成上傳到linux目錄(usr/local/nginx)
[[email protected] nginx]# tar -zxvf tengine-2.3.2.tar.gz
[[email protected] nginx]# cd tengine-2.3.2
[[email protected] tengine-2.3.2]# yum -y install gcc
設置Nginx安裝路徑,如果沒有指定,默認爲/usr/local/nginx
[[email protected] tengine-2.3.2]# ./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= option.
如果出現了,就執行下這個
[[email protected] tengine-2.3.2]# yum -y install openssl openssl-devel
再次執行
[[email protected] tengine-2.3.2]# ./configure —prefix=/usr/local/nginx
[[email protected] tengine-2.3.2]# make
(make的過程是把各種語言寫的源碼文件,變成可執行文件和各種庫文件)
[[email protected] tengine-2.3.2]# make install
(make install是把這些編譯出來的可執行文件和庫文件複製到合適的地方)
參數 -c 指定了配置文件的路徑,如果不加的話就是使用默認的配置文件
[[email protected] tengine-2.3.2]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
停止操作是通過向nginx進程發送信號(什麼是信號請參閱linux文 章)來進行的
ps -ef | grep nginx
在進程列表裏 面找master進程,它的編號就是主進程號了
kill -QUIT 主進程號
kill -TERM 主進程號
pkill -9 nginx
另外, 若在nginx.conf配置了pid文件存放路徑則該文件存放的就是Nginx主進程號,如果沒指定則放在nginx的logs目錄下。有了pid文 件,我們就不用先查詢Nginx的主進程號,而直接向Nginx發送信號了,命令如下:
kill -信號類型 ‘/usr/nginx/logs/nginx.pid’
如果更改了配置就要重啓Nginx,要先關閉Nginx再打開?不是的,可以向Nginx 發送信號,平滑重啓。
平滑重啓命令:
kill -HUP 主進程號或進程號文件路徑
或者使用
/usr/nginx/sbin/nginx -s reload
注意,修改了配置文件後最好先檢查一下修改過的配置文件是否正 確,以免重啓後Nginx出現錯誤影響服務器穩定運行。
nginx -t -c /usr/nginx/conf/nginx.conf
或者
/usr/nginx/sbin/nginx -t
訪問
在瀏覽器中輸入IP:端口號(默認80),出現如下圖所示,說明安裝成功。