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 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献