Virtual hosting on ubuntu desktop

Jordon Bedwell jordon at envygeeks.com
Sat Jul 23 07:59:02 UTC 2011


On Fri, July 22, 2011 10:37 pm, Amrit Pal Pathak wrote:
> I am using ubuntu desktop (10.04).I have installed Lamp and other
> packages. I want virtual hosting at my system(name based) so that
> i can access different pages with same I.P address (localhost).
> Can anybody here who have dont it ever?  What changes should i made
> to http.conf file of apache2?

sudo -i
mkdir -p /srv/www/{domain.tld,default.domain}
cp -R /var/www/* /srv/www/{domain.tld,default.domain}
chown -R www:www /srv/www
rm -rf /var/www
vim /etc/apache2/sites-available/default
After you open it add "ServerName *"
After you open it edit "DocumentRoot" to "/srv/www/default.domain"
cp /etc/apache2/sites-available/default
/etc/apache2/sites-available/domain.tld
mv /etc/apache2/sites-available/default
/etc/apache2/sites-available/default.domain
vim /etc/apache2/sites-available/domain.tld
After you open it edit "ServerName" to "domain.tld"
After you open it edit "DocumentRoot" to "/srv/www/domain.tld"
vim /etc/hosts
After you open it add at the end of the 127.0.0.1 line "domain.tld"

Now you get to restart and test it:
service apache2 restart
service apache2 status

Some of this is not needed, like the moving and removing of /var/www, I
just have problems with /var/www because it is, a, well, direct violation
of FHS that Apache refuses to fix and Debian also refuses to fix.  While
for very good reasons they won't remove it and change it to a more
appropriate directory, it's still annoying to me that there is that FHS
violation in Apache right off the bat.





More information about the ubuntu-users mailing list