一.Nginx安装包下载
地址:下载地址
二.使用命令下载
wget -c http://nginx.org/download/nginx-1.18.0.tar.gz
三.配置安装Nginx需要的环境
1.安装gcc
yum install gcc-c++
2. 安装PCRE pcre-devel
yum install -y pcre pcre-devel
3.安装zlib
yum install -y zlib zlib-devel
4.安装Open SSL
yum install -y openssl openssl-devel
5.解压
将压缩包解压到 /usr/local 下
tar -zxvf nginx-1.18.0.tar.gz
6.自定义配置
需要再/var下创建temp,Nginx目录
./configure
–prefix=/usr/local/nginx --with-http_ssl_module
–conf-path=/usr/local/nginx/conf/nginx.conf
–pid-path=/usr/local/nginx/conf/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
7.编译
make install
8.运行Nginx
cd /usr/local/nginx/sbin/
./nginx 开启
./nginx -s stop 停止
./nginx -s quit 退出
./nginx -s reload 重启
9.Nginx配置文件
注:操作Nginx配置文件注意备份
cd /usr/local/nginx/conf
less nginx.conf
10.设置开启启动Nginx
vi /etc/rc.local
添加配置
/usr/local/nginx/sbin/nginx
给文件赋权
chmod 755 /etc/rc.local