1 安装gcc依赖
yum install -y gcc gcc-c++
2 安装pcre软件包(使nginx支持http rewrite模块)
yum install -y pcre
yum install -y pcre-devel
3 安装openssl-devel(使nginx支持ssl)
yum install -y openssl-devel
4 安装zlib库支持
yum install -y zlib zlib-devel
5 下载nginx
wget http://nginx.org/download/nginx-1.15.4.tar.gz
6 解压包
tar xvf nginx-1.15.4.tar.gz
7 进入nginx解压目录,运行配置
(1)运行默认安装配置
./configure
配置完成后会显示默认的安装路径:
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
注:默认安装在/usr/local/nginx目录下
(2)也可以指定配置参数安装,以及astdfs-nginx-module插件
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/local/nginx/nginx.pid \
--lock-path=/var/lock/nginx/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 \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--add-module=/opt/setups/FastDFS/fastdfs-nginx-module/src
8 编译
make
9 编译安装
make install
10 启动
cd /usr/local/nginx/sbin
./nginx -c /xxxxx/nginx.conf