编译安装
1、安装编译环境
yum -y install gcc gcc-c++ make ncurses ncurses-devel
2、安装pcre软件包(使nginx支持http rewrite模块)
yum install -y pcre pcre-devel
3、安装openssl-devel(使nginx支持ssl)
yum install -y openssl openssl-devel
4、安装zlib
yum install -y zlib zlib-devel
5、创建用户nginx
useradd nginx
groupadd nginx
6、下载安装包
yum -y install wget //如果有就不需要该操作
wget http://nginx.org/download/nginx-1.16.0.tar.gz
7、解压
tar xzf nginx-1.16.0.tar.gz -C /usr/local/
8、切换路径
cd /usr/local/nginx-1.16.0/
9、配置
./configure --prefix=/usr/local/nginx --group=nginx --user=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-stream
10、编译并安装
make && make install
11、启动
- 切换到
nginx
下的sbin
下
cd ../nginx/sbin
- 执行Nginx
./nginx
可能遇到的问题
解决方法
12、检查版本
nginx -v