栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

OpenEuler 第五章《安装软件并管理服务》思考题

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

OpenEuler 第五章《安装软件并管理服务》思考题

从华为云镜像站下载nginx源码,并编译安装nginx.
[root@openEuler ~]# wget https://repo.huaweicloud.com/nginx/nginx-1.9.9.tar.gz

解压与编译

tar -zxvf nginx-1.9.9.tar.gz
cd nginx-1.9.9
./configure
make
make install

 进入安装目录

[root@openEuler nginx-1.9.9]# cd /usr/local/nginx/sbin/

启动nginx

[root@openEuler sbin]# nginx

测试是否安装成功,访问网页

[root@openEuler sbin]# curl http://127.0.0.1



Welcome to nginx!

html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }



Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.


配置主机防火墙服务,要求计算机重启后仍能通过网页访问nginx首页.

此时无法在浏览器中通过IP地址访问,需要配置主机防火墙服务

查询防火墙状态,是在运行中

[root@openEuler sbin]# service firewalld status
Redirecting to /bin/systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-10-12 11:20:02 CST; 5h 32min ago
     Docs: man:firewalld(1)
 Main PID: 773 (firewalld)
    Tasks: 2
   Memory: 31.5M
   CGroup: /system.slice/firewalld.service
           └─773 /usr/bin/python3 /usr/sbin/firewalld --nofork --nopid

Oct 12 11:20:01 openEuler systemd[1]: Starting firewalld - dynamic firewall daemon...
Oct 12 11:20:02 openEuler systemd[1]: Started firewalld - dynamic firewall daemon.

查询防火墙规则,发现并没有开放80端口

[root@openEuler sbin]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s3
  sources: 
  services: dhcpv6-client mdns ssh
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
[root@openEuler sbin]# firewall-cmd --query-port=80/tcp
no

添加80端口,重启防火墙,再查询防火墙规则,可以看到80商品已经开放

[root@openEuler sbin]# firewall-cmd --permanent --add-port=80/tcp
success
[root@openEuler sbin]# service firewalld restart
Redirecting to /bin/systemctl restart firewalld.service
[root@openEuler sbin]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s3
  sources: 
  services: dhcpv6-client mdns ssh
  ports: 80/tcp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
[root@openEuler sbin]# firewall-cmd --query-port=80/tcp
yes

浏览器中就可以正常访问nginx

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/320523.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号