尝试在Ubuntu 14.04上使用Apache设置SSL

我已经从namecheap.com购买了SSL证书。 我正试图在运行Ubuntu 14.04和Apache的服务器上安装它。 我使用以下教程来设置Apache https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts 。 服务器具有仅在HTTP上运行的预先存在的站点。

该网站使用两个子域名admin.example.com和api.example.com,所以我购买了通配符证书。

我已经根据证书颁发机构安装了证书,并修改了Apache config example.com.conf来添加SSL虚拟主机,我仍然希望非HTTPS页面能够正常工作,所以我离开了现有的80端口configuration,并添加了新的虚拟主机主机configuration如下。

我重新启动Apache并尝试通过https查看页面,但从Firefox获取以下错误代码(Error code: ssl_error_rx_record_too_long)

我已经尝试了这个post中提到的修复,但没有成功https://www.digicert.com/ssl-support/apache-fix-common-ssl-errors.htm#SSLRecordLength

我也检查了防火墙已经打开了端口443。

Apacheconfiguration

 <VirtualHost *:80> ServerAdmin [email protected] ServerName example.com ServerAlias www.example.com api.example.com admin.example.com DocumentRoot /var/www/example.com/public/ <Directory "/var/www/example.com/public/"> Options Indexes FollowSymLinks AllowOverride None Order deny,allow Allow from all Satisfy all IndexIgnore */* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php RewriteRule . index.php </Directory> # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn #ErrorLog "/var/www/example.com/protected/runtime/apache-error.log" #CustomLog "/var/www/example.com/protected/runtime/access.log" common </VirtualHost> <VirtualHost *:433> #SSL certificate SSLEngine On SSLCertificateFile /etc/apache2/ssl/STAR.example.com.crt SSLCertificateKeyFile /etc/apache2/ssl/*.example.com.key SSLCACertificateFile /etc/apache2/ssl/STAR.example.com.ca-bundle.crt ServerAdmin [email protected] ServerName example.com ServerAlias www.example.com api.example.com admin.example.com DocumentRoot /var/www/example.com/public/ <Directory "/var/www/example.com/public/"> Options Indexes FollowSymLinks AllowOverride None Order deny,allow Allow from all Satisfy all IndexIgnore */* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php RewriteRule . index.php </Directory> # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn ErrorLog "/var/www/example.com/protected/runtime/apache-error.log" CustomLog "/var/www/example.com/protected/runtime/access.log" combined </VirtualHost> 

Apache细节

 $ apache2 -v Server version: Apache/2.4.7 (Ubuntu) Server built: Jul 22 2014 14:36:38 

那么这是你的问题:

 <VirtualHost *:433> 

改成443。