【问题标题】:Apache URL MappingApache URL 映射
【发布时间】:2013-09-19 13:55:24
【问题描述】:

我已经为 ssl 设置了 apache。 我可以浏览https://localhost

我想将https://localhosz 更改为https://www.test.com 或其他任何内容

我的 httpd-ssl.conf:

SSLSessionCache "shmcb:C:/wamp/bin/apache/apache2.4.2/logsssl_scache(512000)"
SSLEngine on  
DocumentRoot "C:/wamp/www/TeamPass" 
ServerName localhos:443 
ErrorLog "C:/wamp/logs/mysecuresite_error_log" 
TransferLog "C:/wamp/logs/mysecuresite_access_log"
SSLCertificateFile "C:/wamp/OpenSSL/certs/webserver.cer" 
SSLCertificateKeyFile "C:/wamp/OpenSSL/certs/private.key"  

CustomLog "C:/wamp/logs/ssl_request_log" \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

我必须如何更改我的配置文件才能启动 apache,因为我尝试使用 virtualhost 进行一些配置,但在进行更改后 wamp 不会启动。 这是一个测试服务器,所以我没有 DNS 服务器,但我编辑了我的主机文件。

我需要 C:/wamp/www/TeamPass 来收听 test.com:443,我可以将服务器名称更改为此 url,但我不确定这是否正确。 我需要做什么才能使用 url https://pass.test.de,我需要使用重写模块吗

【问题讨论】:

  • 将您的主机名更改为 www.test.com 并将虚拟主机中的 localhost 更改为相同
  • 将 ServerName localhos:443 更改为 ServerName pass.test.de:443 也可以。文档根链接到我的站点。但是此配置不适用于多站点,因为所有其他站点都将在 pass.test.de/phpmyadmin 下运行,例如

标签: apache ssl https


【解决方案1】:

对于 MS Windows,您可以修改位于 Apache 安装路径内的文件夹 conf/extra/ 上的文件 httpd-vhosts.conf,以包含下一个配置:

Listen 443
NameVirtualHost 127.0.0.1:443
<VirtualHost 127.0.0.1:443>
  ServerName www.test.com
  DocumentRoot "C:\wamp\www\TeamPass"
  <Directory "C:\wamp\www\TeamPass">
    AllowOverride All
    Allow from All
  </Directory>
  ErrorLog "C:\wamp\logs\mysecuresite_error_log"
  CustomLog "C:\wamp\logs\ssl_request_log" \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
  SSLEngine on
  SSLCertificateFile "C:\wamp\OpenSSL\certs\webserver.cer" 
  SSLCertificateKeyFile "C:\wamp\OpenSSL\certs\private.key" 
</VirtualHost>

然后,在文件C:\WINDOWS\system32\drivers\etc\hosts最后添加这一行:

127.0.0.1   www.test.com

【讨论】:

  • 所以我还需要将我的配置保存在 httpd-ssl.conf 中吗?并激活在 http.conf 中包含 httpd-vhosts.conf?
  • 我猜不是,但我不完全确定。
  • 另外,请检查 conf\httpd.conf 中是否取消注释此行:Include conf/extra/httpd-vhosts.conf
  • 是的,这就是我所说的激活在 http.conf 中包含 httpd-vhosts.conf 的意思?但是当我激活这个模块 wamp 时不会启动,因为 httpd-vhosts 中的配置有问题。我还看到了 httpd-ssl.config,它保存在 ssl.config 文件中。我仍然可以通过更改我的第一个配置中的默认虚拟主机来更改 url。所以这是第一步:)
  • 尝试注释 httpd-vhosts.conf 中的所有内容,并添加新配置。
【解决方案2】:

将您的主机名更改为 www.test.com

edit or run the file hostname and the file hosts

sudo gksu gedit /etc/hostname  and add www.test.com

sudo gksu gedit /etc/hosts and add the line 127.0.0.1 www.test.com localhost 

in the virtualhoste use www.test.com instead of localhost.

【讨论】:

  • 抱歉没有提到这是windows系统
  • 好吧,我用的是ubuntu,看看如何修改windows hosts文件。
猜你喜欢
  • 2015-05-22
  • 2012-08-11
  • 1970-01-01
  • 2016-04-21
  • 1970-01-01
  • 2017-03-01
  • 2018-07-21
  • 2012-01-20
  • 2017-09-21
相关资源
最近更新 更多