Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to setup NGINX with PHP-FPM on a Fedora 20 box and I am getting the "File not found / Primary script unknown" errors only when starting php-fpm as a system service.

I am using a default setup in NGINX with the default fastcgi.conf included.
(Using: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;)

Here's the relevant nginx.conf:

root   /var/www/index;
index  index.html index.php index.htm;

location ~ \.php$ {
          try_files      $uri = 404; 
          fastcgi_pass   unix:/var/run/php5-fpm.sock;
          fastcgi_index  index.php;
          include        fastcgi.conf;

Now, when I start php-fpm directly from the shell (as root) everything works absolutely fine, however when I start php-fpm using systemctl start php-fpm.service I get the "File not found / Primary script unknown" errors.

Here's the php-fpm.service defintion:

Description=The PHP FastCGI Process Manager
After=syslog.target network.target

ExecStart=/usr/sbin/php-fpm --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID


Does anyone have an idea why php-fpm could behave differently when started through systemd? (I'm very confused especially since php-fpm is spawning worker processes and there shouldn't be any difference between starting from the shell and starting through systemd.)

I am not using any chroot or chdir settings in the fpm pool configuration.

Any help would be greatly appreciated! Thanks Marcus

share|improve this question
In the meantime I found out, that the problem is related to SELinux. When I set SELinux to permissive, php-fpm is starting like it should. –  Marcus Mar 11 at 12:56
Well, if you would post some information then we could solve the problem. –  Michael Hampton Mar 11 at 14:54
Hi Michael, what information would you need? (I guess my problem is more that I don't know how to configure SELinux permissions and directives, so I'm not able to set it up properly for php-fpm. I guess that a more experienced user would be able to figure it out. Seems like it's coming down to file access permissions.) –  Marcus Mar 12 at 15:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.