News:

This week IPhone 15 Pro winner is karn
You can be too a winner! Become the top poster of the week and win valuable prizes.  More details are You are not allowed to view links. Register or Login 

Main Menu

How to Configure Apache Server to share documents from the folder.

Started by Sunite, November 05, 2007, 09:29:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sunite

How to Configure Apache Server to share documents from the folder.

Say you want to make your music collection downloadable using your new web server, and all your music files are located in C:\My Music. Using a plain text editor like Notepad, open the C:\Program Files\Apache Group\Apache2\conf\httpd.conf file. This is Apache's configuration file, which looks long and scary, but most of the defaults will work just fine for us. We just have to change a few things.

   

In this httpd.conf file, comment out the line that starts with DocumentRoot and add another with your directory, like this:

#DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"DocumentRoot "C:/Gina/My Music"Then, comment out the line that starts with <Directory "C:/Program... and add another with your directory, like this:

#<Directory "C:/Program Files/Apache Group/Apache2/htdocs"><Directory "C:/Gina/My Music">Last, about 20 lines below that <Directory line, there is a line that reads:

AllowOverride NoneChange it to:

AllowOverride AllWhen you're done, save httpd.conf. Then, click on the Apache icon in your taskbar and choose "Restart." If Apache restarts successfully, you edited your the file correctly. Visit You are not allowed to view links. Register or Login in your web browser. This time you should see a listing of your music files.

Password your web site documents.

But we don't want just anyone to be able to download your music. Your bandwidth is precious, and we want to secure things a bit. Let's create a password prompt.

First, open a command prompt (go to the Start menu, choose Run, then type cmd.) Change to the Apache bin directory by typing:

cd "C:\Program Files\Apache Group\Apache2\bin"Then create a password file by typing:

htpasswd -c C:\song\my_password_file song

Replace the path with the path of your new password file (which should in any folder EXCEPT the web server's document root.) Replace song with the username you want to use. When prompted, enter the password you want to set up. Once you've done that, a password file will be created.

Now we want to apply that login to your music directory. Open up a new file in a plain text editor like Notepad. Copy and paste the following into it:

AuthType Basic AuthName "This is a private area, please log in"  AuthUserFile c:\Gina\my_password_file AuthGroupFile /dev/null  <Limit GET POST PUT> require valid-user </Limit> Make sure you replace C:\Gina\my_password_file in the text with your own password file created above. Save this new file IN YOUR WEB SERVER DOCUMENT ROOT (in this case, C:\Gina\My Music) and name it .htaccess. Don't forget the dot in the beginning, before .htaccess. So, in this case, we're saving the file as C:\Gina\My Music\ .htaccess.

Note: If you're using Notepad to create your .htaccess file, when you save the file, put quotes around the filename - ".htaccess" - so that Notepad doesn't automatically put a .txt extension on the file. If there's a .txt file extension, your password won't work!

Now, using your web browser, go to You are not allowed to view links. Register or Login. You should be prompted to log in. Enter your username and password you set up in your password file.