Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

Very, very new user to Ubuntu and I've been searching for a long time without finding an answer. Probably I've gotten the answer but I don't understand it all that very well so I thought I try this instead. My problem is that I don't have a permission to the var/www folder that I assume is where my "localhost" should be. I don't know how to change the permission so I can change files and add. Nether am I sure if I want to. MY intentions are only to be available to view PHP in my browser. If anyone know how I can change my permissions or how I can view PHP else way I'll be very happy.

Running Ubuntu 12.04.

Thanks!

P.S. As I said I'm very new so please take it slow :)

share|improve this question

marked as duplicate by gertvdijk, Kevin Bowen, Radu Rădeanu, Basharat Sialvi, Eric Carvalho Jun 25 '13 at 9:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 3 down vote accepted

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!

share|improve this answer
2  
-1 for chmoding to 777. Not necessary and also makes file appearing as executables. Hard to revert it. –  gertvdijk Sep 16 '12 at 11:49
    
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! –  Viktor Sep 16 '12 at 16:08
    
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 :) –  Addison Montgomery Sep 16 '12 at 16:34

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 for directories, 644 for files, and I do not recommend to change permission to 777

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|improve this answer
    
With setting 755 recursively, all files will be set as executable. You don't want that, really. –  gertvdijk Jun 24 '13 at 21:41
    
Thank's for gertvdijk correction, I have edited. –  metamorph Nov 8 '13 at 14:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.