0

How can i get access to files in hostname/var/www/folder? I get an error saying not found - the requested URL /phpfiler(my created folder) was not found on this server?

  • 2
    What exactly are you doing to access the folder? – pLumo Feb 12 '18 at 15:06
  • If you are using 14.04 or newer, you should put your folder in /var/www/html and not /var/www. https://askubuntu.com/q/448944/8698 – Dan Feb 12 '18 at 18:07
  • Could you please add a little more detail? What exactly did you do, what did you expect to happen and what happened instead? Did you encounter any warning or error messages? Please reproduce them in their entirety in your question. You can select, copy and paste terminal content and most dialogue messages in Ubuntu. Please [edit] your post to add information instead of posting a comment. (see How do I ask a good question?) – David Foerster Feb 16 '18 at 13:45

2 Answers2

1

Establish a [folder] at /var/www

Change the directory owner and group:

sudo chown www-data:www-data /var/www/[folder]

Allow the group to write to the directory with appropriate permissions:

sudo chmod -R 775 /var/www

Add yourself to the www-data group:

sudo usermod -a -G www-data [user]
An0n
  • 2,119
  • Hi, I tried it but, i do not get access from the localhost/var/www/filer website. What could be the error here? –  Feb 16 '18 at 11:31
0

Instead of adding yourself to a system group as suggested here I would recommend to just set your file ownerships to

 sudo chown <yourUser>:www-data -R /var/www

On this way you can set different permissions for your user and www-data on any file (or again on everything within a certain folder using -R as before):

The permissions you can set are

  • w write
  • r read
  • x execute (also needed to access folders)

A + grants the permission, a - revokes it.

=> So

  • to set your users' permissions on a file e.g.

    sudo chmod u+wr /path/to/file
    
  • to set www-data's permissions on a file e.g. only read permission

    sudo chmod g+r /path/to/file
    sudo chmod g-wx /path/to/file
    

The same methods also apply to folders so to allow the www-data group to write into a folder:

sudo chmod g+w /path/to/folder

and if you want also to be able to write to any file within that folder

sudo chmod g+w -R /path/to/folder

For accessing folders different from /var/www/html you'll have to add a redirection.

I'll quote from here (they did it for something in /home)

If you are using apache you'll have to create an alias that makes that images accesible via the web server.

Here comes an example for apache2

  Alias /img /home/path/to/images
  <Directory "/home/path/to/images">
     Order allow,deny
     Allow from all
  </Directory>

Place this configuration snippet in the proper place of your apache installation e.g. end of httpd.conf or a separate file. Don't forget to restart your webserver.

Now you should be able to access the images like:

<img style="vertical-align:bottom" src="http://www.myserver.com/img/buy_button.png"border="0" />
derHugo
  • 3,356
  • 5
  • 31
  • 51