1.在nginx.org里的下载里安装最新版的nginx
2.通过FileZilla上传到服务器
3.安装依赖环境
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
4.解压nginx
tar -xvf nginx-1.16.1.tar.gz(你自己的nginx名字)
5.编译之前先创建nginx临时文件,如果不创建在启动nginx的时候会报错
mkdir /var/temp/nginx -p
6.在nginx目录 输入一下命令进行配置 目的是为了创建makefile文件
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/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
可以看到创建了MakeFile了
7.make 编译
make
8.安装
make install
9.进入sbin 目录启动nginx
./nginx
停止:./nginx -s stop
重新加载: ./nginx -s reload
10.打开浏览器访问虚拟机内网ip 即可打开nginx默认网页 显示一下则表示成功
注意事项:
1.如果在云服务器安装,需要开启默认的nginx端口:80
2.如果在虚拟机安装,需要关闭防火墙
3.本地win或mac需要关闭防火墙
1.查看防火墙状态
2.关闭
3.禁止开机启动
firewall-cmd --state
systemctl stop firewalld.service
systemctl disable firewalld.service