doushan2811 2019-03-05 20:31
浏览 105
已采纳

无法从其他设备访问Moodle(用PHP编写的系统)

First time to install Moodle and am installing it locally on Windows 10 using WAMP. My knowledge in Apache and servers in general is very limited. Installation completed successfully and every thing is working fine on my localhost but when i try to access it from other devices (i.e another laptop using chrome) i will be redirected to "http://localhost/moodle" and get the message "This Site can't be reached" although i can access "MyphpAdmen" page after i altered its alias file. I know bet of coding, so i created an alias file for Moodle copying the same code from Myphpadmin's alias file with some changes to look like this

Alias /moodle "C:/wamp64/www/moodle/"

<Directory "C:/wamp64/www/moodle/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride all
<ifDefine APACHE24>
    Require all granted
 </ifDefine>
 <ifDefine !APACHE24>
    Order Deny,Allow
 Deny from all
 Allow from localhost ::1 127.0.0.1
 </ifDefine>

  # To import big file you can increase values
  php_admin_value upload_max_filesize 128M
  php_admin_value post_max_size 128M
  php_admin_value max_execution_time 360
  php_admin_value max_input_time 360
  </Directory>

and it didn't work,any help will be appreciated.

  • 写回答

2条回答 默认 最新

  • duanpei8853 2019-03-06 18:45
    关注

    It wasn't a permission issue after all. I noticed that when i type the address of the Moodle server (http://1.1.1.1/moodle) from other devices ,i will be redirected to "http://localhost/moodle", and to resolve this i just had to edit a line in Moodle's config.php file like this:

    $CFG->wwwroot = 'http://localhost/moodle' ;
    

    to this

    $CFG->wwwroot = 'http://1.1.1.1/moodle';
    

    Change 1.1.1.1 to your server's Ip

    the source of this solution :Moodle in English

    Little Tweaking : You might use your server on different stations with different Ip's Range,In that case you will have to update your Config file every time you change your server ip,so i made this little code to automate the updating :

    $host= gethostname();
    $MyIp= gethostbyname($host);
    $CFG->wwwroot = 'http://'.$MyIp.'/moodle';
    

    hope it helps.Thanks!.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。