A web site located on a local computer is accessed in a browser through the URL localhost and normally served by a local Apache server. There are two parts to this process. The first is the resolution of the name localhost to the IPv4 loopback address 127.0.0.1 which is configured in the local computer’s hosts file.
Fixing WordPress “404 Object Not Found” Errors on a Mac OS X Local Server Environment
Installing WordPress on a local server environment is fairly straight forward. There are numerous guides to be found on the Internet that’ll walk you through each step.
However, if your local server environment is running on a Mac, the local Apache server may have some difficulty serving WordPress posts and pages resulting in Error 404 Object not found! errors. These errors can often be attributed to the use of custom or so-called pretty permalinks.
Starting MAMP’s Apache and MySQL Servers at Login
Whether using XAMPP or MAMP to provide a local server environment I prefer to have the respective Apache and MySQL servers start when I login.
With XAMPP I use a launch daemon and this works perfectly. With MAMP it’s even easier as there’s an option to Start Servers when starting MAMP in MAMP’s preferences. I only need to add MAMP.app to my Login Items and MAMP’s servers will be up and running after logging in.
Accessing localhost and Virtual Hosts Across a Local Network
I have several computers on my local network each with a local server environment provided by XAMPP. As it stands, the local server on each computer can only serve pages stored on that machine. This means that if I have a local site on computer A that I wish to access on computer B I have to replicate that site’s entire folder structure on computer B and on all other computers I want to access the site from.
No big deal really as I currently use ChronoSync to synchronise my site’s folder structure across computers. However, it is possible to have any computer on a local network serve pages that are stored on another computer on that same network. Here’s how.
Starting XAMPP’s Apache Server at System Startup on Mac OS X
Until I recently switched to XAMPP I had been using MAMP to provide a local server environment on my Mac. A small but none the less important feature of MAMP is an option to have the Apache and MySQL servers started when you open the application. So, by checking this option and including MAMP as a Login Item my MAMP servers were up-and-running when I logged in. Unfortunately, XAMPP has no such option. Including XAMPP as a Login Item merely opens XAMPP Control.app and I have to start the servers manually. An extra step I’d rather not have to do.
So, how can I have my XAMPP servers running whenever I login? The answer, by using a daemon.
Configuring Virtual Hosts in XAMPP on Mac OS X
A while back I posted about configuring virtual hosts in MAMP. More recently I noticed that MAMP hadn’t been updated in nearly a year and their support forum resembled a wilderness. Thinking that maybe the writing was on the wall for MAMP I started looking for an alternative and came across XAMPP.
XAMPP provides a similar local server environment to MAMP, but configuring virtual hosts is a little different. Unlike the Pro version of MAMP , XAMPP doesn’t have a nice GUI to allow virtual hosts to be configured easily. So, there is no alternative but to do it manually.
Configuring Virtual Hosts in MAMP on a Mac
If you need to easily set-up and maintain a local server environment on your Mac then look no further than MAMP. MAMP comes with Apache, MySQL and PHP and provides a local server environment independent of that installed as default on macOS. And it’s free.
However, out-of-the-box you’re limited to a single local host. This can prove inconvenient when developing multiple sites each requiring their own local host. The most convenient and cost effective way to overcome this limitation is to use virtual hosts.
Recent Comments