- 安装前提
首先安装组件 ``` - gcc && g++ yum install gcc-c++
- pcre yum install -y pcre pcre-devel
- zlib yum install -y zlib zlib-devel
- openssl yum install -y openssl openssl-devel ```
- 安装 ```
- 解压nginx文件 tar -zxvf nginx-1.17.5.tar.gz
- 安装
创建一个nginx安装目录
mkdir nginx cd nginx-1.12.2指定文件安装路径
./configure —prefix=/usr/local/nginx —conf-path=/usr/local/nginx/conf/nginx.conf —error-log-path=/usr/local/nginx/logs/error.log —pid-path=/usr/local/nginx/logs/nginx.pid —http-log-path=/usr/local/nginx/logs/access.log —with-http_gzip_static_module —with-http_stub_status_module —with-http_ssl_module make make install安装完成后内容会安装到指定的路径 /home/lege/nginx下,否则会在默认目录/usr/local/nginx
```
- 启动
```
修改配置文件
cd /home/lege/nginx/conf vim nginx.conf设置端口为8080,也可设置成其他
listen 8080;进入到启动目录
cd /home/lege/nginx/sbin检查配置文件是否有问题
./nginx -t没有问题的结果如下所示:
[soa@testsoa04 sbin]$ ./nginx -t nginx: the configuration file /home/lege/nginx/conf/nginx.conf syntax is ok nginx: configuration file /home/lege/nginx/conf/nginx.conf test is successful [soa@testsoa04 sbin]$
查询配置参数
./nginx -V
对于已安装的nginx需要修改配置参数
./configure —prefix=/home/lege/nginx …配置参数 make make install 然后重新启动nginx即可
启动
./nginx
停止
./nginx -s stop
重启
./nginx -s reload
输入网址验证是否启动成功
http://ip:port/ ```
离线安装
- 下载rpm组件,https://pan.baidu.com/s/1hO4emswy_di-JBM-PHD1qg
提取码:kfvl
输入rpm -ivh nginx-1.12.0-1.el7.ngx.x86_64.rpm - 启动nginx
/usr/sbin/nginx- nginx的配置文件目录在
/etc/nginx/conf.d/中进行配置 - 启动目录在
/usr/sbin/下
- nginx的配置文件目录在
