n gcclinux
yum install gcc-c++
n PCREnginx
yum install -y pcre pcre-devel
n zlibc++
yum install -y zlib zlib-devel
n openssl正則表達式
yum install -y openssl openssl-devel
yum install gcc-c++ yum install -y pcre pcre-devel yum install -y zlib zlib-devel yum install -y openssl openssl-devel
mkdir -p /var/temp/nginx /var/temp/nginx /var/log/nginx /var/run/nginx //不然運行或報錯 找不到文件 //"/var/run/nginx/nginx.pid" failed (2: No such file or directory)
cd nginx.1.15
//查看 默認安裝配置 ./config --help
//修改安裝配置 如下配置根據須要自行修改 直接命令行運行便可 ./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 \ --http-scgi-temp-path=/var/temp/nginx/scgi
//注意 若是報錯 ./configure: error: the HTTP rewrite module requires the PCRE library. 等 請查看第一步驟安裝的底層工具是否完整 能夠從新再次安裝
nginx根目錄下 make make install
//啓動 /usr/local/nginx/sbin/nginx
[root@yh01 sbin]# netstat -nltp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 5096/nginx 或者瀏覽器直接訪問本機80端口
vim /etc/profile # nginx export NGINX_HOME=/usr/local/nginx/ export PATH=$PATH:$NGINX_HOME/sbin