首先確認已經安裝好pcre 軟件(nginx 依賴該軟件)
進入 usr/local
從http://nginx.org/download/上下載相應的版本(或者wget
http://nginx.org/download/nginx-1.9.9.tar.gz直接在Linux上用命令下載)
解壓 tar -zxvf
nginx-1.9.9.tar.gz
cd 進入
設置一下配置信息 ./configure
--prefix=/usr/local/nginx ,或者不執行此步,直接默認配置
make && make install
如果有問題參數:
http://www.runoob.com/linux/nginx-install-setup.html
到nginx/sbing/ 下運行nginx ,或nginx -V 查看版本
有時會提示
-bash:
nginx: command not found。
這時可以創建軟連接試下:ln -s /usr/local/nginx/sbin/nginx /usr/bin
再輸入nginx 時提示:/usr/
local
/nginx/sbin/nginx:
error
while
loading
shared libraries: libpcre.so.1: cannot
open
shared
object
file
:
No such
file
or
directory
時可以 ln -s /usr/local/lib/libpcre.so.1 /lib64
然後再nginx
nginx -h #幫助
nginx -v #顯示版本
nginx -V #顯示版本和配置信息
nginx -t #測試配置
nginx -q #測試配置時,只輸出錯誤信息
nginx -s stop #停止服務器
nginx -s reload #重新加載配置