How can I test files outside htdocs?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How can I test files outside htdocs?

Postby erdinc » 12. December 2009 00:00

Hi,

If I install C:\Program Files, is there any way I can test my php files without moving them inside htdocs folder? I would rather leave the files here:

D:\Documents\My Webs\website_one\index.php

Would this create a security risk?

Thanks
Erdinç
erdinc
 
Posts: 4
Joined: 11. December 2009 23:41

Re: How can I test files outside htdocs?

Postby Izzy » 12. December 2009 00:09

You can configure the \xampp\apache\conf\extra\httpd-userdir.conf file for this purpose.

Just follow the example included and change it to suit your needs but make a copy of the original first.

After editing, save the file and restart Apache.

If Apache won't start after editing then read the \xampp\apache\logs\error.log file.

http://localhost/~user - being your PC logged on username - Read the file's comments.

You could also use an Alias directive in the httpd-xampp.conf file or create a VirtualHost in the httpd-vhosts.conf file - all these methods allow file and folders outside of the default DocumentRoot to be accessed.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: How can I test files outside htdocs?

Postby erdinc » 12. December 2009 00:49

Izzy,

Thank you very much for your answer. This is one of the very difficult tasks for me. I understand absolutely nothing and spend hours to do something simple. Unfortunately again I couldn't get this right.

edit: I removed long, unnecessary message to prevent confusion in case other newbies read this. Solution is below with alias. Thanks to Izzy.
Last edited by erdinc on 12. December 2009 01:59, edited 1 time in total.
erdinc
 
Posts: 4
Joined: 11. December 2009 23:41

Re: How can I test files outside htdocs?

Postby Izzy » 12. December 2009 01:38

First put things back to the originals in the httpd-userdir.conf file.

Next stop Apache

To get the user directory module working open httpd-conf file in your text editor and find this line:
#LoadModule userdir_module modules/mod_userdir.so

Change it so it looks like this:
LoadModule userdir_module modules/mod_userdir.so

Save the file and start Apache to make sure your edits are working.

BTW you can't use the user directory configuration in httpd-userdir.conf file unless your files are located under PC logged in user's directory - usually C:/Documents and Settings/username/My Documents/ etc. and is what this feature is all about.

So if you want to use D:\Docs\My Webs folder then perhaps an Alias directive in the httpd-xampp.conf file may be the way to go - add this after the Webalizer entry like so
Code: Select all
Alias /mywebs "D:/Docs/My Webs/"
<Directory "D:/Docs/My Webs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Save the file and start Apache again.

http://localhost/mywebs should load an index file if located in the D:\Docs\My Webs\ folder.
http://localhost/mywebs/firstwebsite/ should load an index file located in the D:\Docs\My Webs\firstwebsite\ folder.

Tip before you start - Apache doesn't like spaces in file or folder names so rename those files and folders so they are without spaces and make them all lower case as Apache is case sensitive unlike Windows.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: How can I test files outside htdocs?

Postby erdinc » 12. December 2009 02:14

Izzy,

Thank you very much. You made my day. I am so relieved I managed to get this work.
I hope this doesn't cause a security issue on my computer. I don't want others to access my files.

To other beginners: (extra explanation for dummies like me)
Step one
Like Izzy says you put the above code after the Webalizer entry. This means :

1. Find this file inside your xampp folder: \xampp\apache\conf\extra\httpd-xampp.conf
2. open it with notepad and scroll down
3. You will see the webalizer entry like this:
Code: Select all
  Alias /webalizer "D:/xampplite/webalizer/"
    <Directory ...
    </Directory>

4. Under it add the code above.

Step two
Put any index.php file with something in it to the my webs folder and try to access it from your browser like Izzy said here:
http://localhost/mywebs should load an index file if located in the D:\Docs\My Webs\ folder.


Step three
If that works now you can set dreamweaver to use the correct paths.
1. In dreamweaver 8, I go to (from top menu) site/manage sites and then chose the site name and click edit.
2. On the window that appears switch to advanced tab and on left menu choose "test server".
3. Change server mode to "php mysql", access to "local network"
Then change "testing server folder" to D:\Docs\My Webs\sitenamewhatever\
and change url prefix to http://localhost/mywebs/sitenamewhatever/

Now in dreamweaver you can press F12 and it will open the PHP file locally in your browser.

Izzy,
Thank you very much again. I am very glad I came to this forum. I just opened an account to start this thread and I'm very impressed how helpfull people here are.

Cheers
Erdinç
erdinc
 
Posts: 4
Joined: 11. December 2009 23:41

Re: How can I test files outside htdocs?

Postby Izzy » 12. December 2009 02:34

erdinc wrote:I hope this doesn't cause a security issue on my computer. I don't want others to access my files.
If you don't want to give access to others, only you on localhost then change the permissions like so
Code: Select all
Alias /mywebs "D:/Docs/My Webs/"
<Directory "D:/Docs/My Webs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Deny from all
Allow from localhost
</Directory>
Save and restart Apache, then make sure you can still access via localhost.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: How can I test files outside htdocs?

Postby erdinc » 12. December 2009 02:41

Yes, it still works perfectly after that change. Thank you.

Erdinç
erdinc
 
Posts: 4
Joined: 11. December 2009 23:41


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 26 guests