48 openEuler搭建Nginx服务器-验证web服务是否搭建成功

文章目录

      • 48 openEuler搭建Nginx服务器-验证web服务是否搭建成功
        • 48.1 查看ip地址
        • 48.2 配置防火墙
        • 48.3 验证web服务器是否搭建成功

48 openEuler搭建Nginx服务器-验证web服务是否搭建成功

Web服务器搭建完成后,可以通过如下方式验证是否搭建成功。

48.1 查看ip地址

在root权限下查看服务器的IP地址,命令如下:

# ifconfig

回显信息如下,说明服务器IP为 192.168.1.21。

例如示例命令如下:

[root@superman-21 ~]# ifconfig -a
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.21  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::9393:f6ae:ced9:7759  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:96:c9:d7  txqueuelen 1000  (Ethernet)
        RX packets 66449  bytes 93282768 (88.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3734  bytes 377884 (369.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 74  bytes 6068 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 74  bytes 6068 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:bc:bb:cd  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0-nic: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 52:54:00:bc:bb:cd  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@superman-21 ~]# 

48.2 配置防火墙

在root权限下配置防火墙:

# firewall-cmd --add-service=http --permanent
# firewall-cmd --reload

例如示例命令如下:

[root@superman-21 ~]# firewall-cmd --add-service=http --permanent
success
[root@superman-21 ~]# 
[root@superman-21 ~]# firewall-cmd --reload
success
[root@superman-21 ~]#

48.3 验证web服务器是否搭建成功

验证web服务器是否搭建成功,用户可选择Linux或Windows系统进行验证。

  • 使用Linux系统验证

    执行如下命令,查看是否可以访问网页信息,服务搭建成功时,该网页可以正常访问。

# curl http://192.168.1.21

例如示例命令如下:

[root@superman-21 ~]# curl http://192.168.1.21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Test Page for the Nginx HTTP Server on openEuler</title>
        <style type="text/css">
            /*<![CDATA[*/
            body {
                background-color: #fff;
                color: #000;
                font-size: 0.9em;
                font-family: sans-serif,helvetica;
                margin: 0;
                padding: 0;
            }
            :link {
                color: #c00;
            }
            :visited {
                color: #c00;
            }
            a:hover {
                color: #f50;
            }
            h1 {
                text-align: center;
                margin: 0;
                padding: 0.6em 2em 0.4em;
                background-color: #294172;
                color: #fff;
                font-weight: normal;
                font-size: 1.75em;
                border-bottom: 2px solid #000;
            }
            h1 strong {
                font-weight: bold;
                font-size: 1.5em;
            }
            h2 {
                text-align: center;
                background-color: #3C6EB4;
                font-size: 1.1em;
                font-weight: bold;
                color: #fff;
                margin: 0;
                padding: 0.5em;
                border-bottom: 2px solid #294172;
            }
            hr {
                display: none;
            }
            .content {
                padding: 1em 5em;
            }
            .alert {
                border: 2px solid #000;
            }

            img {
                border: 2px solid #fff;
                padding: 2px;
                margin: 2px;
            }
            a:hover img {
                border: 2px solid #294172;
            }
            .logos {
                margin: 1em;
                text-align: center;
            }
            /*]]>*/
        </style>
    </head>

    <body>
        <h1>Welcome to <strong>nginx</strong> on openEuler!</h1>

        <div class="content">
            <p>This page is used to test the proper operation of the
            <strong>nginx</strong> HTTP server after it has been
            installed. If you can read this page, it means that the
            web server installed at this site is working
            properly.</p>

            <div class="alert">
                <h2>Website Administrator</h2>
                <div class="content">
                    <p>This is the default <tt>index.html</tt> page that
                    is distributed with <strong>nginx</strong> on
                    openEuler.  It is located in
                    <tt>/usr/share/nginx/html</tt>.</p>

                    <p>You should now put your content in a location of
                    your choice and edit the <tt>root</tt> configuration
                    directive in the <strong>nginx</strong>
                    configuration file
                    <tt>/etc/nginx/nginx.conf</tt>.</p>

                </div>
            </div>

            <div class="logos">
                <a href="http://nginx.net/"><img
                    src="nginx-logo.png" 
                    alt="[ Powered by nginx ]"
                    width="121" height="32" /></a>
            </div>
        </div>
    </body>
</html>
[root@superman-21 ~]# 

执行如下命令,查看命令返回值是否为0,返回值为0,说明nginx服务器搭建成功。

# echo $?

例如示例命令如下:

[root@superman-21 ~]# echo $?
0
[root@superman-21 ~]# 
  • 使用Windows系统验证

打开浏览器,在地址栏输入如下地址,如果能正常访问网页,说明nginx服务器搭建成功。

http://192.168.1.21

48 openEuler搭建Nginx服务器-验证web服务是否搭建成功_第1张图片

如果修改了端口号,输入地址格式如下:

http://192.168.1.21:端口号

48 openEuler搭建Nginx服务器-验证web服务是否搭建成功_第2张图片

点赞,你的认可是我创作的动力!

⭐️ 收藏,你的青睐是我努力的方向!

✏️ 评论,你的意见是我进步的财富!

48 openEuler搭建Nginx服务器-验证web服务是否搭建成功_第3张图片

你可能感兴趣的:(服务器,nginx,开源软件,云计算,linux)