使用虚拟主机更新 httpd.conf

使用虚拟主机更新 httpd.conf

我有一个配置较旧的 Web 服务器(但最新的 2.4.6 版 apache)。基本上所有内容都在已有 20 年历史的 httpd.conf 文件中,但我有一些工具抱怨我需要定义虚拟主机。所以我想这意味着我必须将一些配置从 移到/etc/httpd/conf/httpd.conf并在其中/etc/httpd/conf.d/mysite.conf添加一些包装<VirtualHost *:80>。这可能不是很复杂,但我尝试了几次都没有成功。

当前配置很短(稍微简化并删除了注释):

ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>
DocumentRoot "/MySite/www/"
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
<Files ".ht*">
    Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    <IfModule logio_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>
<IfModule mime_module>
    TypesConfig /etc/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf

相关内容