-
Nginx编译安装
yum install -y wget gcc-c++ make pcre pcre-deve zlib zlib-devel openssl openssl-devel#安装依赖包 cd/usr/local/src #放nginx包的目录 wget http://nginx.org/download/nginx-1.14.2.tar.gz #下载nginx包 tar -zxvf nginx-1.14.2.tar.gz #解压包 cd nginx-1.14.2 #进入nginx目录 ./configure --prefix=/usr/local/nginx #安装nginx到local目录下 make && make install #编译安装 vim /etc/profile #编辑环境变量配置文件 export PATH=$PATH:/usr/local/nginx/sbin/ #在环境变量文件末行加入这条配置 source /etc/profile #重新加载环境变量配置文件 nginx -V #查看nginx版本 nginx -t #检查配置文件是否正常 nginx #启动nginx ps auxfww| grep nginx #查看nginx进程是否启动 netstat -tulnp|grep nginx #查看nginx监控端口,默认是80端口 systemctl stop firewalld.service #关闭防火墙 systemctl disable firewalld.service #禁止防火墙开机启动 vim /etc/selinux/config #设置SELINUX=disabled 关闭selinux vim /usr/lib/systemd/system/nginx.service #使用sytemclt管理nginx 在nginx.service文件编写以下内容 [Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx [Install] WantedBy=multi-user.target systemctl daemon-reload #重新加载systemctl daemon-reload systemctl start nginx #使用systemctl管理启动nginx systemctl enable nginx #设置开机自动启动nginx 游览器打开服务器地址显示下面页面表示nginx开启正常 ![游览器打开服务器地址显示下面页面表示nginx开启正常](https://img-blog.csdnimg.cn/20190511150141689.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3Jhb3NoYW95dW4=,size_16,color_FFFFFF,t_70)