![Apache SSL 配置不生效](https://linux22.com/image/647175/Apache%20SSL%20%E9%85%8D%E7%BD%AE%E4%B8%8D%E7%94%9F%E6%95%88.png)
我在我的服务器上配置了一个通过 SSL 提供服务的站点,但是它根本不可用。
$ nmap localhost
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
80/tcp open http
我的防火墙允许端口 443 进入并且 apache2 服务正在运行。
似乎存在一个普遍的问题是,尽管包含在内apache2.conf
,但该文件/etc/apache2/sites-enabled/default-ssl.conf
并未被考虑在内。
$ apache2ctl -S
VirtualHost configuration:
1.23.45.67:80 is a NameVirtualHost
default server 12345.yourvserver.net (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost 12345.yourvserver.net (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost my.doma.in (/etc/apache2/sites-enabled/000-default.conf:31)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=99
Group: name="www-data" id=99
ports.conf 声明如下:
Listen 80
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_ssl.c>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
除注释行外,apache2.conf 如下所示:
ServerName localhost
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
Include ports.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>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
也有一个错误,但我无法按照最受欢迎的答案来解决它此主题(而且我不明白为什么环境变量应该与公共文件所在的目录有任何关系。)
$ apache2 -V
[Tue Dec 02 16:31:03.757529 2014] [core:warn] [pid 26148] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Tue Dec 02 16:31:03.757949 2014] [core:warn] [pid 26148] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Tue Dec 02 16:31:03.758019 2014] [core:warn] [pid 26148] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Tue Dec 02 16:31:03.758148 2014] [core:warn] [pid 26148] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Tue Dec 02 16:31:03.758305 2014] [core:warn] [pid 26148] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue Dec 02 16:31:03.769627 2014] [core:warn] [pid 26148] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue Dec 02 16:31:03.770168 2014] [core:warn] [pid 26148] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue Dec 02 16:31:03.770236 2014] [core:warn] [pid 26148] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue Dec 02 16:31:03.770376 2014] [core:warn] [pid 26148] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue Dec 02 16:31:03.770433 2014] [core:warn] [pid 26148] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
答案1
好吧,这有点令人尴尬。我忘了跑步了a2enmod ssl
。