手机版

CentOS7 yum安装Nginx Web服务器

时间:2020-03-17 来源:互联网 编辑:宝哥软件园 浏览:

关于Nginx

Nginx是一个高性能的web服务器软件。它与Apache HTTP Server比较,更加地灵活和轻量级。

本文介绍如何在CentOS7上使用yum安装Nginx。

步骤1 – 添加Nginx仓库

执行如下命令配置Nginx官方仓库

cat > /etc/yum.repos.d/nginx.repo << EOF
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
EOF

步骤2 – 安装Nginx

现在使用yum安装Nginx:

sudo yum -y install nginx

步骤3 – 启动nginx

Nginx安装后不会自动启动,执行如下命令启动nginx

sudo systemctl start nginx

如何启用了firewall,执行如下命令来允许HTTP和HTTPS流量:

sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

这样你就可以在浏览器输入http://server_domain_name_or_IP/来访问nginx了,如图
CentOS7 yum安装Nginx Web服务器

步骤4 – 设置开机启动nginx

sudo systemctl enable nginx

版权声明:CentOS7 yum安装Nginx Web服务器是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。

相关文章推荐