Is it possible to configure xampp to serve up a file outside of the htdocs
directory?
For instance, say I have a file located as follows:
C:\projects\transitCalculator\trunk\TransitCalculator.php
and my xampp files are normally served out from:
C:\xampp\htdocs\
(because that's the default configuration) Is there some way to make Apache recognize and serve up my TransitCalculator.php
file without moving it under htdocs
? Preferably I'd like Apache to serve up/have access to the entire contents of the projects directory, and I don't want to move the projects directory under htdocs
.
edit: edited to add Apache to the question title to make Q/A more "searchable"
Edit the “DocumentRoot” line to the location of the remote \htdocs folder. Edit the “Directory” tag to the same remote location you set for DocumentRoot. Save the file and restart your local Apache server. Navigate to your "localhost” in your browser and you should see the remote web site files.
Remember to always save your files and folders in htdocs (full path is C:\xampp\htdocs\ ). You will also need to launch the file via a url (e.g.: http://localhost/myphpfile.php ) in the browser address bar, not by double-clicking an icon or via the File Open menu option. In each of the two latter cases, the .
In the xampp PHP server, files are served by default from c:/xampp/htdocs directory. There are times when the need may arise for you to serve your PHP project from directories outside of the /htdocs folder eg directly from an external E:/ drive or any other directory on your computer.
Ok, per pix0r's, Sparks' and Dave's answers it looks like there are three ways to do this:
NameVirtualHost *:80
).Add your virtual host (~line 36):
<VirtualHost *:80> DocumentRoot C:\Projects\transitCalculator\trunk ServerName transitcalculator.localhost <Directory C:\Projects\transitCalculator\trunk> Order allow,deny Allow from all </Directory> </VirtualHost>
Open your hosts file (C:\Windows\System32\drivers\etc\hosts).
Add
127.0.0.1 transitcalculator.localhost #transitCalculator
to the end of the file (before the Spybot - Search & Destroy stuff if you have that installed).
Now you can access that directory by browsing to http://transitcalculator.localhost/.
Starting ~line 200 of your http.conf
file, copy everything between <Directory "C:/xampp/htdocs">
and </Directory>
(~line 232) and paste it immediately below with C:/xampp/htdocs
replaced with your desired directory (in this case C:/Projects
) to give your server the correct permissions for the new directory.
Find the <IfModule alias_module></IfModule>
section (~line 300) and add
Alias /transitCalculator "C:/Projects/transitCalculator/trunk"
(or whatever is relevant to your desires) below the Alias
comment block, inside the module tags.
Edit ~line 176 in C:\xampp\apache\conf\httpd.conf; change DocumentRoot "C:/xampp/htdocs"
to #DocumentRoot "C:/Projects"
(or whatever you want).
Edit ~line 203 to match your new location (in this case C:/Projects
).
Notes:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With