How to create multiple websites for Apache server using Vhosts

# This one is pretty simple - we’re just using common Unix commands.
# I find this one helpful when I don’t want to generate a rails site skeleton on the server.

# create web application skeletal structures

cd ~/public_html

# domain 1
mkdir -p mydomain1.com/{backup,cgi-bin,log,private,public}
mkdir -p mydomain1.com/{config,releases,shared,tmp}
mkdir -p mydomain1.com/tmp/pids
# create symlinks for a capistrano site here
ln -s /home/super/public_html/mydomain1.com  /home/super/public_html/mydomain1.com/current
ln -s /home/super/public_html/mydomain1.com/log  /home/super/public_html/mydomain1.com/shared/log

# domain 2 (optional)
mkdir -p mydomain2.net/{backup,cgi-bin,log,private,public}
mkdir -p mydomain2.net/{config,releases,shared,tmp}
mkdir -p mydomain2.net/tmp/pids
# create symlink for capistrano site here
ln -s /home/super/public_html/mydomain2.net  /home/super/public_html/mydomain2.net/current
ln -s /home/super/public_html/mydomain2.net/log  /home/super/public_html/mydomain2.net/shared/log

# domain 3 (optional)
mkdir -p mydomain3.ws/{backup,cgi-bin,log,private,public}
mkdir -p mydomain3.ws/{config,releases,shared,tmp}
mkdir -p mydomain3.ws/tmp/pids
# create symlink for capistrano site here
ln -s /home/super/public_html/mydomain3.ws  /home/super/public_html/mydomain3.ws/current
ln -s /home/super/public_html/mydomain3.ws/log  /home/super/public_html/mydomain3.ws/shared/log

# to see what was created in the above code, use “ls -la” command (optional)

ls -la ~/public_html/
ls -la ~/public_html/mydomain1.com
ls -la ~/public_html/mydomain2.net
ls -la ~/public_html/mydomain3.ws

# enable (turn on) website applications in apache

sudo a2ensite mydomain1.com
sudo a2ensite mydomain2.net
sudo a2ensite mydomain3.ws

# disable (turn off) website applications in apache
#sudo a2dissite mydomain1.com
#sudo a2dissite mydomain2.net
#sudo a2dissite mydomain3.ws

# (re)start apache server

sudo /etc/init.d/apache2 start
# or
sudo /etc/init.d/apache2 reload

# visit your sites in a web browser

http://mydomain1.com
http://mydomain2.net
http://mydomain3.ws
# secure versions (self-signed)
https://mydomain1.com
https://mydomain2.net
https://mydomain3.ws

Done!

44 Comments so far »

  1. Kathy said,

    Wrote on August 3, 2008 @ 7:31pm

    Hello people! Nice site!

  2. Ron said,

    Wrote on August 12, 2008 @ 5:40am

    Great site. I will bookmark for my sons to view as well!!!/

  3. jeroen said,

    Wrote on August 14, 2008 @ 10:31pm

    This website is very nice and colorful too. Its nice to have something to show others where you attend church and to show all the smiling people filled of the goodness of the Lord. You have a wonderful website here. May God rich bless you always.

  4. Dan said,

    Wrote on September 2, 2008 @ 5:32pm

    Nice post. I\’ll return.a

  5. Willem said,

    Wrote on September 2, 2008 @ 6:04pm

    I like it and the background and colors make it easy to readh

  6. Willem said,

    Wrote on September 3, 2008 @ 11:19pm

    Thank for making this valuable information available to the public.t

  7. jammarlibre said,

    Wrote on September 10, 2008 @ 1:52am

    This is very interesting sites

  8. Rosina said,

    Wrote on September 12, 2008 @ 4:25am

    This website is very nice and colorful too. Its nice to have something to show others where you attend church and to show all the smiling people filled of the goodness of the Lord. You have a wonderful website here. May God rich bless you always.

  9. Melissa said,

    Wrote on September 13, 2008 @ 11:58pm

    Very good web site, great work and thank you for your service.

  10. judy said,

    Wrote on September 15, 2008 @ 9:38pm

    daite na pivoo

  11. john said,

    Wrote on September 17, 2008 @ 12:41am

    This is very interesting sitee

  12. Rosina said,

    Wrote on September 19, 2008 @ 2:45pm

    Pretty nice site, wants to see much more on it! :)d

  13. Martin said,

    Wrote on September 26, 2008 @ 5:26am

    Just serfed in. Great site, guys!

  14. Albert said,

    Wrote on September 27, 2008 @ 10:11pm

    Hi, all. Nice site…I really like your site ! Good job man.

  15. john said,

    Wrote on September 29, 2008 @ 11:13pm

    You have an outstanding good and well structured site. I enjoyed browsing through it.

  16. Melissa said,

    Wrote on September 30, 2008 @ 1:08pm

    Greetings!..:

  17. Kathy said,

    Wrote on October 1, 2008 @ 8:08am

    Very good site! I like it! Thanks!h

  18. john said,

    Wrote on October 4, 2008 @ 1:59am

    Just wanted to say hello

  19. Robert said,

    Wrote on October 7, 2008 @ 2:52pm

    keep up the good work!n

  20. Melissa said,

    Wrote on October 19, 2008 @ 3:48am

    It\’s a great and valuable site!d

  21. Melissa said,

    Wrote on October 22, 2008 @ 9:06pm

    Please, do not delete the given message. Money obtained from spam will go to the help hungry to children ugand

  22. Kathy said,

    Wrote on October 24, 2008 @ 6:49am

    huyak

  23. Albert said,

    Wrote on October 28, 2008 @ 11:30am

    Nice post. I\’ll return.u

  24. Martin said,

    Wrote on October 30, 2008 @ 7:18am

    keep up the good work!

  25. Hannes said,

    Wrote on October 31, 2008 @ 5:31pm

    I\’l be back… :)i

  26. Siber said,

    Wrote on November 2, 2008 @ 12:43pm

    s prazdnikov vaso

  27. Siber said,

    Wrote on November 3, 2008 @ 6:32pm

    Please, do not delete the given message. Money obtained from spam will go to the help hungry to children ugand=

  28. judy said,

    Wrote on November 3, 2008 @ 6:33pm

    Excellent web site I will be visiting often

  29. Rosina said,

    Wrote on November 4, 2008 @ 11:25am

    This website is useful for individuals who are searching prayers and novenas and all.

  30. jammarlibre said,

    Wrote on November 4, 2008 @ 4:09pm

    This is very interesting site…

  31. Kathy said,

    Wrote on November 5, 2008 @ 4:10am

    Da nu Nahn

  32. Martin said,

    Wrote on November 6, 2008 @ 5:05am

    Oh o ho! very nice site!h

  33. Rosina said,

    Wrote on November 6, 2008 @ 8:24am

    Hi our little brothers.k

  34. Robert said,

    Wrote on November 7, 2008 @ 8:18am

    Looking for information and found it at this great site…

  35. Dan said,

    Wrote on November 7, 2008 @ 4:07pm

    A fantastic site, and brilliant effort. A great piece of work.t

  36. Robert said,

    Wrote on November 8, 2008 @ 11:00am

    This is very interesting site…

  37. judy said,

    Wrote on November 11, 2008 @ 1:37pm

    I praise God for answering my prayers. God, you are so wonderful, majestic. Jesus Christ, I adore Your Sacred Heart.

  38. Timmy said,

    Wrote on November 11, 2008 @ 10:14pm

    This website is very nice and colorful too. Its nice to have something to show others where you attend church and to show all the smiling people filled of the goodness of the Lord. You have a wonderful website here. May God rich bless you always.

  39. Martin said,

    Wrote on November 12, 2008 @ 4:24pm

    Great site. I will bookmark for my sons to view as well!!!/

  40. Willem said,

    Wrote on November 13, 2008 @ 10:28pm

    You have built a good websiteg

  41. Hannes said,

    Wrote on November 13, 2008 @ 10:32pm

    Excellent site, added to favorites!!e

  42. Kathy said,

    Wrote on November 15, 2008 @ 12:27am

    I enjoy your site very much! THANK YOUn

  43. judy said,

    Wrote on November 17, 2008 @ 1:17am

    I can find the prayer I want. I thank God for this website.r

  44. jammarlibre said,

    Wrote on November 17, 2008 @ 4:13am

    These prayers help me to keep God in my life, especially with the many distractions I encounter.

Comment RSS · TrackBack URI

Leave a Comment

Name: (Required)

E-mail: (Required)

Website:

Comment: