Running a local web server on your Macbook Pro isn’t that special. Mac OS has Apache server installed per default. You just have to activate it via the terminal window (ie: check out this post to see how).
I love working in the Terminal prompt but not when it’s for tedious config and setup stuff like localhost redirects and local redirect settings. After Googling around to see if there were other FREE tools besides MAMP. I’ve been using that app in the past but I don’t always want to use mySql and PHP per default. Not since client-side JS evolved so fast and stuff like AngularJS started to really define the game!
In this post I’ll show you how to setup a nice GUI for Apache running on your Mac and the steps that you need to take to get a nice config going.
More after the break
Apache GUI – free and easy
My Googling led me to Apache GUI. This is a JAVA based – I know, it scared me at first too – GUI that runs on your machine and lets you setup stuff in your browser running in Localhost on a specific port (9999 is the default).
What you can do with it:
- Start, Stop and Restart Apache
- Vew Runtime Information
- Search, Download and tail logs
- Edit Configurations
- Test the server configuration for errors
- Search for keywords in the configuration files
- View, install and remove apache modules
- Record, Search and Graph detailed Apache Transactions.
Setup your machine
Although Apache GUI itself is very clean and easy to use you have to install it first, and setup your machine so you can play nice with multiple websites on your localhost and have a workable structure.
Follow the steps below to get your setup going:
- Let’s get the ingrediënts
download Apache Gui from http://sourceforge.net/projects/apachegui/
- Bake your pizza bottom in the oven
Install Apache Gui using their instruction on http://apachegui.net/installation#linux
- Add a sniff of PHP, pepperoni, cheese and ansjovis
Open the Appache Server httpd.conf (usually in the /etc/apache2/ directory) configuration file and
activate PHP5 (disabled by default) by un-commenting :
- A side dish to serve along with the main course
Check that in httpd.conf the (separate) Virtual Hosts file (httpd-vhosts.conf) is included / not commented out:
- Make the meal personal with your custom toppings
(OPTIONAL) By default, Apache Server looks for website documents for any directory placed under DocumentRoot “/Library/WebServer/Documents”. If you want to change this directory to a location under your user account for instance, you need to configure this in the httpd.config file as well:
[crayon-6079717e7c5fd961855598/] Comment out (using #) or remove the DocumentRoot and add a new entry. In the above example the document root for Apache has been changed so it looks for the Sites directory in your user profile location. All the files placed within that directory will be served on the Apache server.
- Taste it with a spoon and add salt ‘n pepper if needed
(OPTIONAL) Test if your config settings worked by performing
- Setup the table for dinner
Setup the hosts in Apache GUI by navigating to http://localhost:9999/ApacheGUI/ (if you installed it with the default port etc) and select Virtual Hosts in the left menu (one of the last items).
This basically generates entries for virtual hosts in the httpd-vhosts.conf file that your Apache now includes.You can always view and edit the vhosts config in a raw format by selecting it in the left under Configuration->extra->httpd-vhosts.conf.
Please note: Only if you’ve followed the installation steps from step 2 and used the settings there this menu item points to the correct config file.An example entry as it could be registered in the httpd-vhosts.conf file:
[crayon-6079717e7c602622450006/] This registers the /kittenwebsite subdirectory as a virtual host under kittens.loc. Making all the files under that directory available.
- Place name cards for each seat
Next up; add an entry to your hosts file (/etc/hosts) so the url will refer to localhost instead of a non-existing (or worse, a very bad) website:
- Dim the lights and put on a candle
Stop and start the Apache server on your machine so it gets all the newly configured stuff pumping through its veins:
- Put on some music
Make sure there is a file that Apache can find for you – like index.html or index.php – in your website directory (If you followed the steps above: /Users/YOUR_USERNAME_HERE/Sites/kittenwebsite) and watch it being served when you enter kittens.loc in your browser!
Enjoy your meal