基础材料:
nginx-1.12.2.tar.gz CentOS7.4
安装步骤:
[root@localhost ~]# groupadd nginx
[root@localhost ~]# useradd -g nginx -s /sbin/nologin -M nginx
[root@localhost ~]# yum install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl openssl-devel -y
说明:
pcre pcre-devel:Nginx 的Rewrite模块和HTTP 核心模块会使用到PCRE正则表达式语法。
zlip zlib-devel:nginx启用压缩功能的时候,需要此模块的支持。
openssl openssl-devel:开启SSL的时候需要此模块的支持。
[root@localhost ~]# tar -zxvf nginx-1.12.2.tar.gz
[root@localhost ~]# cd nginx-1.12.2
[root@localhost ~]# ./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre
[root@localhost ~]# make && make install
说明:
prefix 指定编译安装路径
with-http_ssl_module 提供https服务支持
with-http_gzip_static_module 提供压缩支持
with-http_stub_status_module 提供基本状态信息访问支持
with-pcre 提供正则表达式支持
安装完成后生成目录说明:
conf:保存nginx所有的配置文件,其中nginx.conf是nginx服务器的最核心最主要的配置文件
html:目录中保存了nginx服务器的web文件,还有一个50x的web文件是默认的错误页面提示页面。
logs:用来保存nginx服务器的访问日志错误日志等日志
sbin:保存nginx二进制启动脚本
NGINX启动:
[root@localhost ~]# cd /opt/nginx/sbin
[root@localhost ~]# ./nginx
NGINX停止
[root@localhost ~]# ./nginx -s stop
NGINX重新加载配置文件:
[root@localhost ~]# ./nginx -s reload