linux系统部署apache服务(测试不同inux主机访问网站)

以下实验中服务器端为PC1,IP地址为192.168.10.10 ;客户机端分别为PC2和PC3,IP地址分别为192.168.10.20和192.168.10.30

1、在PC1服务器端安装apache服务

[root@PC1 ~]# ifconfig | head -n 3  ## 查看IP
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.10  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::20c:29ff:fe66:37f7  prefixlen 64  scopeid 0x20<link>
[root@PC1 ~]# yum install httpd -y
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
rhel7                                                    | 4.1 kB     00:00     
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-17.el7 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-17.el7 for package: httpd-2.4.6-17.el7.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-17.el7.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-17.el7 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch           Version                 Repository     Size
================================================================================
Installing:
 httpd               x86_64         2.4.6-17.el7            rhel7         1.2 M
Installing for dependencies:
 apr                 x86_64         1.4.8-3.el7             rhel7         103 k
 apr-util            x86_64         1.5.2-6.el7             rhel7          92 k
 httpd-tools         x86_64         2.4.6-17.el7            rhel7          77 k
 mailcap             noarch         2.1.41-2.el7            rhel7          31 k

Transaction Summary
================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 1.5 M
Installed size: 4.3 M
Downloading packages:
--------------------------------------------------------------------------------
Total                                              5.9 MB/s | 1.5 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7.x86_64                                       1/5 
  Installing : apr-util-1.5.2-6.el7.x86_64                                  2/5 
  Installing : httpd-tools-2.4.6-17.el7.x86_64                              3/5 
  Installing : mailcap-2.1.41-2.el7.noarch                                  4/5 
  Installing : httpd-2.4.6-17.el7.x86_64                                    5/5 
rhel7/productid                                          | 1.6 kB     00:00     
  Verifying  : mailcap-2.1.41-2.el7.noarch                                  1/5 
  Verifying  : httpd-tools-2.4.6-17.el7.x86_64                              2/5 
  Verifying  : apr-1.4.8-3.el7.x86_64                                       3/5 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                  4/5 
  Verifying  : httpd-2.4.6-17.el7.x86_64                                    5/5 

Installed:
  httpd.x86_64 0:2.4.6-17.el7                                                   

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7                 apr-util.x86_64 0:1.5.2-6.el7       
  httpd-tools.x86_64 0:2.4.6-17.el7        mailcap.noarch 0:2.1.41-2.el7       

Complete!

 

2、在PC1服务器端启动apache服务

[root@PC1 ~]# systemctl start httpd
[root@PC1 ~]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
[root@PC1 ~]# systemctl status httpd
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: active (running) since Wed 2020-12-16 21:35:02 CST; 17s ago  ## 已启用
 Main PID: 3972 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─3972 /usr/sbin/httpd -DFOREGROUND
           ├─3973 /usr/sbin/httpd -DFOREGROUND
           ├─3974 /usr/sbin/httpd -DFOREGROUND
           ├─3975 /usr/sbin/httpd -DFOREGROUND
           ├─3976 /usr/sbin/httpd -DFOREGROUND
           └─3978 /usr/sbin/httpd -DFOREGROUND

Dec 16 21:35:02 PC1 httpd[3972]: AH00557: httpd: apr_sockaddr_info_get() fa...C1
Dec 16 21:35:02 PC1 httpd[3972]: AH00558: httpd: Could not reliably determi...ge
Dec 16 21:35:02 PC1 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

 

3、在PC2和PC3客户机端测试与PC1的网络连通性

[root@PC2 Desktop]# ifconfig | head -n 3
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.20  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::20c:29ff:fe25:bb3e  prefixlen 64  scopeid 0x20<link>
[root@PC2 Desktop]# ping -c 3 192.168.10.10
PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data.
64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=0.326 ms
64 bytes from 192.168.10.10: icmp_seq=2 ttl=64 time=0.245 ms
64 bytes from 192.168.10.10: icmp_seq=3 ttl=64 time=0.236 ms

--- 192.168.10.10 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.236/0.269/0.326/0.040 ms
[root@PC3 Desktop]# ifconfig | head -n 3
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.30  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::20c:29ff:fe7d:e711  prefixlen 64  scopeid 0x20<link>
[root@PC3 Desktop]# ping -c 3 192.168.10.10
PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data.
64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=0.316 ms
64 bytes from 192.168.10.10: icmp_seq=2 ttl=64 time=0.231 ms
64 bytes from 192.168.10.10: icmp_seq=3 ttl=64 time=0.177 ms

--- 192.168.10.10 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.177/0.241/0.316/0.058 ms

 

4、在PC2和PC3客户机端测试PC1的apache服务(均无法连接)

 

 

 

 

5、在PC1服务器端清空防火墙策略,并使其生效

[root@PC1 ~]# iptables -F
[root@PC1 ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

 

6、在PC2和PC3客户机端测试PC1的apache服务(都可以访问)

 

 

 

 

7、在PC1服务器端修改apache服务网站的首页数据

[root@PC1 ~]# cd /var/www/html/
[root@PC1 html]# ls
[root@PC1 html]# echo "this is a test ! welcome to 192.168.10.10" > index.html
[root@PC1 html]# ls
index.html
[root@PC1 html]# cat index.html 
this is a test ! welcome to 192.168.10.10

 

8、 在PC2和PC3客户机端测试PC1主机的配置的首页数据效果(PC1的首页数据配置生效)

 

 

 

 以上实验实现了服务器端PC1配置Apache服务,PC2和PC3客户机端访问网站的效果(web服务)。

posted @ 2020-12-16 21:54  小鲨鱼2018  阅读(387)  评论(0编辑  收藏  举报