One thing I wanted is the ability to share directories online other then having to make folders in my WebServ folder. So off I went to look up how to configure Apache to do this. As I expected this was not all that hard to do, you just have to add a few lines to the apache config file.
Just type " sudo vi /etc/httpd/httpd.conf " or use what ever editor you like, I like VI. then look for the section below...
#
# Aliases: Add here as many aliases as you need (with no limit). The format is
# Alias fakename realname
#
<IfModule mod_alias.c>
Find place you like to put the info for your new shared directory, and add the lines below. The #"stuff" lines are optional, but it is a good idea to comment about what you are adding.
#Share via online
Alias /NAME OF SHARE "/PATH TO DIRECTORY/"
<Directory "/PATH TO DIRECTORY/">
Options Indexes FolowSymLinks MultViews ExecCGI
Order allow,deny
Allow from all
</Directory>
This will set up a new directory that you can access with http:/serveraddress/name of share. This worked quite well, however I still wanted to take it a step further. I could make a php index page that prevented access, however that would not give me quite the level of security that I wanted. Instead I looked for a way to secure a directory with Apache. First of you need to change the directory set up by setting it to...
<Directory "/PATH TO DIRECTORY/">
Options Indexes MultiViews (+ other things you want)
AllowOverride All
</Directory>
This make it look for a .htaccess file that specifies the access rules for the directory. You will now need to add this file to the directory you are sharing. In that file you need to add these lines.
AuthName "Name of Stuff Share"
AuthType Basic
AuthUserFile /PATH TO PASSWORD DIRECTORY/.htpasswd
AuthGroupFile /dev/null
require user ADD USERNAME
This sets up the directory, the last thing you need to to add a password file for it to reference to.
To do this, cd to the password directory you used above. Then type htpasswd -c .htpasswd "USER NAME" this will add a password file to the directory for the use name.
There you have it a new directory in Apache which requires a password to access.
1 comment:
Not to be the guy commenting on code but the code for setting up a directory in Apache does not bode well on a win32 system
#Share via online
Alias /NAME OF SHARE "/PATH TO DIRECTORY/"
Directory "/PATH TO DIRECTORY/">
Options Indexes FollowSymLinks MultiViews ExecCGI
Order allow,deny
Allow from all
/Directory"
the bolded section is what I fixed
Post a Comment