Skip to content
Advertisement

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

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement