Apache目录结构说明

本文介绍了在Ubuntu 10.04系统中Apache 2.2.14的安装及配置详情,包括配置文件的位置与功能说明,如apache2.conf主配置文件、conf.d配置片段、magic文件等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

系统版本:Ubuntu 10.04(查看命令为cat /etc/issue或sudo lsb_release -a)

Apache当前版本: 2.2.14(用查看)

在Ubuntu下, 用命令sudo apt-get install apache2安装完成后,软件包提供的配置文件位于/etc/apache2目录下:

 

01
02
03
04
05
06
07
08
09
10
11
12
miao@ubuntu: /etc/apache2 $ ls -l
total 68
-rw-r--r-- 1 root root  8113 2010-04-14 04:20 apache2.conf
drwxr-xr-x 2 root root  4096 2010-06-02 01:08 conf.d
-rw-r--r-- 1 root root   725 2010-04-14 04:20 envvars
-rw-r--r-- 1 root root     0 2010-06-02 00:54 httpd.conf
-rw-r--r-- 1 root root 31063 2010-04-14 04:20 magic
drwxr-xr-x 2 root root  4096 2010-06-02 01:27 mods-available
drwxr-xr-x 2 root root  4096 2010-06-02 00:57 mods-enabled
-rw-r--r-- 1 root root   750 2010-04-14 04:20 ports.conf
drwxr-xr-x 2 root root  4096 2010-06-02 01:31 sites-available
drwxr-xr-x 2 root root  4096 2010-06-02 00:54 sites-enabled

 

apache2.conf

为apache2服务器的主配置文件, 查看此配置文件, 你会发现以下内容

 

01
02
03
04
05
06
07
08
09
10
11
12
13
# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
# Include all the user configurations:
Include /etc/apache2/httpd.conf
# Include ports listing
Include /etc/apache2/ports.conf
# Include generic snippets of statements
Include /etc/apache2/conf.d/[^.#]*
# Include generic snippets of statements
Include /etc/apache2/conf.d/
# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/

 

有此可见,apache2 根据配置功能的不同, 对配置文件进行了分割, 这样更利于管理

conf.d

为配置文件的附加片断,默认情况下, 仅提供了 charset 片断,

 

1
2
miao@ubuntu: /etc/apache2/conf .d$ cat charset
#AddDefaultCharset UTF-8

 

如有需要我们可以将默认编码修改为 GB2312, 即文件的内容为: AddDefaultCharset GB2312

httpd.conf

是个空文件

magic

文件中包含的是有关mod_mime_magic模块的数据, 一般不需要修改它.

 

01
02
03
04
05
06
07
08
09
10
11
12
13
14
# The format is 4-5 columns:
#    Column #1: byte number to begin checking from, ">" indicates continuation
#    Column #2: type of data to match
#    Column #3: contents of data to match
#    Column #4: MIME type of result
#    Column #5: MIME encoding of result (optional)
#-------------------------------------------------------
# Localstuff:  file(1) magic for locally observed files
# Add any locally observed files here.
# Real Audio (Magic .ra/0375)
0       belong          0x2e7261fd      audio/x-pn-realaudio
0       string          .RMF            application/vnd.rn-realmedia
0       string  MAS_UTrack_V00
>14     string  >/0             audio/x-mod

 

ports.conf

则为服务器监听IP和端口设置的配置文件,

 

1
2
3
miao@ubuntu: /etc/apache2 $ cat ports.conf
NameVirtualHost *:80
Listen 80

 

mods-available

目录下是一些.conf和.load 文件, 为系统中可以使用的加载各种模块的配置文件, 而mods-enabled目录下则是指向这些配置文件的符号连接, 从配置文件apache2.conf 中可以看出, 系统通过mods-enabled目录来加载模块, 也就是说, 系统仅通过在此目录下创建了符号连接的mods-available 目录下的配置文件来加载模块。同时系统还提供了两个命令 a2enmod 和 a2dismod用于维护这些符号连接。这两个命令由 apache2-common 包提供。命令各式也非常简单:a2enmod [module] 或 a2dismod [module]

sites-available

目录下为配置好的站点的配置文件, sites-enabled 目录下则是指向这些配置文件的符号连接,系统通过这些符号连接来起用站点 sites-enabled目录下的符号连接附有一个数字前缀, 如000-default, 这个数字用于决定启动顺序, 数字越小, 启动优先级越高. 系统提供了两个命令 a2ensite 和 a2dissite 用于维护这些符号连接。这两个命令由apache2-common 包提供.

/var/www

默认情况下将要发布的网页文件应该置于/var/www目录下,这一默认值可以同过主配置文件中的DocumnetRoot选项修改.


参考文献:

1、Apache HTTP Server Version 2.2 文档

2、Apache2 安装与配置

后记:据报道,现在很多站点都转向Nginx

趋势吧,俺是否也应该把握吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值