Apache on different directory
Posted by: austenr (---.hsd1.ma.comcast.net)
Date: June 23, 2007 02:14AM

I am needing to configure Apache to do the following:

I installed the server in C:/wamp/www by default. Now I need to point PHP pages from other drives to it. How do you configure the server so that the pages on say the F: drive can access the data in my mySQL DB's? Thanks

Options: ReplyQuote
Re: Apache on different directory
Posted by: CyberSpatium (71.237.217.---)
Date: June 23, 2007 11:52AM

all your php files need to be in one location. you can setup virtuahost to allow you to run php scripts from multiple locations. if you have a domain name, then see the virtualhost section of my manual. if you do not have a domain name then you can just use different ports instead of domain names

http://httpd.apache.org/docs/2.0/vhosts/examples.html#port

the way apache is setup to use port 80. and when you access apache, it severs files from c:\wamp\www. we are going to add another port for apache to use. when you use that new port, apache will serve files out of your f:\ drive.

open httpd.conf (c:\wamp\apache2\conf\httpd.conf ) and find:
Listen 80

below that add:
Listen 8080

then find this line:
#Include conf/extra/httpd-manual.conf

remove the pound sign ( # ) in front to enable this setting. change it to:
Include conf/extra/httpd-manual.conf

now open httpd-manual.conf (c:\wamp\apache2\conf\extra\#Include conf/extra/httpd-manual.conf ) and find:
#NameVirtualHost

change it to this:
NameVirtualHost *80
NameVirtualHost *:8080


then below the NameVirtualHost setting add these line:

<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp\www
</VirtualHost>

<VirtualHost *:8080>
ServerName localhost
DocumentRoot F:/Your/Folder/Here
</VirtualHost>


now, change the F:/Your/Folder/Here above to what folder on your f:\ drive you want to use for your php files.

now save all the files you just edited and restart apache for the new setting to take effect.

so, to now access php files in the default wamp directory c:\wamp\www use:
http://localhost

to access the php files now located on your f:\ drive use:
http://localhost:8080



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
Re: Apache on different directory
Posted by: austenr (155.41.112.---)
Date: June 25, 2007 05:54PM

I tried to follow your directions. When I opened the httpd-manual.conf file I was unable to find #Name VirtualHost. I did however find it in C:\wamp\Apache2\conf\extra\httpd-vhosts.

I decided to change the contents to the following:

#
# 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
NamevirtualHost *:8080
#
# 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.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.localhost
DocumentRoot C:/wamp\www
ServerName localhost
ServerAlias www.dummy-host.localhost
ErrorLog logs/dummy-host.localhost-error_log
CustomLog logs/dummy-host.localhost-access_log common
</VirtualHost>

<VirtualHost *:8080>
ServerAdmin webmaster@dummy-host2.localhost
DocumentRoot z:
ServerName localhost
ErrorLog logs/dummy-host2.localhost-error_log
CustomLog logs/dummy-host2.localhost-access_log common
</VirtualHost>

which when I try to locate the file like this [localhost], the file that opens is the one in C:/wanp\www.

Im confused.



Post Edited (06-25-07 17:55)

Options: ReplyQuote
Re: Apache on different directory
Posted by: krusher_00 (---.accessplus.com.au)
Date: June 27, 2007 09:17AM

Try this (keep it simple for starters)

<VirtualHost *:80>
DocumentRoot C:/wamp/www
ServerName localhost
</VirtualHost>

<VirtualHost *:8080>
DocumentRoot Z:/
ServerName localhost
</VirtualHost>

Save this in the httpd-vhosts file, make sure the httpd.conf file has a line in it that says
Include "C:/wamp/apache2/conf/extra/httpd-vhosts.conf"

then save and restart the apache service (via the wamp icon)

Options: ReplyQuote


Sorry, only registered users may post in this forum.