ispCP - Board - Support
PHP File Permission Denied - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega Support Area (/forum-30.html)
+--- Forum: Usage (/forum-34.html)
+--- Thread: PHP File Permission Denied (/thread-7886.html)

Pages: 1 2


PHP File Permission Denied - Diego - 09-18-2009 12:44 PM

I'm trying to access this address and I'm gettin permission denied:
http://www.abracadabra-designs.com/store/install.php

What could be wrong?


RE: PHP File Permission Denied - gOOvER - 09-18-2009 03:12 PM

How did you upload the files? I think, not via FTP. Wink


RE: PHP File Permission Denied - MasterTH - 09-18-2009 04:25 PM

check if file permissions are right, owner & group should be like the other files.
i'm not sure what kind of chmod php-files need, but php-files has to be executable


RE: PHP File Permission Denied - joximu - 09-18-2009 05:18 PM

no - php files do not need the execute flag.

you can write a script which sets the correct permissions and owners:
eg:
Code:
!/bin/bash

username=$(ls -ld . | cut -d" " -f3)
echo "Set to user/group: $username/$username"
echo "Cancel -> Ctrl-C, otherwise press Enter..."

read

# set owner vu:vu - folders
cmd="find ./ -type d -exec chown $username:$username {} ;"
#echo $cmd
($cmd)

# set owner vu:vu - files
cmd="find ./ -type f -exec chown $username:$username {} ;"
#echo $cmd
($cmd)

# set permissions - folders
cmd="find ./ -type d -exec chmod 0755 {} ;"
#echo $cmd
($cmd)

# set permissions - files
cmd="find ./ -type f -exec chmod 0644 {} ;"
#echo $cmd
($cmd)

# php files: less permissions (do not need to be world readable)
cmd="find ./ -type f -regex .*\.php$ -exec chmod 0640 {} ;"
#echo $cmd
($cmd)

echo "finished..."
echo ""

run the script inside the htdocs folder (but the htdocs folder must have correct ownership!!! - the script get's the owner of the currect folder!)

/J


RE: PHP File Permission Denied - gOOvER - 09-18-2009 05:21 PM

Nice Script. I will add it to the Wiki Smile


RE: PHP File Permission Denied - joximu - 09-18-2009 05:47 PM

I use it often, when copying files from one customer to another (or creating scripts with root...) or - most times - after transfer of www-data from an old server to the ispcp server.

I named it vu_setperm.sh - but I don't persist on that name :-)

/J


RE: PHP File Permission Denied - kilburn - 09-18-2009 05:57 PM

joxi, just a comment. Why don't you use vuxxx:www-data and remove the world-readable flag to all files?


RE: PHP File Permission Denied - joximu - 09-18-2009 06:13 PM

because php (fastcgi) then complains about wrong group.

/J

upd: btw: if you upload images/html files via ftp you also have this owner/permission...


RE: PHP File Permission Denied - kilburn - 09-18-2009 06:28 PM

Quote:because php (fastcgi) then complains about wrong group.
You are already applying specific permissions for php files, so it's just a matter of changing the group just for them Wink

Quote:upd: btw: if you upload images/html files via ftp you also have this owner/permission...
... and here is where you got me Wink


RE: PHP File Permission Denied - Diego - 09-19-2009 10:31 AM

(09-18-2009 05:18 PM)joximu Wrote:  no - php files do not need the execute flag.

you can write a script which sets the correct permissions and owners:
eg:
Code:
!/bin/bash

username=$(ls -ld . | cut -d" " -f3)
echo "Set to user/group: $username/$username"
echo "Cancel -> Ctrl-C, otherwise press Enter..."

read

# set owner vu:vu - folders
cmd="find ./ -type d -exec chown $username:$username {} ;"
#echo $cmd
($cmd)

# set owner vu:vu - files
cmd="find ./ -type f -exec chown $username:$username {} ;"
#echo $cmd
($cmd)

# set permissions - folders
cmd="find ./ -type d -exec chmod 0755 {} ;"
#echo $cmd
($cmd)

# set permissions - files
cmd="find ./ -type f -exec chmod 0644 {} ;"
#echo $cmd
($cmd)

# php files: less permissions (do not need to be world readable)
cmd="find ./ -type f -regex .*\.php$ -exec chmod 0640 {} ;"
#echo $cmd
($cmd)

echo "finished..."
echo ""

run the script inside the htdocs folder (but the htdocs folder must have correct ownership!!! - the script get's the owner of the currect folder!)

/J

Thanks for that code, worked for the messages I got earlier..
Just one thing, I can't rename/delete/move files using ftp:
Code:
[21:28:42] 150 Opening ASCII mode data connection for file list
[21:28:42] 2032 bytes transferred. (5,80 KB/s) (342 ms)
[21:28:42] 226 Transfer complete
[21:28:57] DELE test.html
[21:28:58] 550 test.html: Permission denied

File owner is set to www-data and I'm login into with the user abracadabra@abracadabra-designs.com
What's wrong now? Sad