目录
简介:
Nginx(engine x)是一个高性能的Http和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。同Tomcat一样,Nginx可以托管用户编写的WEB应用程序成为可访问的网页服务,同时也可以作为流量代理服务器使用,控制流量中转。
安装:
Nginx同样需要配置额外的yum仓库,才可以使用yum安装
安装Nginx的操作需要root身份
1.安装yum依赖程序
#root执行
yum install -y yum-utils
如图:
2.手动添加,nginx的yum仓库
yum程序使用的仓库配置文件,存放在:/etc/yum.repo.d内。
#root执行
#创建文件使用vim编辑
vim /etc/yum.repos.d/nginx.repo
#填入以下内容并保存退出
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=http://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=http://nginx.org/keys/nginx_signing.key
module_hotfixes=true
如图:
3.通过yum安装最新稳定版的nginx
#root执行
yum -y install nginx
4.启动
#nginx自动注册了systemctl系统服务
systemctl start nginx #启动
systemctl stop nginx #停止
systemctl status nginx #查看运行状态
systemctl enable nginx #打开开机自启
systemctl disable nginx #关闭开机自启
5.配置防火墙放行
nginx默认绑定80端口,需要关闭防火墙或放行80端口
#关闭防火墙
systemctl stop firewalld #关闭
systemctl disable firewalld #关闭开机自启
6.查询80端口是否绑定nginx
命令:
netstat -anp | grep 80
如图:
7.启动后浏览器输入linux服务器的IP地址或主机名即可访问
http://192.168.88.133 或 http://centos