Virtual Hosts for Development with Apache on Ubuntu

I do a lot of development on Ubuntu, as I often have multiple projects on the go which are nothing to do with each other, it’s often easier to create separate virtual hosts on my local development machine. This means that when they are ready for the “real world”, they are already set up as isolated sites at the root of their domain (rather than in a subdirectory of an existing site).

In order to do this, you need to create a new virtual host in your Apache config. Create a new file in the directory /etc/apache2/sites-available and open it in your favourite editor. It doesn’t matter what the file is called, but it’s best to keep it descriptive. We’ll call this project “mysite”, so the file can be called “mysite”. In the file we need to configure the Apache virtual host.

<VirtualHost 127.0.0.1>
ServerName mysite.localhost
DocumentRoot /var/www/mysite/public/
</VirtualHost>

In the VirtualHost tag, you put the IP, seeing as I only want this for local loopback (for development) I have just put 127.0.0.1. The ServerName is the URL that you use to connect to the site and the DocumentRoot is where the public documents are stored. This is a very basic set up, so there are many more options you can add.

To make the site enabled, you create a symbolic link to the file from the sites-enabled directory.

cd /etc/apache2/sites-enabled
ln -s ../sites-available/mysite mysite

You now need to add the subdomain (mysite.localhost) to the list of hosts, so open /etc/hosts in your favourite editor and append the line:

127.0.0.1 mysite.localhost

And then restart Apache:

sudo /etc/init.d/apache2 restart

Now you should be able to visit http://mysite.localhost on the local machine (assuming the directory does actually exist).

This should also be similar on MacOS and other linux Distros, but the file locations (particularly for Apache) will vary.

The Research Begins

As some of you may know, I have now officially started my masters. It is a technical MSc (by Research) on Location-based Social Media Services. The easiest way to describe this is I will be designing and developing a Wiki for a variety of media (text, audio, images and video) which (unlike Wikipedia) is not found using “keywords”, but instead is found based on the location of the client.

I am currently starting a literature survey in this area and have discovered a great, free, multi-platform reference manager called Mendeley, which is incredibly useful for literature storing, organising and tracking (and will even generate a bibliography)! I am researching on who’s currently doing what in location based and social media applications. This includes what applications are out there, what technologies are out there (for information transfer/web services and location analysis) and also what is currently being researched.

I will hopefully be blogging regularly about this, and keep this blog updated with my findings. Please leave comments if you have any suggestions regarding areas I should look into, applications or if you have any insight into this area.

Netbeans 6.9 Beta + Zend Framework

Having just got my brand new MacBook Pro, I’ve been setting it up as a development environment (blog post about that to come). I decided to install the new Netbeans 6.9 beta. The main reason for this is the Zend Framework (and Symfony) support.

In the past I have found Netbeans to be pretty good with code-completion when being used with Zend Framework, however with the release of Zend Tool (something I do really like), you’ve had to switch from Netbeans to the command line in order to create the project and then create a new Netbeans project from existing sources. This was a bit of a hassle.

Now, all you need to do is download the Framework, go into the Netbeans preferences > PHP > Zend tab, Zend script box should point to the zf script (from within the bin directory of the ZF downloading). On Mac and Linux it wants the zf.sh file (on Windows it will probably want the zf.bat file, although not tested). Once that has been set up, you can now create brand new Zend Framework projects from within Netbeans, and it preconfigures everything for you. Lovely!