MAMP Virtual Hosting Primer Tutorial

MAMP Virtual Hosting Primer Tutorial

MAMP Virtual Hosting Primer Tutorial

Yesterday we talked about a Linux idea for backup on a MacBook Pro laptop with our Linux Backup via rsync Primer Tutorial as shown below.

Today we are going to talk about virtual hosting on a MAMP Apache local web hosting arrangement.

These two ideas are linked. Go figure …

Did you come up with 42? Never mind ….

The work from yesterday with the Linux rsync command opens the door to a new separated disk/device “area” of use on a MacBook Pro using a Mac OS X operating system. We should not waste this opportunity to now, perhaps, be offering you some new ideas, purrrrhaps, regarding Virtual Hosting with Apache, a fairly big subject we try to encapsulate in a single image we’d like you to examine on a practical viewpoint for how to ease your way into Virtual Hosting, which is an area of knowledge you should follow up more, meowhaps, with pointers from today’s work … which is …

  1. change Apache’s httpd.conf configuration file to add new configuration data, if never put in beforehand, for Virtual Hosting … our example being the addition of …

    NameVirtualHost *
    <VirtualHost *>
    DocumentRoot "/Applications/MAMP/htdocs"
    ServerName localhost
    </VirtualHost>

    <VirtualHost *>
    DocumentRoot "/Volumes/Laura/MAMP/htdocs"
    ServerName seagate.backup
    Alias /seagate.backup "/Volumes/Laura/MAMP/htdocs"
    <Directory "/Volumes/Laura/MAMP/htdocs">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
    </VirtualHost>

    … the ideas for which we got great help from this WordPress forum link … thanks heaps
  2. change hosts file in /private/etc to have the new “seagate.backup” domain be recognized by adding the record …

    127.0.0.1 seagate.backup

    … at the end of the hosts file
  3. rebooted (or restarted) the MacBook Pro (to flush the DNS)
  4. started up MAMP local Apache web server again
  5. in Firefox (web browser) typed in address bar URL of …
    HTTP://seagate.backup:8888/word_association.php
    … which is the execution of some PHP (associated with Language Word Association Game Tutorial) that would not have worked as of yesterday (and which we did try, unsuccessfully, yesterday … but did, try, with success, today)
  6. in Safari (web browser) typed in address bar URL of …
    http://localhost:8888/word_association.php
    … which is the execution of some PHP to sanity check that what we have done has not harmed anything pre-existing … and so it came to pass

The Virtual Hosting has meant that the one MAMP install can be configured to have several DocumentRoot definitions as per, for our local MacBook Pro setup here, two of which are …

DocumentRoot URL DocumentRoot Path
http://localhost:8888/ /Applications/MAMP/htdocs/
HTTP://seagate.backup:8888/ /Volumes/Laura/MAMP/htdocs/

… with that last one being a backup of the first, created on a Seagate Backup Plus Portable Drive.

If this whole big topic of web servers interests you, you might also want to have a read of our Cassini++ WebServer Primer Tutorial.


Previous relevant Linux Backup via rsync Primer Tutorial is shown below.

Linux Backup via rsync Primer Tutorial

Linux Backup via rsync Primer Tutorial

On a Macbook Pro laptop you can use the Mac OS X Time Machine approach to backing up your data, as we talked about with Mac Backup Tutorial. However, a Mac OS X laptop has access to an underlying Linux operating system, that has had great software, including backup software, written for it over many years.

What would be the advantages of using a Linux method of backing up on a Macbook Pro laptop? Can think of …

  • Linux processes are not in your face … while you get on with other things in the usual GUI environment
  • able to be run at a time of your choosing (via shell scripting with crontab, or at login via a .profile arrangement, perhaps), even interactively … though Time Machine can do some of this too
  • the backup can run in the background … though Time Machine can do this too
  • the backup process could easily leave you a log
  • Linux backups are capable of handling remote backup tasks and scenarios

Today’s slideshow presentation starts off with a photo of our …

  1. … Seagate Backup Plus Portable Drive hooked up to our Macbook Pro via a black USB lead plugged into one of the Macbook Pro USB ports
  2. we start up the Macbook Pro application called Terminal in the Utilities folder of the Applications folder
  3. the Linux command

    df -k

    will show you the disks and removables (of which our Seagate Backup Plus is one), the latter of which normally get a name starting with “/Volumes/” as for our “/Volumes/Laura”

  4. we are going, today, to backup the local MAMP server to the Seagate Backup Plus via

    rsync -r /Applications/MAMP /Volumes/Laura/

    as you can see with (and on)

  5. now to indicate some success with this to you, we turn the Firefox web browser to Open File one of the backup HTML files (because it is a step too far to think you will be able to run PHP from the backup disk … perhaps tomorrow) … maybe you remember india_map.html from the series of blog postings ending with PHP Geographical Image Map Yet More Google Charts Tutorial ? … you can see with
  6. okay, that works, and so now, what about if india_map.html changes back at the Macbook Pro hard disk’s MAMP’s htdocs folder … we make a change to the <h1>India</h1> heading to <h1>India Map</h1>
  7. so now we are going to incrementally backup the local MAMP server to the Seagate Backup Plus via

    rsync -ruv /Applications/MAMP/ /Volumes/Laura/MAMP/

    as you can see with

  8. now to indicate some success with this to you, we turn the Firefox web browser to Open File that same india_map.html HTML file … as you can see with

Of course, as with all Linux a

man rsync

command helps explain things further, and we hope this tutorial and Linux.com’s useful link is of some help for you too.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Tutorials and tagged , , , , , , , , , , , , , , . Bookmark the permalink.

26 Responses to MAMP Virtual Hosting Primer Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *