Setting up a Joomla! Development Environment

If you are new to web development and are interested in using Joomla!, you may have used Google to try and find info to help you out. You may have done a search for “joomla development” or “joomla development tools” and got Setting up your workstation for Joomla! development as one of the results. This explains how to set up XAMPP and Eclipse on Windows, Linux and OS X. Now this document has some extremely useful information for people looking to get started. They even state that there are many possible configurations of environments for developing for Joomla!. I’m going to talk about how I have my environment setup for web development.

My workstation is setup with Ubuntu 10.04 running lighttpd/PHP 5.3/MySQL 5.1. I’m not going to go into details on how to install Ubuntu because there are already a few articles and blog posts out there explaining how to do this. Lighttpd is a web server like apache which aims to be fast and efficient with your system resources. You can use Apache if you like but I’m going to go over how I have lighttpd/PHP/MySQL set up.

Since I am using Ubuntu, I can just install everything needed from the Ubuntu repositories. All the commands below require you to open up a terminal and type in the command or copy & paste for them to run.

The following command will install lighttpd, PHP 5 with some extra packages, and MySQL.

$ sudo apt-get install lighttpd php5 php-pear php5-cgi php5-xdebug php5-curl 
php5-gd php5-mcrypt mysql-client mysql-server

During the install you will be prompted to insert a MySQL root password. This password is not the root password to your computer.

Note that you can see what other extra PHP packages are available by doing the following command in a terminal window :

$ sudo apt-cache search php5

Now that everything is installed, let’s begin setting it up.

By default, lighttpd runs under its own user and serves documents out of /var/www. While I’m working I don’t really like to leave my home directory. I also don’t want to deal with a problem because of permissions. So I prefer to have the web server running as my user and the web root sitting in my home directory. Now we will go over how to accomplish this.

You can name any of the directories below the way you want and organize them how you want. You just need to make sure you put the correct paths for the directories you create in the configuration file.

On my system, I put everything under ~/work (the “~” is a shortcut to the full path of your home directory). First, we are going to create the web root directory where all the code will reside.

$ mkdir -p ~/work/webhome

The -p flag of mkdir makes sure all parent directories are created. If none of the directories are there, it will first create the work directory, then the webhome directory.

We need to create the log directory, upload directory, and compress directory (if you enable mod_compress) into the home directory. I do this so I don’t have to mess around with changing a bunch of permissions.

$ mkdir -p ~/work/lighttpd/upload
$ mkdir -p ~/work/lighttpd/log
$ mkdir -p ~/work/lighttpd/compress

Now it’s time to change the paths and setup lighttpd. You can use whatever editor you like –  just replace vim below with the name of the editor you want to use.

$ sudo vim /etc/lighttpd/lighttpd.conf

We need to first make sure some modules are enabled for lighttpd to work. By default everything we need is there but mod_fastcgi, which will allow lighttpd to parse PHP files. Below is the server.modules section of my lighttpd.conf file.

server.modules              = (
            "mod_fastcgi",  # this needs to be added as it is not there by default
#           "mod_rewrite",
#           "mod_redirect",
#           "mod_evhost",
#           "mod_usertrack",
#           "mod_rrdtool",
#           "mod_webdav",
#           "mod_expire",
#           "mod_flv_streaming",
#           "mod_evasive"

Now we change the following options in the lighttpd.conf file. Make sure you use the full path of the folders you created above along with the user:group you want the server to run as. Below are the options that are changed in my lighttpd.conf file.

server.document-root = "/home/dustin/work/webhome"

server.upload-dirs = ( "/home/dustin/work/lighttpd/upload" )

server.errorlog = "/home/dustin/work/lighttpd/log/error.log"

accesslog.filename = "/home/dustin/work/lighttpd/log/access.log"

# size in kbytes - this is optional if you want to be able to upload big files
server.max-request-size = 20000

server.username = "dustin"

server.groupname = "dustin"

# if you have mod_compress enabled
compress.cache-dir = "/home/dustin/work/lighttpd/compress/"

Once done, save and close the file.

We enabled the module for fastcgi in the lighttpd configuration file. We need to enable the configuration for fastcgi. The following command accomplishes that.

$ sudo lighty-enable-mod fastcgi

Now we need to change the /etc/init.d/lighttpd file which controls starting/stopping/restarting of lighttpd. Since we changed the user:group that lighttpd runs as, and its init script makes sure that the directory /var/run/lighttpd is there with the correct user:group, we need to change the user and group.

Open /etc/init.d/lighttpd with your editor from the command line.

$ sudo vim /etc/init.d/lighttpd

We need to change the following line. Make sure you change www-data:www-data to the user:group you set in the /etc/lighttpd/lighttpd.conf file. Below is the original line and how I changed it:

chown www-data:www-data /var/run/lighttpd

changed to:

chown dustin:dustin /var/run/lighttpd

Once done, save and close the file.

There is one more change we need to make so paths work correctly in PHP. We need to open /etc/php5/cgi/php.ini and make sure cgi.fix_pathinfo=1 is uncommented. So open /etc/php/cgi/php.ini in your favorite editor.

$ sudo vim /etc/php5/cgi/php.ini

Search for cgi.fix_pathinfo=1 which is on line 842 on my machine and uncomment it by removing the ; at the beginning of the line.

Now lets restart lighttpd for all the changes to take affect.

$ sudo /etc/init.d/lighttpd restart

You should now be able to browse to http://localhost/ and see an empty directory listing. Now you can create different directories with installs of Joomla! or whatever you please and access them via http://localhost/directory_name or http://localhost/file_name.php.

One last thing we need to do is create a MySQL user to use. Now since this is more than likely your development machine using, the MySQL root user isn’t a huge problem. Just don’t ever use the MySQL root user for your scripts on a production server. This can lead to a lot of problems.

To create a new user:

$ mysql -u root -p
# you will be prompted for the password you entered during install
mysql> CREATE USER 'USER_NAME_YOU_WANT'@'localhost' identified by 'SOME_PASS_YOU_WANT';

Reference: MySQL Adding Users

At the very least, I hope this post gave you some ideas for playing around and setting up a development environment that is comfortable for you.

The Core Team
Editorial Staff Members at 'corePHP'
Editorial staff for the Core Technology Blog for 'corePHP' - news, views insights and advice for e-commerce, marketing technology , web design and development.

3 thoughts on “Setting up a Joomla! Development Environment

  1. Nick Richards


    We set up a server with these instructions exactly.

    We copy a PHP file to the working directory, however when we try to run the PHP file, it always says 403 Forbidden. We have changed and verified set permissions for the PHP file and made it executable etc, but to no avail.

    Otherwise, we are all set up and ready to go, but at the moment we just can’t use the server we have set up.

    Any suggestions?

    info at cgeeks dot co dot uk


    Nick Richards
    Computer Geeks

Comments are closed.