Subdomains for Localhost Guide
Posted by: fastburst (---.tc.ph.cox.net)
Date: April 10, 2007 10:33PM

Here is a little something I did to make the subdomain creation for LOCALHOST.

MAKE SURE TO DO BACKUP OF YOUR FILES BEFORE YOU EDIT THEM!

############
STEP 1
############
create a folder called 'subdomains'
in C:/WAMP/apache2/conf/

############
STEP 2
############
In WAMP enable the 'vhost_alias_module'

open httpd-vhost.conf and edit to look like below or delete all the content but not the file itself.
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:[httpd.apache.org];
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

############
STEP 3
############
Next open wampmanager.ini and add this to the
[Menu.Left]
Type: separator; Caption: "Localhost Subdomains"
Type: submenu; Caption: "Subdomain directories"; SubMenu: subdomain_dir; Glyph: 3


Once you have done that you need to add this to the very bottom of the wampmanager.ini

[add_subdomain]
Action: run; FileName: "G:/WAMP/php/php.exe";Parameters: "-c . ../scripts/add_subdomain.php";WorkingDir: "G:/WAMP/php"; Flags: waituntilterminated
Action: service; Service: wampapache; ServiceAction: restart;
Action: resetservices
Action: readconfig;

[subdomain_dir]
Type: separator; Caption: "Subdomain directories"
Type: item; Caption: "Add an subdomain"; Action: multi; Actions: add_subdomain;Glyph : 8
Type: separator
;add_subdomain

;add_menu_subdomain

;add_delete_subdomains


Save the file

############
STEP4
############

Now Save the next peice of code as add_subdomain.php and save it to your C:/WAMP/scripts/ folder

Make these change to your resepctive paths for this script

$httpconf_file = 'C:/WAMP/apache2/conf/extra/httpd-vhosts.conf';
$wampserverini_file = '../wampmanager.ini';
$conffile_dir = 'C:/WAMP/apache2/conf/subdomains/';

open this file and save

[www.btt-scripts.com]
Save the file.
############
STEP 5
############

Now Save the next peice of code as delete_subdomain.php and save it to your C:/WAMP/scripts/ folder
Edit this part of the code below to your respective paths

$conffile_dir = 'C:/WAMP/apache2/conf/subdomains/';
$wampserverini_file = '../wampmanager.ini';
$httpdconf_file = 'C:/WAMP/apache2/conf/extra/httpd-vhosts.conf';

open this file and save

[www.btt-scripts.com]

Save file after you configure the lines at the top.

* * * * * * * * CONTINUED ON NEXT POST * * * * * * * *



Post Edited (04-10-07 22:56)

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: fastburst (---.tc.ph.cox.net)
Date: April 10, 2007 10:40PM

############
STEP 6
############

Next you will also need to update your hosts file located in

c:/windows/system32/drivers/etc/

Or where you have it located.

# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost www www.localhost
127.0.0.2 subdomain1 subdomain1.localhost
127.0.0.3 subdomain2 subdomain2.localhost


Notice above how the subdomains are created. This is important.


IMPORTANT
You must assign an IP address internally to your localhost subdomain in order for it towork and display properly. Also when creating a subdomain in hte WAMP Mananger make sure you use this IP address that you assigned here or it will not work properly.

############
STEP 7
############

Restart WAMPSERVER

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: fastburst (---.tc.ph.cox.net)
Date: April 10, 2007 10:43PM

If you cannot copy and paste the code above, go here for the add_subdomain.php and delete_subdomain.php files.

[www.btt-scripts.com]


Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: CyberSpatium (71.237.217.---)
Date: April 10, 2007 11:13PM

any changes you make to the hosts file is file will only be to you (localhost). so no one else will be able to use that subdomain to access your server


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

Need help? Check out my WAMP User Manual/Guide here!


Please visit my latest website Clarify Loans:
clarifyloans.com

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: fastburst (---.tc.ph.cox.net)
Date: April 10, 2007 11:38PM

That is correct. This is a mod for those who want to be able to have subdomains on a localhost for testing purposes.

It can probably be changed for live production but that is not my intentions here.

=)

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: CyberSpatium (71.237.217.---)
Date: April 11, 2007 12:20AM

you can add a subdomain from a website like no-ip.com but you will have to add it to wamp the same way you setup domain names using virtualhost.


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

Need help? Check out my WAMP User Manual/Guide here!


Please visit my latest website Clarify Loans:
clarifyloans.com

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: techno_man (---.20-57-74.mc.videotron.ca)
Date: April 11, 2007 01:03AM

okay since im a *newbie*to all of this stuff, doesnt mean i dont know everything but 1 thing i do know is ports are very essentual when trying to do a webpage or servering a webpage on line threw http port 80 (most providers block it) but they say its to prevent from virus reasons, thats what mine says so yah using a dns server like what the admin was saying is the best way to protect yourself and dont forget to cloak ur ip address if there is a enable for it ! you dont want the web users going to your site to know your actual ip !



Post Edited (04-11-07 01:03)

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: fastburst (---.tc.ph.cox.net)
Date: April 11, 2007 01:11AM

Of course completely understand but Iam afraid you both are missing the point and the title of the Subject

This is for localhost testing only for subdomains on localhost only.

I would not recommend doing this as a live server. but for testing only so that you can write whatever scripts and or sites and test them internally only.

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: fastburst (---.tc.ph.cox.net)
Date: April 11, 2007 01:14AM

I also have gotten properly tested the script to write and delete entries to the 'hosts' file.

If anyone wants me to update the script so it is completely automated now, please let me know and I will update the linked pages to the new code on add_subdomain.php and delete_subdomain.php

Until I will leave it as is.

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: techno_man (---.20-57-74.mc.videotron.ca)
Date: April 11, 2007 01:18AM

okay i understand you 100%,dont gety me wrong you seem preety smart from what i see up abouve------ but dont yah think most people today working with servers or local servers want to serve from there own homes and thats the reason why most will ask the questions on how too do it, listen im paying *90$* a month and my speeds are awesome and bandwidth is unlimitted ---10mbps--- so yah im going to do something with it cause i am one of the best paying customers my provider has and they are giving extras cause im good paying client !!



Post Edited (04-11-07 01:27)

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: CyberSpatium (71.237.217.---)
Date: April 11, 2007 01:26AM

most ISP's do not see customers hosting their own webserver using their ISP account as a 'good customer'. most hosts strictly do not allow their customers to use their account for hosting.


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

Need help? Check out my WAMP User Manual/Guide here!

Please visit my latest website Clarify Loans:
clarifyloans.com


Like my free support? Help support me by making a donation today!

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: yfastud (---.cable.mindspring.com)
Date: April 11, 2007 02:23AM

Quote

If anyone wants me to update the script so it is completely automated now, please let me know and I will update the linked pages to the new code on add_subdomain.php and delete_subdomain.php

Nice job fastburst!!!

if you don't mind, please update it

Have fun,

[www.jlbn.net] (testing WAMPS)
[test.jlbn.net] (testing codes)

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: Mcstec (---.pitbpa.east.verizon.net)
Date: April 11, 2007 06:01AM

Update please... winking smiley

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: fastburst (---.tc.ph.cox.net)
Date: April 11, 2007 04:54PM

Okay I have updated the links with the new scripts. This update to the script will automatically edit the hosts file for you so that you do not have to add or edit the hosts file yourself like you did previously. It also removes them from the hosts as you remove them from WAMP as well.

NOTE: you may need to change the permissions settings on your hosts file in order for the script to work properly.

IMPORTANT: Make sure to backup your scripts and files before making any modifications to your WAMP or Windows Hosts file.

v1.1.0
add_subdomain.php
[www.btt-scripts.com]

Edit these lines to your installation
$httpconf_file = 'C:/WAMP/apache2/conf/extra/httpd-vhosts.conf';
$wampserverini_file = '../wampmanager.ini';
$conffile_dir = 'C:/WAMP/apache2/conf/subdomains/';
$hosts = 'C:/Windows/system32/drivers/etc/hosts';



delete_subdomain.php
[www.btt-scripts.com]

Edit these lines to your installation
$conffile_dir = 'C:/WAMP/apache2/conf/subdomains/';
$wampserverini_file = '../wampmanager.ini';
$httpdconf_file = 'C:/WAMP/apache2/conf/extra/httpd-vhosts.conf';
$hosts = 'C:/Windows/system32/drivers/etc/hosts';



Or get both in a zip file.
[www.btt-scripts.com]



Post Edited (04-11-07 16:58)

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: ranger1952 (---.dyn.optonline.net)
Date: April 19, 2007 05:42PM

I have followed the directions above (I think) which were generously provided by fastburst, but when I try to restart Wamp, I get the following message:
The configuration file contains a syntax error on line 78:
[EParseError]Unrecognized [Menu.*.Settings] Section directive "Type:separator; Caption:"Localhost Subdomains""

What did I do wrong and how do I solve? Thanks in advance!
And thank you all for the fine work you do to help us.

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: ranger1952 (---.dyn.optonline.net)
Date: April 19, 2007 05:49PM

Addendum to above post. Here is how lines 78-78 appear in C:\wamp\wampmanager.ini

Type: separator; Caption: "Localhost Subdomains"
Type: submenu; Caption: "Subdomain directories"; SubMenu: subdomain_dir; Glyph: 3

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: fastburst (---.tc.ph.cox.net)
Date: April 20, 2007 12:02AM


[Menu.Left] <<<< Look for this

Once you find this then add this somewhere to it

Type: separator; Caption: "Localhost Subdomains"
Type: submenu; Caption: "Subdomain directories"; SubMenu: subdomain_dir; Glyph: 3

Here is mine below (keep in mind has stats and switch php 4 as well


[Menu.Left]
Type: separator; Caption: "WAMP5"
Type: item; Caption: "Localhost"; Action: run; FileName: "C:\Program Files\Internet Explorer\iexplore.exe"; Parameters: "[localhost];; Glyph: 5
Type: item; Caption: "phpMyAdmin"; Action: run; FileName: "C:\Program Files\Internet Explorer\iexplore.exe"; Parameters: "[localhost];; Glyph: 5
Type: item; Caption: "SQLiteManager"; Action: run; FileName: "C:\Program Files\Internet Explorer\iexplore.exe"; Parameters: "[localhost];; Glyph: 5
Type: item; Caption: "www directory"; Action: shellexecute; FileName: "G:/work/www"; Glyph: 2
Type: submenu; Caption: "Log files"; SubMenu: log_files; Glyph: 3
Type: submenu; Caption: "Config files"; SubMenu: conf_files; Glyph: 3
Type: submenu; Caption: "Apache modules"; SubMenu: apache_mod; Glyph: 3
Type: submenu; Caption: "PHP settings"; SubMenu: php_params; Glyph: 3
Type: submenu; Caption: "Alias directories"; SubMenu: alias_dir; Glyph: 3
Type: item; Caption: "Switch to PHP4"; Action: multi; Actions: Switch;Glyph : 1
Type: separator; Caption: "Localhost Subdomains"
Type: submenu; Caption: "Subdomain directories"; SubMenu: subdomain_dir; Glyph: 3
Type: separator; Caption: "Statistics"
Type: item; Caption: "Generate statistics"; Action: shellexecute; FileName: "G:/WAMP/webalizer/webalizer.bat";WorkingDir: "G:/WAMP/webalizer";Glyph: 1
Type: item; Caption: "Statistics page"; Action: run; FileName: "explorer.exe"; Parameters: "[localhost];; Glyph: 5
Type: separator; Caption: "Services"
Type: servicesubmenu; Caption: "Apache"; Service: wampapache; SubMenu: apache
Type: servicesubmenu; Caption: "MySQL"; Service: wampmysqld; SubMenu: MySql
Type: item; Caption: "Start All Services"; Action: multi; Actions: StartAll
Type: item; Caption: "Stop All Services"; Action: multi; Actions: StopAll
Type: item; Caption: "Restart All Services"; Action: multi; Actions: RestartAll
Type: item; Caption: "Put Offline"; Action: multi; Actions: onlineoffline

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: Alxandr (---.bb.online.no)
Date: June 18, 2007 05:14PM

I can't make this "tutorial" work... I've done everything as said above... But it still dosn't work... And one more thing... When i enabled the 'vhost_alias_module' there were no 'httpd-vhost.conf' file so i just created an directory inside 'conf' named extra (saw that was the path you guys used) and created an empty file named 'httpd-vhost.conf'... I created a subdomain named home, and now if i type home.localhost or just home in the browser i just get the standar wamp-page (http://localhost)... How can i fix this? Pleas help...

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: yfastud (72.236.169.---)
Date: June 18, 2007 06:13PM

If you're using wamp version 1.6.6 or before, you won't have that folder as well as httpd-vhosts.conf, and you must modify the correct path associated w/ your version for this setup works, and remember this is for LOCAL (sub)domains only, so if you want to have both global and local, you have to modify more to meet your needs.

Have fun,





Post Edited (06-18-07 18:17)

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: Subdomains for Localhost Guide
Posted by: CyberSpatium (71.237.217.---)
Date: June 18, 2007 07:50PM

follow the tutorial in my manual.


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

Need help? Check out my WAMP User Manual/Guide here!


Cellular Phone Deals - The Best on the Net! - FREE PHONES! Take your pick from our featured cellular phone deals by Cingular, Verizon, T-Mobile, Sprint PCS, Nextel, and more! Most of our cellular phone offers include a FREE cellular phone with FREE shipping!


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.


Mortgage and Home Loan Advice:
Clarify Loans

Options: ReplyQuote


Sorry, only registered users may post in this forum.