LinuxForum.Fans
Тема

переезд с apache + mariadb 5.x на nginx + php-fpm + mariadb 10.x

Автор: gohoxa 9 сообщений 1046 просмотров
28.02.2017 23:21 · отредактировано #420895

Ранее был lighttpd на centos 7.X, всё работало корректно.

Сейчас имею nginx 1.10 с ubuntu 16.04.

Zabbix работает корректно, переходит по всем каталогам. У других веб-ресурсов не работает переход по каталогам - вместо этого возвращает значение 404, то есть, главная страница отображается, а все последующие с значением 404.


Конфиг Nginx:

text
server {
    root /var;

index index.php index.html index.htm;

server_name my_site;

location / { try_files $uri $uri/ =404; }

location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } }

Переезжали так:

text
tar -cvvf test.tar ./
vsftpd -> filezilla -> windows -> htt p
wget
tar -xvvf test.tar
text
mysqldump -u root -p dumpdb > dumpfile.sql

mysql -u root -p

CREATE DATABASE `db_name` CHARACTER SET utf8 COLLATE utf8_general_ci;

exit

mysql -u root -p db_name < dumpfile.sql

Added: 28.02.2017 20:21:52

Логи:
2017/03/01 02:19:53 [error] 25546#25546: *1 "/home/www/test/test2/index.php" is not found (2: No such file or directory), clie$
2017/03/01 02:19:55 [error] 25546#25546: *2 "/home/www/test/test3/index.php" is not found (2: No such file or directory), client: IP_ADDRESS, server: zom$

02.03.2017 23:24 #420981

Не буду оригинальным, файл по пути /home/www/test/test2/index.php" существует?
Ибо ошибка черным по белому говорит что его нет.

02.03.2017 23:52 #420982

Да, всё на месте.
Мне кажется, что всё-таки проблема в том, что в lighttpd есть .htcasses, настройки которого нужно переносить в nginx...

Взять в пример тот же zabbix, который заработал с аналогичным конфигом и настройками nginx - .htcasses отсутствовал.
К сожалению, я "готовить" nginx не умею, поэтому это только предположение.

03.03.2017 18:53 · отредактировано #421002

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

Значение 404 не возвращается, но при этом отображается только "начальная страница" (с которой был совершён переход). Аналогичная ситуация происходит на всех интернет-ресурсах.

Логи:

text

2017/03/03 18:48:59 [error] 12382#12382: *1 FastCGI sent in stderr: "Passing INI directive through FastCGI: empty value for key '#php_value default_charset windows-125$
Passing INI directive through FastCGI: unable to set '#date.timezone'" while reading response header from upstream, client: 141.8.142.105, server: my-site2, reque$
2017/03/03 18:49:00 [error] 12382#12382: *3 FastCGI sent in stderr: "Passing INI directive through FastCGI: empty value for key '#php_value default_charset windows-125$
Passing INI directive through FastCGI: unable to set '#date.timezone'" while reading response header from upstream, client: 95.158.200.30, server: my-site2, reque$
2017/03/03 18:49:00 [error] 12382#12382: *3 FastCGI sent in stderr: "Passing INI directive through FastCGI: empty value for key '#php_value default_charset windows-125$
Passing INI directive through FastCGI: unable to set '#date.timezone'" while reading response header from upstream, client: 95.158.200.30, server: my-site2, reque$
2017/03/03 18:49:00 [error] 12382#12382: *6 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function IPS\mb_internal_encoding$
Stack trace:
#0 /home/www/my-site/init.php(627): IPS\IPS::init()
#1 /home/www/my-site/index.php(12): require_once('/home/www/my-sit...')
#2 {main}
  thrown in /home/www/my-site/init.php on line 125" while reading response header from upstream, client: 69.30.234.2, server: my-site, request: "GET /?app=core&mod$
2017/03/03 18:49:00 [error] 12382#12382: *3 FastCGI sent in stderr: "Passing INI directive through FastCGI: empty value for key '#php_value default_charset windows-125$
Passing INI directive through FastCGI: unable to set '#date.timezone'" while reading response header from upstream, client: 95.158.200.30, server: my-site2, reque$
2017/03/03 18:49:00 [error] 12382#12382: *10 FastCGI sent in stderr: "Passing INI directive through FastCGI: empty value for key '#php_value default_charset windows-12$
Passing INI directive through FastCGI: unable to set '#date.timezone'" while reading response header from upstream, client: 95.158.200.30, server: my-site2, reque$
2017/03/03 18:49:01 [error] 12382#12382: *6 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function IPS\mb_internal_encoding$
Stack trace:
#0 /home/www/my-site/init.php(627): IPS\IPS::init()
#1 /home/www/my-site/index.php(12): require_once('/home/www/my-sit...')
#2 {main}
  thrown in /home/www/my-site/init.php on line 125" while reading response header from upstream, client: 69.30.234.2, server: my-site, request: "GET /?app=core&mod$

Проблема с кодировкой ясна (ибо наглядно видна проблема) - как зафиксить не знаю; с тайм зоной фиксить знаю как, но не трогаю - пытаюсь исправить основное.

03.03.2017 20:28 #421007
"gohoxa" написал:
.htcasses, настройки которого нужно переносить в nginx

Много я слышал о чудесах, но такое.......... Оставлю без комментариев.

"gohoxa" написал:
Значение 404 не возвращается, но при этом отображается только "начальная страница"

Значения 404 не существует.

03.03.2017 20:55 #421009

Все прекрасно поняли, что имелся в виду HTTP ответ "404 - Not found".

03.03.2017 22:19 #421011
"stranger" написал:
Много я слышал о чудесах, но такое.......... Оставлю без комментариев.

Что собственно не так?
Реврайт, например, должен быть.

04.03.2017 18:12 · отредактировано #421022

Пробовали так:

text
 location / {
        try_files $uri $uri/ @backend;
    }

location @backend { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; }

в логах nginx и php-fpm пусто, но проблему это не решило.

05.03.2017 15:44 #421026

Содержание конфига include snippets/fastcgi-php.conf;

text

# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;

# Check that the PHP script exists before passing it try_files $fastcgi_script_name =404;

# Bypass the fact that try_files resets $fastcgi_path_info # see: http://trac.nginx.org/nginx/ticket/321 set $path_info $fastcgi_path_info; fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php; include fastcgi.conf;

Войдите или зарегистрируйтесь, чтобы ответить.