简体   繁体   中英

Can't reach Moodle (a system written in PHP) from other devices

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 (ie 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.

Please go to XAMPP-Cotroll and open Apache->Config->httpd.conf and add

<IfModule mpm_winnt_module>
   ThreadStackSize 8888888
</IfModule>

to the end

Reference

If you want to be able to serve your pages to all ip addresses. You can remove this 2 lines.

Deny from all
Allow from localhost ::1 127.0.0.1

or if you want more security you can allow only a range of ip's

Order Allow,Deny
Deny from all
Allow from 127.0.0.1 ::1
Allow from localhost
Allow from 192.168

Being 192.168 the 2 first brackets of your network ip's

Reference: https://httpd.apache.org/docs/2.4/mod/mod_access_compat.html#allow

And remember to restart apache to apply the changes.

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!.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM