Configuration of Apache
What you'll need is the Apache VirtualHost directive.
See the Apache Documentation and some Examples.
Basically what you want to do in Ubuntu is to make sure, that the port you want to use (usually :80) is enabled in /etc/apache2/ports.conf like this:
Next you'll have to create a new conf-file in /etc/apache2/sites-available.
I'd suggest to name it proj1.conf or proj1.mydomain.conf.
There you can configure the VirtualHost as follows:
# Write a seperate log per Virtualhost
CustomLog /var/log/apache2/proj1.subdomain.access_log combined
# Maybe you want to put some restrictions on the directory
Options -Indexes +FollowSymLinks + Includes
# Restrict Access to certain IP's
Deny from All
Allow from 127.0.0.1 IP IP IP
Consult the Apache Manual to see what you could do with the Directive.
To enable this Site, link it to /etc/apache2/sites-enabled
ln -s /etc/apache2/sites-available/proj1.conf /etc/apache2/sites-enabled/proj1
Now all you have to do is make sure your config is valid and then restart Apache:
apache2ctl configtest && /etc/init.d/apache2 restart
If you're running a virtual machine, DNS is probably provided by your hoster, so you could talk to him regarding setting the DNS up.
Naturally you will have to set up the subdomain in your DNS in a way that it points to this server.
For this you can create an A- or CNAME-Record for each subdomain and point it to your server.
This is how your Bind Zone-file could look:
@ IN SOA dns1.example.com. emailaddress.domain.com. (
2011120701 ; serial number YYMMDDNN
1h ; Refresh
20m ; Retry
2w ; Expire
2h ; Min TTL
@ IN NS dns1.example.com.
@ IN NS dns2.example.com.
@ IN MX 10 mx1.domain.com.
@ IN MX 20 mx2.domain.com.
@ IN A 999.999.999.999
subdomain IN A 666.666.666.666
proj1.subdomain IN CNAME subdomain
*.subdomain IN CNAME subdomain
Obviously you'd have to replace domain.com by your domain, 999.999... and 666.666 by the proper IP's, change the NS and MX Records etc..
See the Bind manual for further details.
For testing purposes you can also edit the hosts-file on your local computer. That way only your computer will resolve the subdomain to this server, so you can check if everything works and only change the DNS if it does.
If you want to create "sub-subdomains" that point to the same directory as the subdomain, you could add a ServerAlias to your Apache2 config, next to the ServerName:
The DNS configuration would be the same as pictured above.