Page 1 of 1
Apache error "Could not save png to "
Posted: 2019/01/15 10:30:36
by bachoA4o
I'm trying to run a perl script that displays information about an interface and graphs in .png format.
The script must save the graphs in /var/www/html/grafika directory .
It displays the web page with the text but no graphs. Error log :
Code: Select all
AH01215: ERROR: Could not save png to '/var/www/html/grafika/graphHour.png
But when i run the script from the terminal and then access the web page the graps are there being displayed
Permmissions and ownership of /grafika (and dirs above) :
Code: Select all
drwxrws---. 2 root apache 6 Jan 15 12:15 grafika
I start the web server as user "apacheuser" and group "apache" , the group has full permissions on every directory.
I know its not right to give full permissions but this is a testing configuration.
Re: Apache error "Could not save png to "
Posted: 2019/01/15 11:54:32
by pjsr2
Writing to that directory may be forbidden by SELinux.
What is the SELinux context of the /var/www/html/grafika directory? You can see the SELinux context with
If you are new to SELinux, start reading with
https://wiki.centos.org/HowTos/SELinux
Re: Apache error "Could not save png to "
Posted: 2019/01/15 12:16:02
by TrevorH
Ideally you never want to give the web server write access to a directory that also contains the code that it's running. If you have the option to save the files in a directory that isn't the one where grafika runs from then you can set the context on that to one that allows writing.
Re: Apache error "Could not save png to "
Posted: 2019/01/15 13:08:00
by bachoA4o
pjsr2 wrote: ↑2019/01/15 11:54:32
Writing to that directory may be forbidden by SELinux.
What is the SELinux context of the /var/www/html/grafika directory? You can see the SELinux context with
If you are new to SELinux, start reading with
https://wiki.centos.org/HowTos/SELinux
Yes that was the problem and i found that minutes after i posted the question , i set /grafika dir in domain httpd_sys_script_rw_t so scripts can read/write in it . Thanks for the fast answer
Re: Apache error "Could not save png to "
Posted: 2019/01/15 13:09:33
by bachoA4o
TrevorH wrote: ↑2019/01/15 12:16:02
Ideally you never want to give the web server write access to a directory that also contains the code that it's running. If you have the option to save the files in a directory that isn't the one where grafika runs from then you can set the context on that to one that allows writing.
Taking a note on that , i will change it . Thanks