I have been setting up a test server few days back by setting up MySQL , Apache and PHP from source. Though the installation all went smooth, but when I restarted apache it failed and when I checked the error logs they showed the following error :

Syntax error on line xxx of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied


I checked the related line in httpd.conf configuration file for possible syntax error , but I found none. The libphp5.so was available on the correct path and I verified the permissions and they were all correct as well. This was a new error so I had to do some googling to find some clue. What I found was that this permission error is actually related to Selinux settings which will need to be modified for the libphp5.so library.

If you face this error you can use below chcon command to change the Selinux security context for the file :

chcon -t textrel_shlib_t /usr/local/apache/modules/libphp5.so

This should resolve the problem and apache should start up fine. If you continue to see any issues you can try changing the Selinux mode from enforcing to permissive, even if that do not work you can change Selinux mode to disabled unless your environment do not allow do that.

Tags: , ,

1 Comment on Error : “/usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied” Resolution

  1. Jeong says:

    Thank you your post!
    it’s help resolv my problem!

    have a good day!

Leave a Reply