Home

My personal development environment runs on Arch Linux, and I had a lot of trouble getting it set up how I wanted. It’s the same setup as ones like Chris Mallison’s (for OS X) and Bruno de Bundt’s (for Ubuntu), but the process for setting it up on Arch is somewhat different. I used parts of each of their guides, and they certainly deserve some credit for this guide as well.

Installation

Run the following command:

$ pacman -S apache php php-apache dnsmasq mariadb

That will get you all the packages you need for the whole installation.1

Apache

In /etc/httpd/conf/httpd.conf, there are some things you need to change. Uncomment the lines: 2

Include conf/extra/httpd-vhosts.conf

LoadModule vhost_alias_module modules/mod_vhost_alias.so

Comment out the following block:

<Directory />
AllowOverride none
Require all denied
</Directory>

If you want to store your sites somewhere other than /srv/http, replace /srv/http in the line DocumentRoot "/srv/http" with the address at which you’d like to store your sites. On the line below, change where it says /srv/http to whatever you just changed your DocumentRoot to. For instance, I store my sites in ~/development/sites, so I would replace /srv/http with /home/jesse/development/sites.

Note: If the place that you’re changing your DocumentRoot to is inside your home directory, do not use the ~ character, but instead use the extended /home/<user> notation.

Delete or comment out everything in /etc/httpd/conf/extra/httpd-vhosts.conf, and replace it with this:

If you changed your DocumentRoot, make sure to change the /srv/http parts of both Directory and VirtualDocumentRoot in the vhost configuration above to whatever you set your DocumentRoot to. So again, I would replace <Directory "/srv/http"> with <Directory "/home/jesse/development/sites">, and VirtualDocumentRoot "/srv/http/%1/htdocs" with VirtualDocumentRoot "/home/jesse/development/sites/%1/htdocs".

Once we have set up dnsmasq, this vhost configuration will make it so that any site placed in the DocumentRoot will be accessible by going to sitename.dev in the browser. The end of the path in VirtualDocumentRoot is the directory in which your site files will be stored. For instance, your index.html file for the site called sitename would be located at /your/document/root/sitename/htdocs/index.html. You can change the htdocs folder to be whatever you want, but it’s traditionally either htdocs or wwwroot.

PHP

Uncomment these lines in /etc/httpd/conf/httpd.conf, or create them at the end of the list of LoadModule calls if they don’t already exist:

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

LoadModule php5_module modules/libphp5.so

Comment out this line:

LoadModule mpm_event_module modules/mod_mpm_event.so

At the end of the list of Include statements, just after the block for configuring mod_proxy_html, add the line:

Include conf/extra/php5_module.conf

If you would like pages other than index.html to be able to act as the index page of a site, edit the line:

DirectoryIndex index.html

and change it to something like

DirectoryIndex index.html index.php

You can add as many different index pages as you want.

Open up /etc/php/php.ini. If you changed your DocumentRoot in /etc/httpd/conf/httpd.conf, add it to open_basedir like so: