shane07 Posted September 14, 2011 Share Posted September 14, 2011 I have a weird kind of problem. I uploaded all upload-directories through FTP which have 777 permissions and owner name 'abc' This means I can access all of them through the codes. But while creating files inside those full permitted directories, the compiler complains for access denied. Meanwhile, a different directory is created with same name whose owner is 'apache' itself and the previous directory is lost. Then I cannot change the permissions of that directory through FTP. I don't if it is apache server's problem itself or not. Or is it a way to define user while creating/editing/deleting files and directories through php code itself? Link to comment https://forums.phpfreaks.com/topic/247120-cant-access-directory-or-file-through-php-code/ Share on other sites More sharing options...
trq Posted September 14, 2011 Share Posted September 14, 2011 PHP operates as part of Apache. Apache runs as a specific user, it is this user that needs permission to create files/directories using PHP. Link to comment https://forums.phpfreaks.com/topic/247120-cant-access-directory-or-file-through-php-code/#findComment-1269155 Share on other sites More sharing options...
AyKay47 Posted September 14, 2011 Share Posted September 14, 2011 you can either change the permissions of www-data manually, through PHP using chmode or terminal Link to comment https://forums.phpfreaks.com/topic/247120-cant-access-directory-or-file-through-php-code/#findComment-1269156 Share on other sites More sharing options...
shane07 Posted September 14, 2011 Author Share Posted September 14, 2011 this means I need to change the owner to 'apache' using chown before doing something, isn't it? Link to comment https://forums.phpfreaks.com/topic/247120-cant-access-directory-or-file-through-php-code/#findComment-1269157 Share on other sites More sharing options...
AyKay47 Posted September 14, 2011 Share Posted September 14, 2011 the owner will be "www-data" which is the owner that apache uses Link to comment https://forums.phpfreaks.com/topic/247120-cant-access-directory-or-file-through-php-code/#findComment-1269159 Share on other sites More sharing options...
trq Posted September 14, 2011 Share Posted September 14, 2011 the owner will be "www-data" which is the owner that apache uses This completely depends upon Apache's configuration. You can check who apache runs as by executing: grep User /etc/apache2/httpd.conf The path to your config file might also be different though. Link to comment https://forums.phpfreaks.com/topic/247120-cant-access-directory-or-file-through-php-code/#findComment-1269186 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.