@Semasping

Как сконфигурировать nginx php-fpm для phalcon фреймворка в панели vestaCP?

Всем привет
есть ли у кого то шаблон для nginx php-fpm для phalcon для панели vestaCP? Можете поделиться? Или помочь в его написании.
в настройках сервера очень не силен.
пробовал переделать laravel шаблон с учетом фалконовских рекомендаций https://docs.phalconphp.com/en/3.2/webserver-setup - но открывает только главную страницу в ответ на любую страницу.
Пример vestacp шаблона для laravel https://gist.github.com/semasping/85c9262ce9914176...

То что получилось у меня для phalcon
spoiler
server {
    listen      %ip%:%web_port%;
    server_name %domain_idn% %alias_idn%;
    root        %docroot%/public;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;

    charset utf-8;

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

        location ~ \.php {
            fastcgi_pass  %backend_lsnr%;;
            fastcgi_index /index.php;

            include /etc/nginx/fastcgi_params;
            fastcgi_split_path_info       ^(.+\.php)(/.+)$;
            fastcgi_param PATH_INFO       $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
    

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   %home%/%user%/web/%domain%/stats/;
        include %home%/%user%/web/%domain%/stats/auth.conf*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     %home%/%user%/conf/web/nginx.%domain%.conf*;
}



Дополнение:
Еще раз взял laravel шаблон и добавил в него в нужное место только
try_files $uri $uri/ /index.php?_url=$uri&$args;
В итоге существующие пути заработали.
полурабочий шаблон
server {
    listen      %ip%:%web_port%;
    server_name %domain_idn% %alias_idn%;
    root        %docroot%/public;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;
    location / {
        try_files $uri $uri/ /index.php?_url=$uri&$args;
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    %backend_lsnr%;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   %home%/%user%/web/%domain%/stats/;
        include %home%/%user%/web/%domain%/stats/auth.conf*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     %home%/%user%/conf/web/nginx.%domain_idn%.conf*;
}


Но если нет страницы то вываливается ошибка:
spoiler
TestpathController handler class cannot be loaded
#0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('TestpathControl...', 2)
#1 [internal function]: Phalcon\Dispatcher->_dispatch()
#2 [internal function]: Phalcon\Dispatcher->dispatch()
#3 /home/admin/web/semasping.tk/public_html/public/index.php(42): Phalcon\Mvc\Application->handle()
#4 {main}

Но тут я полагаю, что в фалконе у меня не настроена обработка несуществующих путей.
  • Вопрос задан
  • 741 просмотр
Пригласить эксперта
Ответы на вопрос 1
RomaZveR
@RomaZveR
CEO AlertMoney, PHP/Golang Developer
Хоть уже и прошел год.
Обработку несуществующих роутов нужно делать на стороне приложения.

$router = $di->getRouter(FALSE);
//$router = Phalcon\Mvc\Router(FALSE);
...
...
$router->notFound([
    'controller' => 'index',
    'action' => 'route404'
]);

...
class IndexController extends ControllerBase
{
   public function route404Action()
   {
        $this->view->disable();
        $this->response->setRawHeader('HTTP/1.1 404 Not Found');
        $this->response->setContent('<b>404, bratishka :(</b>');
        $this->response->send();
   }
}
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
18 апр. 2024, в 07:58
500 руб./в час
18 апр. 2024, в 07:22
45000 руб./за проект
18 апр. 2024, в 01:12
150000 руб./за проект