nginx + php-fpm ERROR 'FastCGI sent in stderr: "Primary script unknown"' for 2nd app (WP) in a subdir. Main site is OK.

aclion at yepmail.net aclion at yepmail.net
Sun Apr 29 22:12:34 UTC 2018


This config seems to get me further, or maybe just different

	location / {
		index index.php;
		try_files $uri $uri/ /index.php?q=$uri&$args;
	}

	location ^~ /blog {
		alias /srv/www/test/wp/public/blog;
		index index.php;
		try_files $uri $uri/ /blog/index.php?q=$uri&$args;
	}

	location ~ \.php$ {
		try_files $uri =404;
		fastcgi_split_path_info ^(.+?\.php)(/.*)$;
		if (!-f $document_root$fastcgi_script_name) {
		    return 404;
		}

		fastcgi_param HTTP_PROXY "";
		fastcgi_pass phpfpm;
		fastcgi_index index.php;
		include includes/fastcgi/fastcgi_params;
	}

With that when I visit

	https://test.example.com/blog/

I see this _source_ file in the browser

		<?php
		/**
		 * Front to the WordPress application. This file doesn't do anything, but loads
		 * wp-blog-header.php which does and tells WordPress to load the theme.
		 *
		 * @package WordPress
		 */

		/**
		 * Tells WordPress to load the WordPress theme and output it.
		 *
		 * @var bool
		 */
		define('WP_USE_THEMES', true);

		/** Loads the WordPress Environment and Template */
		require( dirname( __FILE__ ) . '/wp-blog-header.php' );


It's found, but not being handled by php.

AC


More information about the nginx mailing list