nginx的安装

第一步:下载nginx

nginx源码链接nginx官方链接

第二步:copy压缩包到/usr/local下面

此处我以nginx-1.15.5.tar.gz为例

nginx部署dist文件500 nginx如何部署_Nginx

第三步:安装

tar -zxvf nginx-1.15.5.tar.gz

(此处我将解压之后的文件别名 你可以不用别名)

nginx部署dist文件500 nginx如何部署_centos_02


nginx部署dist文件500 nginx如何部署_nginx_03


第四步:下载所需要的类库

yum install pcre yum install pcre-devel

yum install zlib yum install zlib-devel

(在输入上面指令之后 直接输入y进入下一步)

nginx部署dist文件500 nginx如何部署_centos_04


第五步:进行config的配置

cd nginx(这里是我别名之后的) && ./configure --prefix=/usr/local/nginx

nginx部署dist文件500 nginx如何部署_重启_05

查看是否报错

nginx部署dist文件500 nginx如何部署_nginx部署dist文件500_06


第六步:在nginx的根目录下去执行 make&&make install

nginx部署dist文件500 nginx如何部署_Nginx_07


第七步:检验你是否安装成功

·cd到刚才配置的安装目录/usr/local/nginx/

./sbin/nginx -t(如果报下面错误)

nginx部署dist文件500 nginx如何部署_Nginx_08


执行下面的操作 在/usr/local/nginx/

mkdir logs

并赋予权限

chmod 700 logs

后在

./sbin/nginx -t

发现成功 如下图

nginx部署dist文件500 nginx如何部署_centos_09


第七步:进入/nginx/sbin目录下

启动

nginx部署dist文件500 nginx如何部署_Nginx_10

第八步 查看是否开启

netstat -tunpl |grep 80

nginx部署dist文件500 nginx如何部署_nginx部署dist文件500_11


关闭: -s stop -s reload 命令

第九步 打开网页访问 如果访问的页面出现下面错误 说明你端口没有放行

nginx部署dist文件500 nginx如何部署_nginx部署dist文件500_12

systemctl status firewalld 查看防火墙状态

nginx部署dist文件500 nginx如何部署_centos_13

systemctl start firewalld 开启防火墙

nginx部署dist文件500 nginx如何部署_Nginx_14


因为我使用的linux系统版本是CentOS7,所以可以在服务器中执行如下命令来验证

firewall-cmd --query-port=80/tcp

nginx部署dist文件500 nginx如何部署_Nginx_15

firewall-cmd --add-port=80/tcp --permanent 将80端口永久放行
#重启防火墙
systemctl restart firewalld

nginx部署dist文件500 nginx如何部署_nginx部署dist文件500_16


nginx部署dist文件500 nginx如何部署_nginx_17


第十步 最后再访问页面 成功

nginx部署dist文件500 nginx如何部署_nginx_18


再说下Nginx下目录的解析吧

Conf:存放配置文件的地方
Html:存放静态资源的地方 类似 Toncat下的webapps目录
Logs:存放日志的地方
Sbin:是用来存放启动文件的地方

nginx部署dist文件500 nginx如何部署_Nginx_19