Running tons of development servers on one linux host
I drive about 25 domains with different technologies like wordpress, drupal, b2evolution, lussumo vanilla, phpCMS etc. Most of that need a typical LAMP. That is a Linux, an Apache, a MySQL and a PHP. It’s common sense to have kind of test systems, systems where you can test your development work before bringing it up to production. For that I use one linux machine running OpenSuSE Linux 10.2 (basically some partitions on my laptop I use with a boot manager).
Goals of the development and testing environment
There are several goal to be met by my dev-env:
- Having production-near environment (Tools, Versions, OS)
- Having same code for testing as in production
- Having production-like network structure
- Having a permanent installation
How to setup lot’s of virtual servers on the development host
My first and most important hint: Don’t use yast2 for setting up the virtual apache hosts. That module is still buggy. Use it only to set up apache the first time.
Prerequisites
I assume you have apache2, MySQL4 or MySQL 5 and PHP4 or PHP5 up and running. All you need now is a virtual host, a new database and a new database user to run the dev-env. What you get from your production hosting provider is a domain, a database server, a database name and a database user.
Example: www.geekland.de
As an example I use my domain geekland.de. It is hosted by 1&1 and has the following attributes (not really exactly these
):
domain: geekland.de
db-host: db1234.1und1.de
db-user: dbo12345678
db-pwd: qwertz123
database: db12345678
CMS: wordpress 2.1
Tools: PHP5, MySQL 5, Apache 2
Setting up the local development domain
Because I don’t want to mingle the real domains, I use a TLD “.test” on my local machine. For the example that means, I set up the domain “geekland.test” on my host.
Setting up a virtual network interface
That’s an easy task within unix. As root use
ifconfig lo:1 127.0.0.2
and add in /etc/hosts
127.0.0.2 geekland.test www.geekland.test
Starting an apache virtual server on this virtual interface
Add the virtual server in your apache’s httpd.conf file:
NameVirtualHost 127.0.0.2
<VirtualHost 127.0.0.2>
ServerName www.geekland.test
DocumentRoot /srv/www/vhosts/geekland
</VirtualHost>
Now put your htdocs file into /srv/www/vhosts/geekland and don’t forget to restart your apache!
Create a database on your local MySQL server
Login in to your MySQL server via mysql command, then issue the following command:
CREATE DATABASE `db12345678` ;
Create a database user on your local MySQL server
Now create a database user and grant login rights:
CREATE USER 'dbo12345678'@'localhost'
IDENTIFIED BY 'qwertz123';
GRANT USAGE
ON * . * TO 'dbo12345678'@'localhost'
IDENTIFIED BY 'qwertz123'
WITH MAX_QUERIES_PER_HOUR 0
MAX_CONNECTIONS_PER_HOUR 0
MAX_UPDATES_PER_HOUR 0
MAX_USER_CONNECTIONS 0 ;
Now grant special rights (all) to the new user for the new database:
GRANT ALL PRIVILEGES
ON `db12345678` . *
TO 'dbo12345678'@'localhost'
WITH GRANT OPTION ;
Alias the DB-Server to localhost
As I don’t need any access to the hoster’s DB machine db1234.1und1.de. I alias that host to my localhost. With that simple trick I can use the same config (like wp-config.php) file on my dev-env as on the production environment.
In /etc/hosts modify the localhost line to contain the DB Server:
127.0.0.1 localhost db1234.1und1.de
Now you’re done. You can use all the same files on your production plattform and your development plattform now. The only thing you need to take care is to change the top level domain if necessary (i.e. in DB dump files of wordpress).
The next project
Your next project can be set up in exactly the same way, just change the virtual interface to lo:2 127.0.0.3 and the apache config accordingly.










November 13th, 2007 at 6:59 pm
[…] read more | digg story […]
November 19th, 2007 at 11:08 pm
I was wondering, I did a search for 1and1 root server virtual domains several minutes ago and found this site. While I know how to set up virtual hosts and virtual domains, specifying their root directly, I do not know where the config file is in 1and1 internet for this…for the root servers.
The only apache2/httpsd.conf file I found was the default in /etc/apache2/conf/httpsd.conf, however this file merely refers to the main root server and doesn’t even mention my first domain starlypt.org, much less the document root for this site, so I cannot place document roots and set up other virtual domains, as I am looking for the other httpd.conf file, and I have not found it….
Do you have any idea where else I can find it?
p.s…..try working with root servers that use more intelligent cluster administrators, running freebsd over fedora with 1and1, they are incompetent, I know MUCH more than they do, and they have not been helping me at all!
November 20th, 2007 at 11:07 am
Hi Erin,
I don’t use 1&1 root-Servers - but I use one of their vServers. Maybe the root servers are not so different.
On my vServer I have Plesk managing the virtual domains. And the DocumentRoot of the virtual domains reside in /var/www/vhosts. The configuration of the virtual domains is done in /var/www/vhosts/domainname/conf. That is possibly where you will find your starlypt.org conf file, too.
Hope that helps.
Cheers, Rainer