# How hosting files with Apache [ Solved ]

## lcoulon

Hello,

I need to host a list of files and let them avalaible from Internet when browsing from htpp://myaddress

For some of them i need to let people anonymous access and some others placed in a restrited area as a login & password will be resquested to access to the files ?

Can anyone explain me how to do, i'm very novice with Apache 2.

The only thing i know is that "htpasswd" needs to be generated  ...

Help will be much appreciated.Last edited by lcoulon on Sat Mar 12, 2005 2:52 pm; edited 1 time in total

----------

## omnicloud

For the anonymous, just put them into a directory. For the passworded, I recommend you get some type of PHP portal and use MySQL or even a flat database file unless you just want to add a single user and give out the password to everyone. The PHP can create new users on the database , send out the email with a confirmation link if you want,  you can add users easily, and it's more secure.

----------

## Genone

no need for a complicated and maybe insecure PHP setup, just use the builtin apache authentication as desribed in http://httpd.apache.org/docs-2.0/howto/auth.html

----------

## lcoulon

Thanks Genone.

I have now the var/www/localhost/htdocs secured by logon / password.

( i have created .HTACCESS & .HTPASSWD files )

Then i have put all the files i want to share into var/www/localhost/htdocs folder.

However when browsing the page, i get identification window working fine but next i get this message :  :Shocked: 

403  Forbidden

You don't have permission to access / on this server.

Apache/2.0.52 (Gentoo/Linux) Server at 127.0.0.1 Port 80 

I need to get files list on the screen instead of 403 Error ...

I have of course no html files into the folder as i only want to host files for download.

Thanks for help.

----------

## Genone

Well, you've done something wrong with the config or the file permissions then, hard to say without more information.

----------

## lcoulon

Here is attached contents of my .HTACCESS located in /var/www/locahost/htdocs:

```
SetEnvIfNoCase Request_URI \.ht(access|passwd)$ ban

<Files ~ "^.*$">

order allow,deny

allow from all

deny from env=ban

</Files>

Authname "Zone est restreinte:"

AuthUserFile /var/www/localhost/.htpasswd

AuthGroupFile /dev/null

AuthType Basic

<limit GET POST>

require valid-user

</limit>
```

And this is .HTPASSWD that is located in  /var/www/localhost/ :

```

lcoulon:xxxxxxxxxxx 
```

Thanks for your help.

----------

## Genone

looks good at a first glance. One other thing to check: are directory listings actually enabled?

----------

## lcoulon

i don't know really as i'm very newbie with Apache, would you please tell me where i should enable this option ?

----------

## Genone

Being a newbie is no excuse for not looking for docs  :Wink: 

http://httpd.apache.org/docs-2.0/mod/core.html#options

----------

## lcoulon

I have found that i should have to add something like that :

```
<Directory /usr/local/httpd/htdocs> 

Options Indexes FollowSymLinks 

</Directory> 
```

I added these lines in my /etc/apache2/conf/apache2.conf

Then when i try again to browse my address (no index.html) Internet Explorer still not able to list files available inside the folder.

I still getting 403 Error ...

These screens showing how i tried to enable file list from Webmin , please have a check if what i done is correct :

http://membres.lycos.fr/lcoulon1/Gentoo/screen.jpg

http://membres.lycos.fr/lcoulon1/Gentoo/screen1.jpg

Thanks for you help.

----------

## lcoulon

Can anybody help me regarding that problem ?

----------

## Genone

 *Quote:*   

> Then i have put all the files i want to share into /var/www/localhost/htdocs folder. 

 

 *Quote:*   

> I have found that i should have to add something like that :
> 
> ```
> <Directory /usr/local/httpd/htdocs>
> 
> ...

 

You see the problem?

----------

## R0Bzombie

put this in your /etc/apache2/conf/commonapache2.conf

```
 <Directory "put the path of the folder you want to list">

     AllowOverride FileInfo AuthConfig Limit

     Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

     <Limit GET POST OPTIONS PROPFIND>

         Order allow,deny

         Allow from all

     </Limit>

     <LimitExcept GET POST OPTIONS PROPFIND>

         Order deny,allow

         Deny from all

     </LimitExcept>

 </Directory>
```

----------

## lcoulon

Thank you very much R0Bzombie , it works fine !

Would you please tell me what are options needed to be changed in Webmin to get those lines in /etc/apache2/conf/commonapache2.conf

Just to know where finding these settings in Webmin ...

Thanks again for your help!  :Very Happy: 

----------

## R0Bzombie

lol a friend told me to do this and it worked and now I tell you and it's working  :Very Happy:   don't ask me how I found this, I didn't found it

I don't even know what is webmin  :Wink: 

----------

## lcoulon

No problem, anyway thanks for friend for me !  :Very Happy: 

----------

