Frequently Asked Question

php-fpm permissions and "AH01071: Got error 'Primary script unknown\n'"
Last Updated 2 years ago

So you've moved or upgraded to php-fpm and now some if not all of your sites are giving the above error in the error_log and returning "Not Found" to visitors.

There are several causes for this, but the most common is permissions. The user php-fpm needs to be able to read the web directories where php files reside. Often in earlier configuration apache:apache was the default but this isn't going to work for php-fpm.

chgrp -R php-fpm *
chgrp -R php-fpm .htaccess

will give php-fpm group privileges, and then you simply need to make sure group has read

chmod -R g+r *
chmod g+r .htaccess

and you should be good to go. Now there are more elegant solutions involving moving php-fpm to the apache user, or adding php-fpm to the apache group and so on but in reality what most people want is the site up and running fast and elegance can be deployed later.

IF after doing all this php-fpm still doesn't work then its worth adding some logging to the system, this can be done by adding

access.log = /var/log/php-fpm/access.log

into the [www] section of /etc/php-fpm.d/www.con

then restart php-fpm with systemctl restart php-fpm. Now check this log file and make sure the correct requests are hitting it. If not then you've got a problem with your apache configuration so check out

/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf

for any obvious errors.

Please Wait!

Please wait... it will take a second!