Answer the question
In order to leave comments, you need to log in
Nginx + php-fpm, why are scripts being downloaded and not executed?
Hello! Busy migrating wordpress from nginx+apache to nginx + php-fpm. After setting it up, follow this manual: help.ubuntu.ru/wiki/nginx-phpfpm
When you click on a link that should be processed by a script, a file is downloaded with the following content:
<?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' );
server
{
listen 80;
server_name site.ru;
root /var/www/site/wordpress;
index index.php index.html index.htm;
location "/" {
index index.php index.html index.htm;
try_files $uri $uri/ =404;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php break;
}
}
location ~* "/\.ht" {
deny all; # запретить все для всех
return 404; # вернуть код ошибки 404
}
location ~* "^/wordpress/(wp-config.php)((/.*)?)$" {
deny all; # запретить все для всех
return 404; # вернуть код ошибки
}
location ~ \.php$ {
location ~* "/(upload(s?)|image(s?)|attachment(s?))/" {
return 404;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SERVER_ADMIN [email protected]; # почта администратора
fastcgi_param SERVER_SIGNATURE nginx/$nginx_version; # подпись сервера
fastcgi_index index.php; # файл индекса
}
}
Answer the question
In order to leave comments, you need to log in
Eka you have a curly config.
I'm not much of a WordPress expert - isn't there a single entry point?
To begin with, I would remove everything from FCGI_PARAM to include (so as not to clog the config).
This location
location "/" {
index index.php index.html index.htm;
try_files $uri $uri/ =404;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php break;
}
}
I don't see your location for php files. And in general for statics ..
First, configure nginx + php-fpm habrahabr.ru/post/113101
And then make additions under wordpress
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question