Nginx+Php-fpm支持PathInfo(适用于Typecho)

  • PHP版本
PHP 7.0.33 (fpm-fcgi) (built: Dec  6 2018 22:33:05)
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
  • Nginx版本
nginx version: nginx/1.14.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017

根据网上的资料总结的nginx的配置,亲测可以用

server {
	#前略
	
	#typecho所需配置
	if (!-e $request_filename) {
	    rewrite ^(.*)$ /index.php$1 last;
	}
	
	location ~  .*\.php(\/.*)*$ {
		#支持pathinfo的关键配置
	    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
	    #php-fpm的监听端口
	    fastcgi_pass   localhost:9000;
	        
	    fastcgi_index  index.php;
	    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
	    include        fastcgi_params;
	}
}

你可能感兴趣的:(教程)