软件:VMware 12
系统:CentOS 7
1.安装开发工具包
[root@localhost ~]# yum groups mark install 'Development Tools'
[root@localhost ~]# yum -y install wget bzip2 bzip2-devel gcc gcc-c++
2.创建系统用户ngin
[root@localhost ~]# groupadd -r nginx
[root@localhost ~]# useradd -r -s /sbin/nologin -M -g nginx nginx
3.安装依赖环境
[root@localhost ~]#yum -y install pcre-devel openssl openssl-devel gd-devel
4.创建日志存放目录
[root@localhost ~]# mkdir -p /var/log/nginx
[root@localhost ~]# chown -R nginx.nginx /var/log/nginx/
5.下载nginx
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
6.编译安装
[root@localhost src]# tar xf nginx-1.12.0.tar.gz
[root@localhost src]# cd nginx-1.12.0
[root@localhost nginx-1.12.0]# ./configure \
> --prefix=/usr/local/nginx \
> --user=nginx \
> --group=nginx \
> --with-debug \
> --with-http_ssl_module \
> --with-http_realip_module \
> --with-http_image_filter_module \
> --with-http_gunzip_module \
> --with-http_gzip_static_module \
> --with-http_stub_status_module \
> --http-log-path=/var/log/nginx/access.log \
> --error-log-path=/var/log/nginx/error.log
[root@localhost nginx-1.12.0]# make && make install
7.nginx安装后配置
[root@localhost nginx-1.12.0]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@localhost nginx-1.12.0]# . /etc/profile.d/nginx.sh
8.启动
[root@localhost ~]# nginx
参考文档:https://blog.csdn.net/weixin_44437026/article/details/88066510