我想让一个在 apache2 (ubuntu) 上运行的应用程序在互联网上可用。所以我决定在购买 SSL 证书后设置虚拟主机。在我的本地网络上一切正常。
当我访问 172.16.2.28/moodle(在本地网络上)时,一切正常。
当我还访问 example.com 时,我会收到来自 (/var/www/html) 的默认 index.php
但是当我通过公共互联网访问 example.com/moodle 时,浏览器重定向到 172.16.2.28/moodle(错误 404)
我究竟做错了什么。
-
000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
默认-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin [email protected]
ServerName lms.xxx.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /home/vlms/sslcert/cert.pem
SSLCertificateKeyFile /home/vlms/sslcert/cert.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
<Directory /var/www/html/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
</IfModule>
moodle/config.php(问题可能来自这里吗?)
<?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype = 'mariadb';
$CFG->dblibrary = 'native';
$CFG->dbhost = '172.16.0.30';
$CFG->dbname = 'xxx';
$CFG->dbuser = 'xxx';
$CFG->dbpass = 'xxx';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbport' => '',
'dbsocket' => '',
'dbcollation' => 'utf8mb4_general_ci',
);
$CFG->wwwroot = 'http://172.16.0.30/moodle';
$CFG->dataroot = '/var/www/moodledata';
$CFG->admin = 'xxx';
$CFG->directorypermissions = 0777;
require_once(__DIR__ . '/lib/setup.php');
// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!