安装包下载
下载地址:http://nginx.org/en/download.html
安装依赖:
1.安装依赖
yum install -y gcc
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
2.安装nginx
创建临时目录
mkdir /var/temp/nginx -p
./configure \
--prefix=/usr/local/nginx \
--pid-path=/usr/local/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/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
make
make install
3.启动nginx
通过安装在/usr/local下有一个nginx目录
进入nginx下的sbin目录执行命令:./nginx
4.验证是否正常
打开浏览器,输入虚拟机的IP,如果发现访问不通,
则尝试关闭防火墙:
systemctl stop firewalld.service //关闭防火墙
system disable firewalld.service //禁止防火墙开机自启
重启防火墙:
systemctl restart firewalld
再访问发现nginx访问成功
至此nginx安装成功