Linux - apache服务配置及应用(浏览器界面操作目录结构,读取及下载文件)

     像这样的浏览器文件结构目录,一定见过不少,像许多镜像或者安装包的下载地址,都是用这种方式来下载的,到底是怎么做的呢?

    Apache服务因其开源、跨平台应用、支持多种网页编程语言、模块化设计 、运行稳定、良好的安全性等优点,被广泛应用于承载Web服务,而其与Linux、PHP、MySQL等组件相结合后,更能充分发挥出其独具特色的优点,是小型网站搭建的较优选择。

    一般来说,Linux服务器都自带这个服务;

    命令   rpm  -qa|grep  httpd  ,查看系统中已安装的所有apache软件包列表

[root@ip-xxxx ec2-user]# rpm  -qa|grep  httpd
httpd-tools-2.4.41-1.amzn2.0.1.x86_64
httpd-2.4.41-1.amzn2.0.1.x86_64
httpd-filesystem-2.4.41-1.amzn2.0.1.noarch
generic-logos-httpd-18.0.0-4.amzn2.noarch

 

 

 

 

 

 

    如果没有什么特殊的要求,只是简单的启一个apache的服务的话,这些软件包也不用卸载,直接将httpd服务拉起来就行;

     命令   service httpd status  ,查看系统中httpd服务是否已经启动;

[root@ip-xxxx ec2-user]# service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd.service(8)
[root@ip-xxxx ec2-user]# service httpd start
Redirecting to /bin/systemctl start httpd.service
 

 

 

 

 

 

 

 

     命令   service httpd start,启动系统中httpd服务;

[root@ip-xxxx ec2-user]# service httpd start
Redirecting to /bin/systemctl start httpd.service
[root@ip-xxxx ec2-user]# service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-11-26 10:37:06 CST; 2s ago
     Docs: man:httpd.service(8)
 Main PID: 10864 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─10864 /usr/sbin/httpd -DFOREGROUND
           ├─10866 /usr/sbin/httpd -DFOREGROUND
           ├─10867 /usr/sbin/httpd -DFOREGROUND
           ├─10868 /usr/sbin/httpd -DFOREGROUND
           ├─10869 /usr/sbin/httpd -DFOREGROUND
           └─10871 /usr/sbin/httpd -DFOREGROUND

Nov 26 10:37:06 ip-xxxx.cn-north-1.compute.internal systemd[1]: Starting The Apache HTTP Server...
Nov 26 10:37:06 ip-xxxx.cn-north-1.compute.internal httpd[10864]: AH00558: httpd: Could not reliably determine the server's fully quali...ssage
Nov 26 10:37:06 ip-xxxx.cn-north-1.compute.internal systemd[1]: Started The Apache HTTP Server.
 

 

 

 

 

 

 

 

 

 

 

 

 

    命令 ps / netstat ,查看apache服务的启动情况;

[root@ip-xxxx conf]# ps -ef|grep apache
apache   10866 10864  0 10:37 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   10867 10864  0 10:37 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   10868 10864  0 10:37 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   10869 10864  0 10:37 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   10871 10864  0 10:37 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
root     11125 10088  0 10:38 pts/2    00:00:00 grep --color=auto apache
[root@ip-xxxx conf]# netstat -anop|grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      10864/httpd          off (0.00/0/0)
 

 

 

 

 

 

 

 

    apache服务默认启动在80 端口上,我们可以在它的配置文件中修改它的监听端口;配置文件位置: /etc/httpd/conf/httpd.conf

    这时候就可以在浏览器上输入:http://<ip>:80 ,然后 回车,就可以看到以下界面。这时候还没有配置具体的文件目录,所以是一个TEST PAGE。。。。

    

    /var/www/html:首页文件存放的目录(/etc/httpd/conf/httpd.conf中默认的目录 DocumentRoot=/var/www/html)

    /var/www/error:错误信息处理的文件(主机设置错误或者浏览器客户端要求的数据错误,浏览器上显示的错误信息)

    /var/www/icons:存放(apache、tomcat)网页的图片

 

    在/var/www/html 目录下,创建你需要的文件夹,以及文件,就可以在浏览器上进行访问,读取,以及下载了,很nice呀!!!

    还有更多的使用技巧,可以参考这里哟~ Linux Apache服务介绍及搭建_vic的博客-CSDN博客

posted @ 2022-01-27 18:35  zhangdaopin  阅读(473)  评论(0编辑  收藏  举报