logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Password for Apache 2.2 in windows 7(x86)program file. Help!
Author
ob1kenobi



Joined: 05 May 2010
Posts: 3

PostPosted: Wed 05 May '10 3:32    Post subject: Password for Apache 2.2 in windows 7(x86)program file. Help! Reply with quote

Hi, I'm following these steps below but can't configure the password for the server. I'm on windows 7 64 bit.

The address of the file I'm trying to use in command promt is

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin

but it doesn't recognise this as an internal or external command, operable program or batch file.

What am I doing wrong???







Step 3. 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 Software Foundation\Apache2.2\bin"

Then create a password file by typing:

htpasswd -c "C:\Documents and Settings\Gina\my_password_file.txt" gina

Replace the path with the path of your new password file (which should in any folder EXCEPT the web server's document root.) Replace gina 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:\Documents and Settings\Gina\my_password_file.txt"
AuthGroupFile /dev/null

<Limit GET POST PUT>
require valid-user
</Limit>

Make sure you replace "C:\Documents and Settings\Gina\my_password_file.txt" 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 http://localhost/. You should be prompted to log in. Enter your username and password you set up in your password file. Rock!

Step 4. Congratulate yourself. You've got a home webserver running.

If you are NOT behind a firewall, you can access your web server from other computers by typing your computer's IP address into a web browser's address bar. If you're not sure what your IP is, visit What Is My IP to find out. If your IP is 12.34.567.890, then type http://12.34.567.890 into a browser's address bar. [7]

If you ARE behind a firewall (like a wireless router), you'll need to open up port 80 on the firewall and forward it to your computer. This part is beyond the scope of this article, but will be covered in a future Lifehacker feature is covered in Lifehacker feature How to access a home server behind a firewall.
Back to top
wm003



Joined: 24 Mar 2006
Posts: 88

PostPosted: Wed 05 May '10 6:57    Post subject: Reply with quote

your path contains spaces so check if the path has been set in quotes
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 05 May '10 11:42    Post subject: Reply with quote

The path is not correct Wink On Win 7 "Documents and Settings" is an alias for Users.So the correct path in the httpd.conf is
Code:

AuthUserFile "c:\Users\Gina\my_password_file.txt"


There is no /dev/null on Windows. That's linux / unix stuff. Delete that line. Also it makes no sence since you don't use any groupds.
Back to top
ob1kenobi



Joined: 05 May 2010
Posts: 3

PostPosted: Wed 05 May '10 13:41    Post subject: Reply with quote

hi,

Thanks.

the part i'm struggling with is the

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin


This is what i think allows me to change the password but I can't get it to open in command promt. As it "is not an internal or external command, operable program or batch file."

any suggestions.?

[/i]
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 05 May '10 21:31    Post subject: Reply with quote

For me it works to change the directory to the x86 program files

Code:

C:\Windows\System32>C:\Program Files (x86)

C:\Program Files (x86)>


I haven't installed apache on that path so I can't try. An idea is to put that path into %PATH% env variable. Like on http://www.question-defense.com/wp-content/uploads/2010/01/windows-7-environment-variables.gif
Than you can call the htpasswd without the path.
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Thu 06 May '10 21:44    Post subject: Reply with quote

ob1kenobi wrote:
hi,



C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin


This is what i think allows me to change the password but I can't get it to open in command promt. As it "is not an internal or external command, operable program or batch file."


No, that is where you want to be at

So when you open up that command prompt window,

cd\program files (x86)\Apache Software Foundation\Apache2.2\bin

Now, you should be at that location ... then try htpasswd


Code:
C:\Users\yourname>cd\Program files (x86)\Apache Software Foundation\Apache2.2\bin

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin>htpasswd
Usage:
        htpasswd [-cmdpsD] passwordfile username
        htpasswd -b[cmdpsD] passwordfile username password

        htpasswd -n[mdps] username
        htpasswd -nb[mdps] username password
 -c  Create a new file.
 -n  Don't update file; display results on stdout.
 -m  Force MD5 encryption of the password (default).
 -d  Force CRYPT encryption of the password.
 -p  Do not encrypt the password (plaintext).
 -s  Force SHA encryption of the password.
 -b  Use the password from the command line rather than prompting for it.
 -D  Delete the specified user.
On Windows, NetWare and TPF systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin>
Back to top


Reply to topic   Topic: Password for Apache 2.2 in windows 7(x86)program file. Help! View previous topic :: View next topic
Post new topic   Forum Index -> Apache