Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_38390092/article/details/90216232
Nginx install 1.10.2
Lightweight Web server, reverse proxy server
(LINUX)
1.安装 gcc (命令: yum install gcc)
注:gcc -v 查询是否已经安装
2.安装pcre (命令:yum install pcre-devel)
3.安装zlib (命令:yum install zlib zlib-devel)
4.安装openssl (命令:yum install openssl spenssl-devel)
Note: You need only install ssl support
综合命令:yum -y install gcc zlib zlib-devel pcre-devel openssl opssl-devel
5.下载源码包,选择稳定版本,解压安装 http://www.nginx.org/
1).wget nginx.org/download/nginx-1.10.2.tar.gz
或访问 download.happymmall.com/nginx-1.10.2.tar.gz
2).tar -zxvf nginx-1.10.2.tar.gz
6.Nginx安装
1).进入nginx目录之后执行./configure
也可以指定安装目录,增加参数--prefix=/usr/nginx
如果不指定路径,可以通过whereis nginx进行查询
默认安装在/usr/local/nginx
2).继续执行make
3).继续执行make install
WINDOWS installation:
下载 - 解压 - 运行nginx.exe
Nginx commonly used commands
测试配置文件 安装路径/nginx/sbin/nginx -t
启动命令 安装路径/nginx/sbin/nginx
停止命令 安装路径/nginx/sbin/nginx -s stop 或者 nginx -s quit
重启命令 安装路径/nginx/sbin/ngin -s reload
查看进程命令 ps -ef |grep nginx
Graceful Restart
kill -HUP [Nginx主进程号(即查看进程命令查到的PID)]
Adding firewall access
1.sudo vim /etc/sysconfig/iptables
2.-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
3.保存退出
4.重启防火墙sudo service iptables restart
Nginx virtual domain configuration and verification test
Configuration Steps
1.编辑 sudo vim /usr/local/nginx/conf/nginx.conf
1) 添加 include vhost/*.conf
2) 保存退出
2.在/usr/local/nginx/conf/目录新建vhost文件夹
即 /usr/local/nginx/conf/vhost
3.重启验证
启动:${nginx}$/sbin/nginx
重启:${nginx}$/sbin/nginx -s reload
4.访问验证
使用默认80端口访问验证 localhost:80 或者 IP
Local Application Notes
可以配置域名转发,但是一定要配置 host 且host生效之后才可以,设置完成重启游览器
Linux
1. sudo vim /etc/hosts
2. 添加好对应的域名及ip
3. :wq保存退出
Windows
1.进入 C:\Windows\System32\drivers\etc
2.用记事本打开hosts文件
3.添加好对应的域名及ip
4.保存退出
As 10.211.55.x image.tdh.com etc.
注: 若 ftpfile 没有索引文件 index.html 访问会失败