Answer the question
In order to leave comments, you need to log in
Why does nginx throw an error FastCGI sent in stderr: "PHP message: PHP Notice: Undefined variable: object_id?
php_value register_globals Off
ErrorDocument 404 404.html
AddDefaultCharset utf-8
AddCharset utf-8 *
<IfModule mod_charset.c>
CharsetSourceEnc utf-8
CharsetDefault utf-8
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.html$ index.php?cat_name=$1 [NC,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?cat_name=$1 [NC,L,QSA]
user www-data;
worker_processes auto;
timer_resolution 100ms;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
server_tokens off;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.1;
gzip_disable msie6;
gzip_types text/plain application/xml application/x-javascript text/css;
include /etc/nginx/conf.d/stub.conf;
include /usr/local/ispmgr/etc/nginx.domain;
client_max_body_size 16M;
log_format isp '$bytes_sent $request_length';
include common/upstream;
include /etc/nginx/sites-enabled/*;
}
upstream php-fpm
{
#php5-fpm сервер
server unix:/var/run/php5-fpm.sock;
}
server
{
listen 80;
server_name www.test.example.ru;
rewrite ^ http://test.example.ru$request_uri? permanent; #301 redirect
}
server
{
# Порты
listen 80;
disable_symlinks if_not_owner from=$root_path;
set $root_path /var/www/example_ru/data/www/test.example.ru;
root $root_path;
index index.php index.html index.htm;
server_name test.example.ru;
client_max_body_size 30m; # максимальный объем файла для загрузки 30 mb
location "/"
{
try_files $uri $uri/ =404; # проверить есть ли файл из запроса на диске, иначе 404
}
include common/locations/deny;
# Направление PHP-скрипта для обработки FastCGI или PHP-FPM серверу
location ~ \.php$
{
# Решение проблемы с уязвимостью (см. http://forum.nginx.org/read.php?2,88845,page=3)
# Не будет работать (ошибка 404) если файлы хранятся на другом сервере
try_files $uri $uri/ $uri/index.php?q=$uri&$args $uri/index.php =404;
include common/php-fpm;
}
}
if (!-e $request_filename){
rewrite ^/(.*)\.html$ /index.php?cat_name=$1 break;
}
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?cat_name=$1 break;
}
# Настройки порта или сокета PHP-FPM производятся в файле "/etc/php5/fpm/pool.d/www.conf"
fastcgi_pass php-fpm;
# Порядок важен - строчка "include fastcgi_params" должна быть первой
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
# См. http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
# Указание дополнительных переменных окружения PHP
fastcgi_param SERVER_ADMIN xxx;
fastcgi_param SERVER_SIGNATURE nginx/$nginx_version;
fastcgi_index index.php;
Answer the question
In order to leave comments, you need to log in
Try something like this:
server {
listen 80;
server_name test.example.ru;
root /var/www/example_ru/data/www/test.example.ru;
index index.php index.html index.htm;
client_max_body_size 30m;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 60;
fastcgi_send_timeout 60;
location / {
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?cat_name=$1 last;
}
expires 72h;
}
location ~ \.php$ {
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?cat_name=$1 last;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question