ubuntu apache2配置

在Windows下,Apache的配置文件通常只有一个,就是httpd.conf。但在Ubuntu Linux上用apt-get install apache2命令安装了Apache2后,会发现它的httpd.conf(位于/etc/apache2目录)是空的!进而发现Ubuntu的 Apache软件包的配置文件并不像Windows的那样简单,它把各个设置项分在了不同的配置文件中,看起来复杂,但仔细想想设计得确实很合理。

严格地说,Ubuntu的Apache(或者应该说Linux下的Apache?我不清楚其他发行版的apache软件包)的配置文件是/etc /apache2/apache2.conf。即:/etc/apache2/apache2.conf 是主配置文件。

Apache在启动时会自动读取这个文件的配置信息。而其他的一些配置文件,如httpd.conf等,则 是通过Include指令包含进来。如在apache2.conf中可以找到这些Include行:

说明:

如果Include指向了一个目录而不是一个文件,Apache将读入目录及其子目录下的所有文件,并依照字母顺序将这些文件作为配置文件进行解析。

# 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 of directories ignores editors' and dpkg's backup files,

# see README.Debian for details.

# Include generic snippets of statements

Include /etc/apache2/conf.d/

# Include the virtual host configurations:

Include /etc/apache2/sites-enabled/

结合注释,可以很清楚地看出每个配置文件的大体作用。当然,你完全可以把所有的设置放在apache2.conf或者httpd.conf或者任何一个配置文件中。Apache2的这种划分只是一种比较好的习惯而已。

参考资料:

ubuntu apache2配置

http://wendell07.blog.hexun.com/25799017_d.html

Apache模块 core

http://oss.org.cn/man/newsoft/ApacheManual/mod/core.html

ubuntu apache2配置