我正在运行apache2。 我还跑了:
sudo a2enmod ssl
我无法使用https加载我的网站,但是使用常规http可以。 在Firefox中:
SSL_ERROR_RX_RECORD_TOO_LONG
在Chrome中:
ERR_SSL_PROTOCOL_ERROR
netstat -lp:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 *:ssh *:* LISTEN 168/sshd
tcp6 0 0 [::]:http [::]:* LISTEN 2021/apache2
tcp6 0 0 [::]:ssh [::]:* LISTEN 168/sshd
tcp6 0 0 [::]:https [::]:* LISTEN 2021/apache2
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 139167163 1/init /run/systemd/private
unix 2 [ ACC ] SEQPACKET LISTENING 139167175 1/init /run/udev/control
unix 2 [ ACC ] STREAM LISTENING 139167182 1/init /run/systemd/journal/stdout
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/example-dot-com/build
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect permanent / https://example.com/
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
/etc/apache2/sites-available/default-ssl.conf:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/example-dot-com/build
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /var/www/website_ssl_files/example.com.crt
SSLCertificateKeyFile /var/www/website_ssl_files/example.com.key
SSLCertificateChainFile /var/www/website_ssl_files/example.com-starfield.crt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
apachectl -S:
VirtualHost configuration:
*:80 server.example.com (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex watchdog-callback: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
netstat -lntp:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 168/sshd
tcp6 0 0 :::80 :::* LISTEN 2446/apache2
tcp6 0 0 :::22 :::* LISTEN 168/sshd
tcp6 0 0 :::443 :::* LISTEN 2446/apache2
tcp6 0 0 :::443 :::* LISTEN 2446/apache2
tcp6 0 0 :::443 :::* LISTEN 2446/apache2
我正在使用Ubuntu 16.04运行Linux VSP 服务器版本:Apache / 2.4.18(Ubuntu)
答案 0 :(得分:0)
我创建了以下文件/etc/apache2/sites-available/example.com.conf
:
<IfModule mod_ssl.c>
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /var/www/website_ssl_files/example.com.crt
SSLCertificateKeyFile /var/www/website_ssl_files/example.com.key
SSLCertificateChainFile /var/www/website_ssl_files/example.com-starfield.crt
ServerAdmin person@example.com
ServerName myserver.example.com
ServerAlias example.com
DocumentRoot /var/www/html/example-dot-com/build
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet