我正在尝试在Debian上设置对Apache 2的ssl支持。 版本是:
Debian GNU/Linux 6.0 apache2 2.2.16-6+squeeze1
我跟随了很多日子,但我无法做到这一点。 这里是我的步骤和configuration文件(ServerName和DocumentRoot被改变为隐私,以防告诉我):
# mkdir /etc/apache2/ssl # openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.pem
在这一点上,我对apache.pem的权限有疑问,在这一步他们是
-rw-r--r-- 1 root root
也许它必须属于万维网数据? 然后我启用ssl-mod
# a2enmod ssl # /etc/init.d/apache2 restart
我以这种方式修改/ etc / apache2 / sites-available / default-ssl(我把端口8080,因为我需要端口443用于另一个目的):
<VirtualHost *:8080> SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.pem SSLCertificateKeyFile /etc/apache2/ssl/apache.pem ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options Indexes 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 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 *:8080> DocumentRoot /home/user1/public_html/ ServerName first.server.org # Other directives here </VirtualHost> <VirtualHost *:8080> DocumentRoot /home/user2/public_html/ ServerName second.server.org # Other directives here </VirtualHost>
我必须指出,相同的configuration在http上工作(这是/ etc / apache2 / sites-available / default的副本,有一些不同 – > port和ssl支持)。 我的/etc/apache2/ports.conf如下:
# If you just change the port or add more ports here, you will likely also # have to change the VirtualHost statement in # /etc/apache2/sites-enabled/000-default # This is also true if you have upgraded from before 2.2.9-3 (ie from # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and # README.Debian.gz #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. #NameVirtualHost *:8080 Listen 8080 </IfModule> <IfModule mod_gnutls.c> Listen 8080 </IfModule>
任何build议?
根据你的configuration你有几个虚拟主机在同一个端口上,你想使用SSL – 显然只有其中一个configuration为SSL。
删除所有其他虚拟主机定义或更改其端口或IP地址并再次testing。
你在这个地方有一个可能的错误configuration:
SSLCertificateFile /etc/apache2/ssl/apache.pem SSLCertificateKeyFile /etc/apache2/ssl/apache.pem
您的证书文件和密钥应该是单独的文件。
我不知道该如何去做。 但是为了让你的东西工作,你也可能需要按照我的指导使用Java Keytool来创build密钥库,然后将密钥从密钥库中导出以便与Apache一起使用。 用这种方法,我知道它的作品。
按照我的指导,你将有:
SSLCertificateFile /etc/apache2/ssl/exported-pem.crt SSLCertificateKeyFile /etc/apache2/ssl/exported-pem.key
我不确定,但我读了你的步骤,我注意到以下几点:
- 您跳过CSR步骤,然后也跳过签署证书请求
- 你没有从私钥中删除密码(但是这只在Windows平台上是必需的;在这种情况下,Apache需要知道密码才能读取密钥,而我没有看到你在哪里做的)
- 至于sslconfiguration去,即时通讯我的经验,默认的SSLconfiguration文件应该工作,只要你在你的http.conf文件中启用其指令。