在CentOS 8系统中安装Nginx
在CentOS 8系统中安装Nginx
从CentOS 8开始,Nginx软件包在默认的CentOS存储库中可用。
在CentOS 8系统中安装Nginx只需输入以下命令即可:
$ sudo yum install nginx
参考:在RHEL 8/CentOS 8上安装LEMP(Nginx、MariaDB、PHP7.2)的方法。
安装完成后,使用以下命令启用并启动Nginx服务:
$ sudo systemctl enable nginx
$ sudo systemctl start nginx
要验证服务是否正在运行,请检查其状态:
$ sudo systemctl status nginx
输出如下所示:
nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2019-10-06 18:35:55 UTC; 17min ago
调整防火墙(Firewall)
FirewallD是Centos 8中的默认防火墙解决方案。
在安装过程中,Nginx使用预定义的规则创建防火墙服务文件,以允许访问HTTP(80)和HTTPS(443)端口。
使用以下命令永久打开必要的端口:
$ sudo firewall-cmd --permanent --zone=public --add-service=http
$ sudo firewall-cmd --permanent --zone=public --add-service=https
$ sudo firewall-cmd --reload

浙公网安备 33010602011771号