Getting access to var/www

22,994

Solution 1

First of all, had you install a server as lampp? Is you did, the files sould be at some place as /opt/lampp/htdocs.

Assuming that the htdocs directory is on /var/www, you could change the permissions like this (in a Terminal, open it by searching Terminal on the Dash):

sudo chmod -R 777 /var/www
sudo chown -R **yourusername** /var/www

You must change yourusername with the username you entered in the installing process.

I hope it works to you!

Solution 2

First of all, you can see the permission of /var/www has, by this command ls -l /var/www. You will see like this (this only for example):

drwxr--r--  7 www-data www-data  4096 Jun 21 10:53 CodeIgniter
drwxr--r-- 11 www-data www-data  4096 Oct  2 19:49 eAdministration

drwxr-sr-x is permission status and www-data www-data is ownership status. By default, when you installed for first time, ownership status is www-data www-data. The thing that you should do, add your username belongs to www-data group by this command:

sudo adduser yourusername www-data

After that, you should change the ownership to your username:

sudo chown yourusername:www-data -R /var/www

It will result in:

drwxr--r--  7 yourusername www-data  4096 Jun 21 10:53 CodeIgniter
drwxr--r-- 11 yourusername www-data  4096 Oct  2 19:49 eAdministration

Then, you should change permission to 755 (rwxr-xr-x) for directories, 644 (rw-r--r--) for files, and I do not recommend to change permission to 777 (rwxrwxrwx). As suggestion from temoto to make easier to be understand, you can do this:

sudo find /var/www -type d -print0 | sudo xargs -0 chmod u=rwX,go=rX
sudo find /var/www -type d -print0 | sudo xargs -0 chmod u=rw,go=r

OR

sudo find /var/www -type d -print0 | sudo xargs -0 chmod 0755
sudo find /var/www -type f -print0 | sudo xargs -0 chmod 0644

To ensure that setting has been running well, you can try php code in /var/www.

Share:
22,994

Related videos on Youtube

Matt Jones
Author by

Matt Jones

Updated on September 18, 2022

Comments

  • Matt Jones
    Matt Jones over 1 year

    I'm building an html email template and need to remove the spacing between table rows, but need to keep the cellspacing at 10px. You will see in the example blue title bars and the spacing beneath them. Is there any way to isolate those table rows using CSS and remove this?

    HTML: http://www.tailwatersflyfishing.com/email/template/new.html

    • DreamTeK
      DreamTeK over 10 years
      Your example is not very clear however I would recommend you remove cell spacing from table and separate tables using css margin and padding.
  • gertvdijk
    gertvdijk over 11 years
    -1 for chmoding to 777. Not necessary and also makes file appearing as executables. Hard to revert it.
  • Viktor
    Viktor over 11 years
    As I guess you know more about Ubuntu then me, I assume I made the installation wrong. I followed a guide so I guessed it would work. Could you guide me though uninstall and reinstall? or give suggestion guide? Thanks!
  • Addison Montgomery
    Addison Montgomery over 11 years
    Did you install any software for the HTTP server such as Apache, LAMPP (XAMPP) or anything like that? I think that Ubuntu Desktop hasn't any server installed by default, so if you installed something, please tell me and i'll be glad to help you. Else, if you had not installed anything, I'm sure that someone could help you to do it :)
  • gertvdijk
    gertvdijk almost 11 years
    With setting 755 recursively, all files will be set as executable. You don't want that, really.
  • kevinius
    kevinius over 10 years
    If you are targeting a wide range of email clients, then the only option here is to use tables for layout purposes...
  • Chad
    Chad over 10 years
    Ah yea, I've never designed for email. Regardless, there's still a fix in there :)
  • temoto
    temoto about 8 years
    Nowadays chmod recognise X permission as x for directories and empty for files. It's possible to run find /var/www -print0 |xargs -0 chmod u=rwX,go=rX. With added benefit of easier to understand permissions.
  • Peter Krauss
    Peter Krauss about 7 years
    ERROR, no permission for my user (that was in adduser suggested), at /var/www/html I can not do cat > test.txt even with sudo! (I used last options of sudo find etc also)
  • 5d41402abc4
    5d41402abc4 about 7 years
    First, could you try to find what groups are your user belongs to? Try to type groups <username>
  • AntonK
    AntonK almost 6 years
    There is a typo in sudo find /var/www -type d -print0 | sudo xargs -0 chmod u=rw,go=r, which will list directories (-type d) instead of files (-type f).