LAN 连接到 wamp 主页,而不是 www 中的项目
LAN connecting to wamp homepage, not projects in www
我尝试设置 wamp 来托管我的项目,并希望它们在我的 LAN 中可见。我已经安装了最新版本的 wamp64 并且在 www 文件夹中是 运行 moodle。在 pc 上它是 运行 我可以连接到主 wamp 页面和 moodle 项目。
不幸的是,在连接到同一网络的笔记本电脑上,我无法连接到 moodle 项目。虽然我 可以 连接到 wamp main page/homepage。我已将 httpd-vhost.conf 文件更改为以下内容:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
我假设这允许笔记本电脑连接到 wamp 页面但还不能连接到 moodle page/folder。虽然我不知道如何让笔记本电脑访问。
我是否需要为 moodle 项目添加另一个虚拟主机?
我现在有点不知所措。
moodle 有一个配置文件,也可能会弄乱它。这是文件:
<?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype = 'mariadb';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'xxxx';
$CFG->dbpass = 'xxxx';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbport' => '',
'dbsocket' => '',
'dbcollation' => 'utf8mb4_unicode_ci',
);
$CFG->wwwroot = 'http://localhost/moodle';
$CFG->dataroot = 'C:\wamp64\moodledata';
$CFG->admin = 'admin';
$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!
非常感谢任何帮助。
提前致谢,
您的问题是您只为 localhost
请求设置了目录。
您可以将 ServerAlias
更改为您的 LAN ip 或您从浏览器请求的地址
例如:
<VirtualHost *:80>
ServerName localhost
ServerAlias 192.168.1.3
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
它的作用是说,如果 apache 收到对 192.168.1.3
或任何 ServerAlias
条目的请求,它将以与 localhost
相同的方式对待它请求。
我尝试设置 wamp 来托管我的项目,并希望它们在我的 LAN 中可见。我已经安装了最新版本的 wamp64 并且在 www 文件夹中是 运行 moodle。在 pc 上它是 运行 我可以连接到主 wamp 页面和 moodle 项目。
不幸的是,在连接到同一网络的笔记本电脑上,我无法连接到 moodle 项目。虽然我 可以 连接到 wamp main page/homepage。我已将 httpd-vhost.conf 文件更改为以下内容:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
我假设这允许笔记本电脑连接到 wamp 页面但还不能连接到 moodle page/folder。虽然我不知道如何让笔记本电脑访问。
我是否需要为 moodle 项目添加另一个虚拟主机? 我现在有点不知所措。
moodle 有一个配置文件,也可能会弄乱它。这是文件:
<?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype = 'mariadb';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'xxxx';
$CFG->dbpass = 'xxxx';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbport' => '',
'dbsocket' => '',
'dbcollation' => 'utf8mb4_unicode_ci',
);
$CFG->wwwroot = 'http://localhost/moodle';
$CFG->dataroot = 'C:\wamp64\moodledata';
$CFG->admin = 'admin';
$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!
非常感谢任何帮助。
提前致谢,
您的问题是您只为 localhost
请求设置了目录。
您可以将 ServerAlias
更改为您的 LAN ip 或您从浏览器请求的地址
例如:
<VirtualHost *:80>
ServerName localhost
ServerAlias 192.168.1.3
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
它的作用是说,如果 apache 收到对 192.168.1.3
或任何 ServerAlias
条目的请求,它将以与 localhost
相同的方式对待它请求。