http和https的Apache虚拟服务器设置

我知道这已经被问了几次之前,但即使阅读了几次,我仍然不能“得到它”的答案。

我有一台运行Apache2的服务器,我希望能够从它服务两个网站:gitorious.myserver.com和redmine.myserver.com。 Gardious需要http和https(Redmine对于http很满意)。

我完全不知道该把什么放在哪里。 我试过编辑conf.d / redmine.conf,conf.d / gitorious.conf,httpd.conf,sites-available / gitorious和sites-available / gitorious-ssl,我不得不承认这一切都相当混乱。 我设法得到一些东西工作(例如http,但不是https),但不是在同一时间的一切。 我无法弄清楚这些文件之间的区别。

我需要做一些特别的东西,我想要在www.myserver.com sub-uri( http://www.myserver.com/phpmyadmin或https://www.myserver.com/someservice for实例)? 或者只是为这个地址创build一个虚拟服务器,就像其他人一样(这是我的理解)。

http.conf的:

NameVirtualHost *:80 NameVirtualHost *:443 <VirtualHost 192.16.160.65:443> ServerAdmin poutmar@localhost DocumentRoot /var/www/gitorious/public <Directory /var/www/gitorious/public> Allow from all Options -MultiViews FollowSymLinks </Directory> SSLEngine on SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key </VirtualHost> <VirtualHost *:80> ServerName gitorious.myserver.com DocumentRoot /var/www/gitorious/public <Directory /var/www/gitorious/public> Allow from all Options FollowSymLinks </Directory> </VirtualHost> <VirtualHost *:80> ServerName redmine.myserver.com DocumentRoot /var/www/redmine/public <Directory /var/www/redmine/public> Allow from all Options -MultiViews FollowSymLinks </Directory> </VirtualHost> <VirtualHost *:80> ServerName www.myserver.com DocumentRoot /var/www <Directory /var/www/> Allow from all Options FollowSymLinks </Directory> </VirtualHost> <VirtualHost *:443> ServerName www.myserver.com DocumentRoot /var/www <Directory /var/www> Allow from all Options FollowSymLinks </Directory> SSLEngine on SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key </VirtualHost> 

ports.conf:

 Listen 80 <IfModule mod_ssl.c> # If you add NameVirtualHost *:443 here, you will also have to change # the VirtualHost statement in /etc/apache2/sites-available/default-ssl # to <VirtualHost *:443> # Server Name Indication for SSL named virtual hosts is currently not # supported by MSIE on Windows XP. Listen 443 </IfModule> <IfModule mod_gnutls.c> Listen 443 </IfModule> 

我不明白在ports.conf中的评论。

对于你所描述的设置你需要:

  • 基于IP的虚拟主机在*:443gitorious.example.com与SSL / TLS支持
  • gitorious.example.com:上的*:80 的基于名称的VirtualHost gitorious.example.com:
  • 对于redmine.example.com*:80的基于名称的VirtualHost
  • example.comwww.example.com (或者只是*.example.com )上*:80的基于名称的VirtualHost。

对于其他Web应用程序(如提到的phpMyAdmin),您可以在www.example.com上使用Alias es。