Virtual Apache Development Server
If you are a web developer, you will need a virtual server to test and run your code. On Linux you can install the LAMP packet (Linux, Apache, MySQL, PHP). On Windows or Mac you may prefer XAMPP. The problem: sometimes you need more! If you think of things like memcache or other packages that are only available on real Linux machines. For this you may want to install and configure a real virtual Linux server system.
The installation is quite simple. First you need to download a Linux server system as image. Then you have to create a new virtual machine and install this system. You can find a how to here.
For our needs a good solution is to use a highly configured virtual server which uses our source code that is situated on our host machine. So we do not need to copy files every time things changes and have also the current version running on our server. For this we can use shared folders. There may be problems for configuring the right user rights and correct setup. Also it may be difficult to set up shard folders on a text based server system. I found a good how to here. The steps are:
- Installation of a virtuel machine
sudo apt-get update sudo apt-get dist-upgrade
- install dkms. This is used for the installation of the GuestAdditions
sudo apt-get install dkms
- install GuestAdditions. The GuestAdditions can be mounted a cd rom image. You can install these additions manually from console. For this you also have to mount the cd rom drive:
sudo mount /dev/cdrom /cdrom cd /cdrom sudo sh ./VBoxLinuxAdditions.run
- create shared folder. For this you can use the virtual box menu. You have to choose the folder of you web application of the host system. It is important to click ok and do not choose any of the checkboxes.
- add your username to the vboxsf user group
sudo nano /etc/group
change this line
here you should set your username instead of USERNAME. The number 1001 may be different. Please do not change it to 1001. It is only an example.
- find out which UID and GID the user has
sudo nano /etc/passwd
find a line that looks nearly as this line
please do not change anything. At this example the UID is 1000 and the GID is also 1000. The first one after the x is the UID, the second one is the GID.
- Now we need to mount the share folder. It would be a good idea to mount it to /var/www so that your application will be found at localhost root by default.
sudo mount -t vboxsf -o rw,uid=1000,gid=1000 test /var/www
again, replace the numbers with your UID and GID.
- from now on, the Apache web server should show your application. You can proof this by entering the IP of your virtual server in a browser window on your host system.
It is really easy to set up a virtual server for special needs. You can for example test your source code on different server configurations without copying any file.