【发布时间】:2016-12-22 15:54:17
【问题描述】:
我正在尝试在 Ubuntu 上设置 Apache (2.4) 服务器。现在我只是想让它为来自/var/www/html 的静态页面提供服务(尽管最终我想运行一个 WSGI Python 应用程序)。
这是我的sites-available/website.conf 文件:
<VirtualHost *:443>
ServerAdmin email@gmail.com
ServerName website.com:443
SSLEngine on
SSLCertificateFile /root/website.csr
SSLCertificateKeyFile /root/website.key
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
(将我的实际域替换为“网站”。)
当我尝试通过访问我的域名或服务器的 IP 来连接到此站点时,Chrome 会给我ERR_CONNECTION_REFUSED(“无法访问此站点”)。
我也尝试过 telnet:
root@website:/etc/apache2# telnet localhost 443
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
当我从配置文件中注释掉所有与 SSL 相关的行时,我可以通过 telnet 进行连接,但 Chrome 给了我ERR_SSL_PROTOCOL_ERROR(“此站点无法提供安全连接”,我想这是有道理的)。
这也是我的ports.config,如果有帮助的话:
Listen 80
<IfModule ssl_module>
Listen 443
NameVirtualHost *:443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
(是的,SSL 模块已启用。)
还有我在类似问题中经常看到的apache2.conf 部分:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
这是我第一次设置 Apache 服务器,所以我猜我在这里搞砸了一些简单的事情?
【问题讨论】:
-
你能不能把
Listen 443改成Listen 443 https(虽然443端口应该默认是https)