下载软件包,进入http://nginx.org/download/复制对应版本的下载链接地址
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 时提示如下错误时:
nginx: [emerg] getpwnam(“nobody”) failed
解决方案
在nginx.conf中 把user nobody的注释去掉,换成 root
user root;
worker_processes 4; #使用的cpu数