设置 apache 以查看 https 页面

设置 apache 以查看 https 页面

我正在尝试使用 vmware 工作站、ubuntu 11.10 和 apache2 设置网站。该网站运行正常,但现在 https 页面未显示。例如,如果我尝试访问https://www.mysite.com/checkout我刚刚看到消息

未找到 该服务器上未找到请求的 URL /checkout/。

我真的不知道自己在做什么,并且尝试了很多方法来获得正确的 SSL 证书。

我那里有一些东西,我httpd.conf只有:

ServerName localhost

在我的ports.conf我有:

NameVirtualHost *:80
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 http
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443 http
</IfModule>

在 /etc/apache2/sites-available/default-ssl 中:

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
        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>

     .... truncated

在 sites-available/default 中我有:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        #DocumentRoot /home/magento/site/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
        #<Directory /home/magento/site/>
                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

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>
<virtualhost *:443>
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/server.crt
        SSLCertificateKeyFile /etc/apache2/ssl/server.key
        ServerAdmin webmaster@localhost
  <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
        #<Directory /home/magento/site/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all


        </Directory>

</virtualhost>

我还在 sites-availabe 中为我的网站网址 www.mysite.com 设置了一个文件,因此在 /etc/apache2/sites-available/mysite.com

<VirtualHost *:80>
        ServerName mysite.com
        DocumentRoot /home/magento/mysite.com

        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /home/magento/mysite.com/ >
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /home/magento/logs/apache.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
</VirtualHost>
<VirtualHost *:443>
        ServerName mysite.com
   DocumentRoot /home/magento/mysite.com

        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /home/magento/mysite.com/ >
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /home/magento/logs/apache.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
</VirtualHost>

感谢您提供的帮助!从这篇文章中可能可以看出,我现在很迷茫。

答案1

您可以尝试以下几件事:

  1. 由于您使用的<VirtualHost *:443>/etc/apache2/sites-available/mysite.com,因此将两个实例都替换Listen 443 http

    NameVirtualHost *:443
    Listen 443
    

    在你的ports.conf

  2. 据我所知,您并没有使用默认配置来实际为网站提供服务。

    如果我是对的,请禁用它们:

    a2dissite default default-ssl
    

    在这种情况下,您还应该删除以下行

    ServerName localhost
    

    从你的httpd.conf

  3. 确保您的最新配置和 SSL 已启用。

    a2ensite mysite.com
    a2enmod ssl
    
  4. 进行任何更改后,请记住重新加载 apache 以激活新配置:

    service apache2 reload
    

答案2

以下部分似乎不正确

这是 443 上的 SSL 连接的虚拟主机,

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
        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>

您收到错误是由于不适当的

DocumentRoot /var/www

将其更改为与

<VirtualHost *:443>

相关内容