0

I want to move my web content from Window 7 to Ubuntu 12.04. So I copy my web content and move it to my /opt/lampp/htdocs folder, then I have change the folder permission using:

sudo -s 
cd /opt/lampp/htdocs
sudo chmod 777 -R myWebContent

Then folder permission is changed. But still I can not access my php file, because it only change the folder's access permission, not a single php file's permission. How can I solve this?

David Foerster
  • 36,264
  • 56
  • 94
  • 147
sabbir
  • 223

2 Answers2

4

instead of chmod 777 you should better to change the owner to www:www and keep 644 or 755 security. Under www user the apache is running and will have read-write-execute access, but other users will have just read or read-execute only access. Try this:

sudo chmod -R 755 /opt/lampp/htdocs
sudo chown -R www-data:www-data  /opt/lampp/htdocs
Dee
  • 1,976
  • Hey, if I do this I find that I'm not able to use my text editor to write files to htdocs. What to do?! – ankush981 Mar 20 '14 at 16:54
  • you can add yourself to the www:data group and use 775 / 664, or you can write it as a root. If you write new files, you will have to change ownership again. Obvious but secure. – Dee Mar 24 '14 at 10:16
  • Hmmm, but does it matter if I'm experimenting on the local machine? If I then FTP the files to the web server, it's going to have its own permissions set up and there will be no problem. What say? – ankush981 Mar 26 '14 at 15:52
  • you can change (and you should) permissions on FTPd web server as well. – Dee Mar 28 '14 at 01:21
1

I know this question is super old but for anyone reading out there... you probably don't need to do that if all you want is to be able to freely change and add files that use the lamp stack.

You could always change the httpd-vhosts.conf file, add the port and the path to a more suitable directory and that's it.

<VirtualHost *:80> 
 DocumentRoot "/path/to/dir"        
 ServerName DevEnv
 Other directives here
 </VirtualHost>

I personally rather :

Opt/Lampp/htdocs Sudo .nautilus 

Then you can do whatever you want in there and open the htdocs with your code editor and all that.

no messing with permissions and stuff.

Kam
  • 11
  • 1
    Can you please expand on this answer with more information? Things like where the file is found, and what to edit in the file. It may also be helpful to provide a step by step guide for anyone who has similar issues. :) – AnotherKiwiGuy Mar 02 '17 at 20:33