Would anyone guide on what AMPPS, MAMP or Moodle files should be changed to achieve this and how to do it?
thanks!
you might want to read/understand the following resource:
https://www.techtarget.com/searchnetworking/tip/Tips-for-setting-up-a-home-network
Assuming you don't want to wreck your upstream access to the internet
for your smart devices ... like your phone and any TCP/IP device you have
in your home right now ... like security cameras/printers etc.
You don't really need a DNS server.
one can map an IP address with a FQDN (fully qualified domain name).
In your case, I would imagine that IP range is 192.168.0 or 1.0-254.
For you moodle server, static IP address not in the range of DHCP server
IP addresses.
Example of /etc/hosts from a Mac:
cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
192.168.1.245 sandboxmdl.lan sandboxmdl
The last entry above ... note that it does NOT have .com, .net, .org or other
but a top level domain (.lan) which isn't routable and really shouldn't leak to
the upstream internet.
You do need to access your home router to see the range of IP addresses
it's DHCP server is currently doling out. For the computer that will be
your 'moodle server' needs a static TCP/IP setup and wired connection
so it can be accessed and not conflict with any other device you
might use on your home network.
The machine that will be your Moodle server .. is it a laptop or table top?
Best if it will remain at home ... all the time. And that it be networked
by wire plugged into your home router. Static private IP address.
For the machine running AMPP or MAMP, or whatever ...
set the networking to a static IP address ... check that it can still get
to the internet.
In AMPP/MAMP moodle the config.php file. Leave the port for 8080 or 81
whatever it's using ... port 80/443 used by browser for outside surfing.
In the moodle itself ... search and replace. Moodle has been using
the wwwroot variable in config.php for internal links. Those have
to be changed to match the static IP/Hostname.
So using my hostile example above:
config.php file would have http://sandboxmdl.lan
And search and replace would use that to replace whatever is in the DB.
Now if one expects to use smart phone/fablet or the moodle app or other device like that to access the home moodle, they might not work using sandboxmdl.lan in a hosts flie.
;sandboxmdl.lan. IN A
PING sandboxmdl.lan (192.168.1.245): 56 data bytes
I have lots of student assignments on my local, therefore want to be cautious changing anything, although I have taken a backup.
These are the changes I will make, just wish to confirm.
1. Assign static IP to my moodle MAC computer. (fyi - I currently access moodle with "http://localhost:8888/moodle403/")
2. Change entry in moodle config.php - I have added a copy of my current config.php in the end.
i.e., a. Change 'http://localhost:8888/moodle403'; to $CFG->wwwroot = 'http://[StaticIP]:8888/moodle403'
and b. $CFG->dbhost = 'localhost'; to. $CFG->dbhost = [StaticIP]:8888
I suppose I don't have to make changes to the '$CFG->dataroot'
3. MAMP interface has the ports as 8888 for all. So not changing.
4. Change host file on moodle server to include - [Static IP] moodle403. (see below)
---
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
[Static IP] moodle403
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 AcronisDriveSearchPlugin
-----
Did I miss anything, before I change the router entry of my moodle MAC to Static and check whether I can reach internet.
many thanks!
-----
my config.php file in MAMP <?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle403';
$CFG->dbuser = 'moodle';
$CFG->dbpass = 'moodle';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbport' => '',
'dbsocket' => '1',
'dbcollation' => 'utf8mb4_unicode_ci',
);
$CFG->wwwroot = 'http://localhost:8888/moodle403';
// $CFG->wwwroot = 'http://192.168.0.199:8888/moodle403';
$CFG->dataroot = '/Applications/MAMP/data/moodle403';
$CFG->admin = 'admin';
$CFG->directorypermissions = 0777;
require_once(dirname(__FILE__) . '/lib/setup.php');
Error
MAMP UI still says local host. or anything else I am missing?
this is my hosts file and php.config
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
10.0.0.106 moodle403
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost = '10.0.0.106:8888';
$CFG->dbname = 'moodle403';
$CFG->dbuser = 'moodle';
$CFG->dbpass = 'moodle';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbport' => '',
'dbsocket' => '1',
'dbcollation' => 'utf8mb4_unicode_ci',
);
$CFG->wwwroot = 'http://10.0.0.106:8888/moodle403';
// $CFG->wwwroot = 'http://192.168.0.199:8888/moodle403';
$CFG->dataroot = '/Applications/MAMP/data/moodle403';
$CFG->admin = 'admin';
$CFG->directorypermissions = 0777;
require_once(dirname(__FILE__) . '/lib/setup.php');

151.1.168.192.in-addr.arpa. 0 IN PTR Kens-MBP-2.lan
File: httpd.conf
Default is ServerName localhost:8888
to
ServerName moodle403.local:8888
I was able to connect with a fixed IP address from other Macs. summarizing the steps.
a. Installed the latest stable version from moodle4mac.
b. Assigned a fixed IP address to the Mac where moodle was installed in the router.
c. Modified and replaced the config.php entry for $CFG->wwwroot = 'http://[Fixed IP Address:8888]/moodle403';
d. sudo nano /etc/hosts and added an entry at the end - [Fixed IP Address] Moodle403
e. Went to other computers and repeated step d
f. logged into moodle with http://[Fixed IP Address:8888]/moodle403/admin/tool/replace/
g. find - http://localhost:8888/moodle403 and replace with http://[Fixed IP Address:8888]/moodle403/
h. once done start using http://[Fixed IP Address:8888]/moodle403/. to login from all your computers.
note: you may need to open firewall to allow httpd.