Permission denied for php code in /var/tmp folder

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Permission denied for php code in /var/tmp folder

Postby snehu » 16. September 2014 07:35

I am using apache web server on linux. I am using PHP for web designing. On web server, i want to show the configuration data by reading the ini file. I am creating this ini file from one php code itself. If this php code i run through linux terminal, the file is created with file and group owner as root.(i am having sudo rights on machine) Then if i try to read the ini file from my apache web server, it gives warning as failed to open stream: permission denied. I have tried changing the owner, and permissions to 777 of the file. Still it is not editable.
Also from folder /var/www/html, php code is able to read any owner file but not able to write.
and from folder /var/tmp, php code is not able to read any other owner file.
On the other hand, if i run the php code of ini file creation through web server, ini file is created with file and group owner as apche. and web server is able to read/ write the file.

But i want to create that file from root or some other user and later read/written by apache.

How to give this access permission?
snehu
 
Posts: 1
Joined: 16. September 2014 06:36
Operating System: Linux

Re: Permission denied for php code in /var/tmp folder

Postby Nobbie » 17. September 2014 10:52

snehu wrote:Then if i try to read the ini file from my apache web server, it gives warning as failed to open stream: permission denied. I have tried changing the owner, and permissions to 777 of the file. Still it is not editable



"Read" and "editable" is NOT the same?! For "editable" you need to open in read/write mode. How is your open flag in the code?

The problem usually is the missing permission of the folders(!) that holds the file. You have to grant full access to /var and to /var/tmp for example, if you like to read/write a file like /var/tmp/config.ini

Another hint: maybe you are running your PHP installation with a "safe_mode" restriction (see php.ini). Typically for safe_mode, the Apache user may NOT open files from different users.
Nobbie
 
Posts: 13182
Joined: 09. March 2008 13:04


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 62 guests