在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的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

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示