Newbie ques. Multiple dev sites in WAMP
Posted by: Sirius (---.singnet.com.sg)
Date: May 27, 2006 10:27PM

Gooday, first of all, I would like to say that I am new to WAMP and web development in general so pls. bear with me. I hv installed the latest version of WAMP and manage to get it up and running (not that it's difficult, thanks to it's developers).

I would like to know how can I set up multiple web sites using only 1 copy of WAMP. I read from the forum that VirtualHost may fit the bill but since I am using WAMP just for development purpose, I don't hv several spare IPs available. I also read about using different listening ports but I can't quite grasp the concept. Can anyone advise me how I can create something like these:

[localhost]
[localhost]

Thanks in advance.


Options: ReplyQuote
Re: Newbie ques. Multiple dev sites in WAMP
Posted by: CyberSpatium (67.170.181.---)
Date: May 28, 2006 12:24AM

One of the main reasons virtual host was included in apache was so one server, with one ip address could host unlimited websites with that one ip instead of having to use an ip for every website. The port has nothing to do with virtual hosting, so do not change that. If only you are going to be accessing your wamp sites, you can just edit your windows hosts file:

open:
C:\WINDOWS\system32\drivers\etc\hosts (open this with NotePad, not WordPad or MS Word)

Towards the bottom of the file, you will see:
127.0.0.1 localhost

Below that add:

127.0.0.1 testsite1.com
127.0.0.1 testsite2.com


Save the file. Open up apache conf file httpd.conf (again with Notepad,not with WordPad or MS Word)
C:\wamp\Apache2\conf\httpd.conf

Find this line:

#NameVirtualHost *:80

Change it to:

NameVirtualHost *:80

#
#### testsite1.com ####
#

<VirtualHost *:80>
ServerAdmin webmaster@testsite1.com
DocumentRoot C:/wamp/users/www.testsite1.com/public_html
ServerName www.testsite1.com
ServerAlias testsite1.com
ErrorLog C:/wamp/users/www.testsite1.com/logs/error.log
CustomLog C:/wamp/users/www.testsite1.com/logs/access.log common
<Directory "C:/wamp/users/www.testsite1.com/public_html">
Options Indexes FollowSymLinks Includes
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>

#
#### testsite2.com ####
#

<VirtualHost *:80>
ServerAdmin webmaster@testsite2.com
DocumentRoot C:/wamp/users/www.testsite2.com/public_html
ServerName www.testsite2.com
ServerAlias testsite2.com
ErrorLog C:/wamp/users/www.testsite2.com/logs/error.log
CustomLog C:/wamp/users/www.testsite2.com/logs/access.log common
<Directory "C:/wamp/users/www.testsite2.com/public_html">
Options Indexes FollowSymLinks Includes
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>


Save the file, and restart apache for the new settings to take effect. Note that the allow from 127.0.0.1 setting from above is for security reasons, is means only you can access this site. If you move your test sites to an actual live web server, change it to allow from all.

Also to get this to work for you, crate a folder in your wamp directory (c:\wamp) called users. This new folder is where all your virtual hosted websites will be saved. Now create a folder in the users folder called www.testsite1.com. In the www.testsite1.com folder, create two new folders, one called pubic_html where all your website files for testsite1 will go, and create a folder called logs, this is where you apache logs will go.

Now go back to the users directory, and create a new folder called www.testsite2.com. Go to that new folder and again, create a public_html folder and a logs folder.

You will now save all your html, php, images, ccs, and all other website files for testsite1.com in:
c:\wamp\users\www.testsite1.com\public_html

And you will save all your website files for testsite2.com in:
c:\wamp\users\www.testsite2.com\public_html

To see your sites in action, open up your web browser and go to:
http://www.testsite1.com
[www.testsite2.com]


Please note that I use testsite1.com and testsite2.com here in all these examples. Replace them with your actual domain name (google.com for example). You can also add more domains by adding it to the virtual host section of your httpd.conf file, and creating a new directory for that site in the users folder like in the previous example.

You can also set wamp to be accessible by others then yourself. Be careful thought, as wamp was designed for local testing and development only , not for a live production server. It has absolutely no security in place. But it can be done.

You will need to delete the testsite1.com and testsite2.com part we just added to windows hosts file. Now edit the httpd.conf file, and change all allow from 127.0.0.1 to allow from all. Save the file and restart apache for the new settings to take effect.

To make your site accessible to others, we will have to setup DNS for you domains. Sign up for a free dynamic ip address service. www.zoneedit.com is one of the most popular on the net. I prefer www.everydns.net myself.

After you create your accounts, add your domains. After you add a zone, you will need to setup two A records to tie your domain name to your ip address:

testsite1.com your.ip.address.here
www.testsite1.com your.ip.address.here


Now add your other domain and then add two A records for that domain to

testsite2.com your.ip.address.here
www.testsite2.com your.ip.address.here


now anyone can access you wamp by using:
http://www.testsite1.com
[www.testsite2.com]




Post Edited (05-28-06 23:47)

CyberSpatium
----------------------
WAMP Forum Admin

Web Development for Newbie's Blog - Check out my new blog. It is for web developers, and especially tailored for the web development newbie. If you are not fluent in “geek speak”, then this incredible resource is just you. And even if you are a web development pro, this is a great resource to check out some of the latest web development tips, news, tutorials, codes and more.

Options: ReplyQuote
Re: Newbie ques. Multiple dev sites in WAMP
Posted by: yfastud (---.mia.bellsouth.net)
Date: May 28, 2006 07:16PM

CyberSpatium, look like you're in the very good mood today, he he ;-)

Options: ReplyQuote
Re: Newbie ques. Multiple dev sites in WAMP
Posted by: CyberSpatium (67.170.181.---)
Date: May 28, 2006 10:26PM

I like helping people

Options: ReplyQuote
Re: Newbie ques. Multiple dev sites in WAMP
Posted by: Sirius (---.singnet.com.sg)
Date: May 29, 2006 12:57AM

Thank you very much for your guidance CyberSpatium. I appreciate your time and patience.

I have created the necessary folders and made the necessary amendment/additions. Nevertheless, I am now unable to restart my Apache server. I found that the issue is the VirtualHost setting in the httpd.conf. When I comment out the <VirtualHost *:80> entry, I am able to restart the Apache server.

By the way, my WAMP installation is in c:/program files/wamp. I have added this into the VirtualHost entry but am not sure whether the installation folder has any bearing on the issue observed.

Could someone advise me on the next course of action? Thanks very much.



Post Edited (05-29-06 01:50)

Options: ReplyQuote
Re: Newbie ques. Multiple dev sites in WAMP
Posted by: CyberSpatium (67.170.181.---)
Date: May 29, 2006 03:18AM

If apache does not start then there were some problems, most likely you did not make the correct settings to the virtual hosting part of your httpd.conf file I showed above. You most likely did not get all the folders I asked you to make correct. They need to all be correct in the httpd.conf file, or apache will not start.

Ok, here is what to do to get everything working ok. Delete all those folders I told you to make in the previous post, and now make a new folder called users in your root C: drive:
c:\users

Now you need to make some folders in your users folder for your websites to be stored and served up by apache. Here is a list of all the folders you need to make. Once again, the public_html folder is where all your html, php, images, ccs and other website files will go. The logs folder is where the apache access and error log for that domain will be stored.

c:\users\www.testsite1.com
c:\users\www.testsite1.com\public_html
c:\users\www.testsite1.com\logs
c:\users\www.testsite2.com
c:\users\www.testsite2.com\public_html
c:\users\www.testsite2.com\logs


Ok, now open up your httpd.conf file, and change the virtual host from what I posted above to this:

NameVirtualHost *:80

#
#### testsite1.com ####
#

<VirtualHost *:80>
ServerAdmin webmaster@testsite1.com
DocumentRoot c:/users/www.testsite1.com/public_html
ServerName www.testsite1.com
ServerAlias testsite1.com
ErrorLog c:/users/www.testsite1.com/logs/error.log
CustomLog c:/users/www.testsite1.com/logs/access.log common
<Directory "c:/users/www.testsite1.com/public_html">
Options Indexes FollowSymLinks Includes
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>

#
#### testsite2.com ####
#

<VirtualHost *:80>
ServerAdmin webmaster@testsite2.com
DocumentRoot c:/users/www.testsite2.com/public_html
ServerName www.testsite2.com
ServerAlias testsite2.com
ErrorLog c:/users/www.testsite2.com/logs/error.log
CustomLog c:/users/www.testsite2.com/logs/access.log common
<Directory "c:/users/www.testsite2.com/public_html">
Options Indexes FollowSymLinks Includes
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>


Save the file, and restart apache for the new settings to take effect. Don’t worry about having your wamp installed in your Program Files directory. Virtual hosts sites can be stored anywhere on your computer, even on a different hard drive. But it is 100 times easier to have all the websites/domains in one main location, so that is why we use the users folder.



Post Edited (05-29-06 03:21)

CyberSpatium
----------------------
WAMP Forum Admin

Web Development for Newbie's Blog - Check out my new blog. It is for web developers, and especially tailored for the web development newbie. If you are not fluent in “geek speak”, then this incredible resource is just you. And even if you are a web development pro, this is a great resource to check out some of the latest web development tips, news, tutorials, codes and more.

Options: ReplyQuote
Re: Newbie ques. Multiple dev sites in WAMP
Posted by: Sirius (---.singnet.com.sg)
Date: May 29, 2006 12:58PM

Thanks once again for your great help and patience CyberSpatium, Apache can start/restart as normal now.

After populating each public_html folder with a "index.php" and accessing them through my firefox browser, I got the "Server not found" error.

The addresses enter at the browser are:
[www.testsite1.com] or [www.testsite2.com]

I would like to add that when I tried using just [localhost], I was redirected to [localhost]. Could this is the problem? How can I stop the redirection? I can't find anything on xampp on the laptop which I am using for the setup.

Thanks in advance


Options: ReplyQuote
Re: Newbie ques. Multiple dev sites in WAMP
Posted by: CyberSpatium (67.170.181.---)
Date: May 29, 2006 10:00PM

you need to replace testsite1.com and testsite2.com with your actual domain names.

if you are getting service not found then you may have errors in your httpd.conf file, or you may have not setup your windows hosts file correctly, or it you are using dynamic dns, you did not set that up correctly.

about your localhost problem, I have done a search and I can not find a splash.php file in my wamp directory. are you using WAMP from wampserver.com or XAMPP from apachefriends.org?

try adding this to virtual hosts part of your httpd.conf file.

#
#### localhost ####
#

<VirtualHost *:80>
ServerAdmin root@localhost
DocumentRoot "c:/program files/wamp/www"
ServerName localhost
ServerAlias localhost
ErrorLog c:/program files/wamp/logs/error.log
CustomLog c:/program files/wamp/logs/access.log common
<Directory "c:/program files/wamp/www">
Options Indexes FollowSymLinks Includes
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost
>

save the file and restart apache for the new settings to take effect. now try to go to localhost again and see what happens.

Options: ReplyQuote
Re: Newbie ques. Multiple dev sites in WAMP
Posted by: nateharper (---.cable.mindspring.com)
Date: June 06, 2006 05:12AM

I, too, am new to wamp. i tried this and found the same problem loading page with firefox. i have had trouble loading pages before but I did not figure that one out either. I have wamp installed in c:/wamp so it should work right? but it hasnt. It would just go on and on loading and not do anything. I copied and paisted everything from the posts. when i try to go to [www.testsite1.com] (I have changed the site but I did go into the config file and change all of that too) it pops up the error message problem loading page. is there something else i have done to make wamp not work correctly? I loaded wamp with all of the defaults.

thank you for your help

Options: ReplyQuote
Re: Newbie ques. Multiple dev sites in WAMP
Posted by: CyberSpatium (67.170.181.---)
Date: June 06, 2006 07:22AM

make sure you replace testsite1.com from my instuctions above with your actuall domain name. also make if you are using dynamic ip service make sure you dns settings are correct. also after you make any changes to your httpd.conf or php.ini file you need to restart apache for the new settings to take effect.

Options: ReplyQuote


Sorry, only registered users may post in this forum.