Open /etc/postfix/main.cf: Permission denied
When running php comand "mail($tio, $subject, $body, $header)" from a website program, error appear: Open /etc/postfix/main.cf: Permission denied , even though the permisson of main.cf is set to 755.
The same code runs well in the shell.
could anyone help with the issue.
Thank you.
2 Replies
This sounds like an SELinux issue as discussed in this Server Fault post. To test whether SELinux is the cause, you can set SELinux to run in Permissive mode with this command:
sudo setenforce 0
Now, reboot your Linode, and confirm that SELinux is in Permissive mode with the following command:
getenforce
Now, see if your web application is still returning that error. After confirming whether SELinux is the problem, you can reestablish Enforcing mode by running the following command and again rebooting:
sudo setenforce 1
You may need to make several adjustments to your SELinux rules in order to enable postfix while maintaining your security settings. To help with that, here's our guide on Getting Started with SELinux. There are also several useful resources at the end of this guide, including User Resources from the SELinux Project Wiki.
The issue may due to the the "postfix/main.cf" is including other configuration files, and so the included files may also need to have the proper permissions. Setting all the files in /postfix/ to 755 may solve the problem.