下載軟件包,進(jìn)入http://nginx.org/download/復(fù)制對應(yīng)版本的下載鏈接地址
1.最新安裝包下載
wget?http://nginx.org/download/nginx-1.13.11.tar.gz
2.解壓
tar zxf nginx-1.13.11.tar.gz
3.安裝
./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-pcre --with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx
make && make install
如果遇到以下問題
編譯安裝nginx卻requires the PCRE library編譯安裝nginx需要pcre包,未安裝會有如下提示:
1.
./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using --with-pcre= option.
需要安裝pcre的devel包匆赃,pcre-devel。使用yum安裝即可:
yum -y install zlib zlib-devel
2.
./configure: error: SSL modules require the OpenSSL library.You can either do not enable the modules, or install the OpenSSL libraryinto the system, or build the OpenSSL library statically from the sourcewith nginx by using --with-openssl= option.
需要安裝ssl包
yum?-y?install?openssl?openssl-devel??
啟動 nginx 時(shí)提示如下錯(cuò)誤時(shí):
nginx: [emerg] getpwnam(“nobody”) failed
解決方案
在nginx.conf中 把user nobody的注釋去掉,換成 root
user root;
worker_processes 4; #使用的cpu數(shù)