Multiple local websites in ubuntu LAMP

Just got a way to create multiple local websites in ubuntu which has LAMP installed. This information will be helpful when many computers connected with ubuntu server in LAN network(may be office or home local network).

Generally we had to disable default site to enable new site as per the documentation given by ubuntu community, so only one site can be enabled at a time.

Here's is the organized way to have multiple sites enabled at a time.

Assume i am going to create a local site called colorpicker.local.

Create directories like /home/[user]/websites/colorpicker/public_html

Go to /etc/apache2/sites-available

cd /etc/apache2/sites-available

Copy the default website and name it as colorpicker

cp default colorpicker

Edit the colorpicker site configuration file

gedit colorpicker

Change it as below

<VirtualHost *>
              DocumentRoot /home/[user]/websites/colorpicker/public_html/
              ServerName colorpicker.local

              <Directory /home/kbala/websites/colorpicker/public_html/>
                           Options Indexes FollowSymLinks MultiViews +Includes
                           AllowOverride All
                           Order allow,deny
                           allow from all

And now, we have to enable the site by this command

a2ensite colorpicker

Finaly, we have to add this site into the hosts file

gedit /etc/hosts

add below line at the end of the file         colorpicker.local

Now, try http://colorpicker.local in the browser, it will work, if things are correct.

OK, If you are in LAN network connected with few computers, you have to set the site info in the hosts file of the computer.

For windows, edit the hosts file which is located in c:\windows\system32\drives\etc\hosts

add the below line at the end of the file

[your ubuntu server LAN ip]       colorpicker.local

For linux, edit the file from /etc/hosts

add the below line at the end of the file

[your ubuntu server LAN ip]       colorpicker.local

That's all, now you have configured a new site and its visible to all the computer in the LAN. Please follow the same steps to create another new site , like wise you can have multiple local sites running in the local server at a time.

And if you are giving the sharing option to websites folder accessible to all the computer, then people can upload the web content directly, and can check the site their itself, yep, Enjoy!

Be Sociable, Share!

Leave a Reply

Copyright © 2008-2010 K BalaSubramanian | Credits