已经五天了,我快要疯了。
我正在尝试在我创建的子域上安装 Let's Encrypt 证书,但无法使其正常工作。
以下是 sites-available 中的我的 .conf 文件:
test.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName test.com
ServerAlias www.test.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
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
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.test.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,NE,R=permanent]
</VirtualHost>
因此这个有效,并且我已经test-le-ssl.conf
在站点可用中创建了一个。
这是我的whydoesntitwork.test.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/whydoesntitwork
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/whydoesntitwork>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
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
</VirtualHost>
当我运行 ./letsencrypt-auto 或 add -d test.com -d whydoesntitwork.com 时,它会询问我是否要续订或尝试重新安装。我重新安装是因为我不想被锁定(他们说我们每周可以这样做约 5-7 次)。
当我尝试在 whydoesntitwork 上放置 SSL 时收到的错误是:
The selected vhost would conflict with other HTTPS VirtualHosts within Apache. Please select another vhost or add ServerNames to your configuration.
VirtualHost not able to be selected.
我已经添加了两个域,/etc/apache2/hosts
如下所示:
127.0.0.1 localhost.localdomain localhost
(myip) test.com test
(myip) whydoesntitwork.test.com whydoesntitwork
我究竟做错了什么 ?
编辑:添加了 apache 的版本
Server version: Apache/2.2.22 (Debian)
Server built: Sep 21 2017 20:51:54
谢谢
答案1
在 Apache 2.2 上,您需要设置 NameVirtualHost
NameVirtualHost *:80
此外,您似乎在第二个配置中缺少 ServerName 指令。
最后,您是否启用了 sites-available 中的配置?