关于Apache2的配置文件

来源:互联网 发布:阿里云 ace 编辑:程序博客网 时间:2024/06/06 17:25
Ubuntu的Apache的配置文件是/etc/apache2/apache2.conf,Apache在启动时会自动读取这个文件的配置信息。
而其他的一些配置文件,如httpd.conf等,则是通过Include指令包含进来。在apache2.conf中可以找到这些Include行:
# Include module configuration:Include mods-enabled/*.loadInclude mods-enabled/*.conf# Include list of ports to listen on and which to use for name based vhostsInclude ports.conf# Include generic snippets of statementsInclude conf.d/# Include the virtual host configurations:Include sites-enabled/
结合注释,可以很清楚地看出每个配置文件的大体作用。当然,你完全可以把所有的设置放在apache2.conf或者httpd.conf或者任何一个配置文件中。Apache2的这种划分只是一种比较好的习惯。安装完Apache后的最重要的一件事就是要知道Web文档根目录在什么地方。对于Ubuntu而言,默认的是/var/www。
怎么知道的呢?apache2.conf里并没有DocumentRoot项,httpd.conf又是空的,因此肯定在其他的文件中。
经过搜索,发现在/etc/apache2/sites-enabled/000-default中,里面有这样的内容:
<VirtualHost *:80>        ServerAdmin webmaster@localhost        DocumentRoot /var/www        <Directory />                Options FollowSymLinks                AllowOverride None        </Directory>        <Directory /var/www/>                Options Indexes FollowSymLinks MultiViews                AllowOverride None                Order allow,deny                allow from all        </Directory>        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/        <Directory "/usr/lib/cgi-bin">                AllowOverride None                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch                Order allow,deny                Allow from all        </Directory>        ErrorLog ${APACHE_LOG_DIR}/error.log        # Possible values include: debug, info, notice, warn, error, crit,        # alert, emerg.        LogLevel warn        CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>
http://www.cherrot.com/2011/11/apache-server-fully-qualified-domain-name

原创粉丝点击