10-29 13:39 nginx 技巧 centos安装指定nginx版本 #### 添加依赖环境 ```shell yum install -y wget yum install -y vim-enhanced yum install -y make cmake gcc gcc-c++ yum install -y pcre pcre-devel yum install -y zlib zlib-devel yum install -y openssl openssl-devel ``` #### 下载nginx 打开[官网](http://nginx.org/en/download.html "官网")选择所需下载的版本。 ```shell wget http://nginx.org/download/nginx-1.18.0.tar.gz ``` #### 编译安装 ```shell tar -zxvf nginx-1.18.0.tar.gz cd nginx-1.18.0 ./configure \ --prefix=/usr/local/nginx \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/temp/nginx/client \ --http-proxy-temp-path=/var/temp/nginx/proxy \ --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --with-http_stub_status_module \ --with-http_ssl_module \ --http-scgi-temp-path=/var/temp/nginx/scgi ``` 注意上面将临时文件目录指定为/var/temp/nginx,需要在var下创建temp/nginx 目录。(参数具体介绍 见`./configure --help`) ```shell make && make install ``` #### 设置全局变量并启动 ```shell ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ ```