Setting up a LAMP for local development on Arch Linux

Just installed Arch Linux (after leaving Ubuntu due to Unity/GNOME 3). Now I need to setup my development environment. This should work for most distros, not just Arch. I want Apache, MySQL, PHP, phpMyAdmin, and SSL. Because its easy and I’m lazy, we’re going to setting up XAMPP. As always, first reference the wiki (Xampp – ArchWiki).

The steps break down like this:

1) Download the latest version from here.

2) Extract and move to /opt/

# tar xvfz xampp-linux-*.tar.gz -C /opt

3) Set passwords for MySQL and stuff

# sudo /opt/lampp/lampp security

4) Only listen for local connections
– Open /opt/lampp/etc/httpd.conf
– Change “Listen 80” to “Listen 127.0.0.1:80”

You could stop here, but I’m going to make a virtual host (with SSL).

5) I’m going to leave my document root as /opt/lampp/htdocs/ but I’m going to keep all my vhosts in /var/www/
– Create /var/www/
– Let make a wordpress site, create /var/www/wordpress/htdocs/ and /var/www/wordpress/logs/

6) Download the WordPress files
– Move to /var/www/wordpress/htdocs/
– Checkout the trunk from SVN

# svn co http://core.svn.wordpress.org/trunk/ .

I like using svn, because I can quickly do “svn up .” and update my wordpress install. More info here.

7) Create some blank log files

# touch /var/www/wordpress/logs/error_log
# touch /var/www/wordpress/logs/access_log

8) Make your vhost definition

# sudo nano /opt/lampp/etc/extra/httpd-ssl.conf

– Change “Listen 443” to “Listen 127.0.0.1:443”
– Add “NameVirtualHost *:443” right below it

– And something like this to the bottom of the file:

<VirtualHost *:443>
DocumentRoot "/var/www/wordpress/htdocs"
ServerName wp.localhost:443
ServerAdmin you@wp.localhost
ErrorLog /var/www/wordpress/logs/error_log
TransferLog /var/www/wordpress/logs/access_log

SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /opt/lampp/etc/ssl.crt/server.crt
SSLCertificateKeyFile /opt/lampp/etc/ssl.key/server.key
<FilesMatch ".(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/opt/lampp/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>
</VirtualHost>

9) What’s this wp.localhost nonsense all about?
We need to add a hosts definition

# sudo nano /etc/hosts

Mine looks like this

#
# /etc/hosts: static lookup table for host names
#

#      
127.0.0.1       localhost.localdomain   localhost arch-pc
::1             localhost.localdomain   localhost
127.0.0.1       wp.localhost

# End of file

Obviously you can just keep adding lines for whatever you want. Learn more here.

10) Start up xampp

# sudo /opt/lampp/lampp start

11) Go to https://wp.localhost/ and check out your site!

You might notice that if you try and browse directories with index files (idex.html, index.php, ect) then you get an error, not the familiar directory listing. If you want to change that, open up httpd.conf and add

<Directory "/var/www">
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Learn more here.

12) Post your troubles in the comments and I’ll do my best to help

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.