需要有关 apache2 httpd.conf 的帮助

需要有关 apache2 httpd.conf 的帮助

好的,问题呈现如下:

  • 我有一个 IP(123.123.123.123)
  • 我有多个域名
  • 我使用子域名进行测试

因此,基本上我需要托管 www.example.com、wwww.example2.com 以及几个开发用户 user1.example.com 和 user2.example2.com 的子域。除此之外,www.example.com 还需要使用端口 443。

我看到了很多建议,但似乎都不起作用。也许我只需要在这里填写一些真正有用的空白?

Listen ???
NameVirtualHost ???
<VirtualHost ???>
    DocumentRoot /home/user1/example.com
    ServerName user1.example.com
    ErrorLog logs/user1.example.com-error_log
    CustomLog logs/user1.example.com-access_log common from all
    <Directory "/home/user1/example.com/public">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost ???>
    DocumentRoot /home/user2/example.com
    ServerName user2.example.com
    ErrorLog logs/user2.example.com-error_log
    CustomLog logs/user2.example.com-access_log common from all
    <Directory "/home/user2/example.com/public">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost ???>
    DocumentRoot /home/www/example.com
    ServerName www.example.com
    ErrorLog logs/www.example.com-error_log
    CustomLog logs/www.example.com-access_log common from all
    <Directory "/home/www/example.com/public">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

# Entry for 443
<VirtualHost 67.23.39.254:443>
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
    SSLCertificateFile /etc/httpd/conf/ssl/example/www.example.com.crt
    SSLCertificateKeyFile /etc/httpd/conf/ssl/example/example.key
    SSLCertificateChainFile /etc/httpd/conf/ssl/example/gd_bundle.crt
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    DocumentRoot /home/www/example.com
    ServerName www.example.com
</VirtualHost>

然后对于 example2.com 也是同样的事情。Example2.com 可能使用与 example.com 不同的 SSL 证书,我知道这可能需要第二个 IP 地址,但也许有人可以提出建议。

答案1

可能最简单的方法是将其用作*虚拟主机的 IP,例如:

Listen 80
Listen 443
NameVirtualHost *:80

<VirtualHost *:80>
  ServerName user1.example.com
  # config for user1.example.com here as in your config...
</VirtualHost>
# repeat lines above as many times as you need

# For SSL:
<VirtualHost 123.123.123.123:443>
....
</VirtualHost>

相关内容