Настройка Yii2 advanced в nginx

Различные вопросы по установке и настройке фреймворка, конфигурции веб-сервера и IDE.
Ответить
rinat989
Сообщения: 1
Зарегистрирован: 2017.05.29, 13:18

Настройка Yii2 advanced в nginx

Сообщение rinat989 » 2017.05.29, 13:50

Поставил yii advanced на nginx, frontend работает, а backend в роли админки не хочет работать

NGINX.CONF

Код: Выделить всё

server {
    listen      89.223.24.185:443;
    server_name rindev.ru www.rindev.ru;

    if ($host = "www.rindev.ru"){
        rewrite ^ https://rindev.ru$request_uri permanent;
    }

    root        /home/admin/web/rindev.ru/public_html;

    index       index.php index.html index.htm;
    charset    utf-8;

    access_log  /var/log/nginx/domains/rindev.ru.log combined;
    access_log  /var/log/nginx/domains/rindev.ru.bytes bytes;
    error_log   /var/log/nginx/domains/rindev.ru.error.log error;

    ssl         on;
    ssl_certificate      /home/admin/conf/web/ssl.rindev.ru.pem;
    ssl_certificate_key  /home/admin/conf/web/ssl.rindev.ru.key;

    location / {
        root  /home/admin/web/rindev.ru/public_html/frontend/web;
        try_files $uri /frontend/web/index.php?$args;
    }

    location /admin {
        root /home/admin/web/rindev.ru/public_html/backend/web;
        try_files $uri /backend/web/index.php?$args;
		
    }

    location ~ [^/]\.php(/|$) {
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        if (!-f $document_root$fastcgi_script_name) {
            return  404;
        }
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        include         /etc/nginx/fastcgi_params;
    }

    location ~ /\.(ht|svn|git) {
        deny    all;
        return  404;
    }

    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/admin/web/rindev.ru/document_errors/;
    }

    location /vstats/ {
        alias   /home/admin/web/rindev.ru/stats/;
        include /home/admin/web/rindev.ru/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/admin/conf/web/snginx.rindev.ru.conf*;
}

FRONTAND

Код: Выделить всё

<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'app-frontend',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'frontend\controllers',
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-frontend',
			'baseUrl'=>'',
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the frontend
            'name' => 'advanced-frontend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],


		'urlManager' => [
			'enablePrettyUrl' => true,
			'showScriptName' => false,
			'rules' => [
				'<slug:\w+>' => 'site/view',
			]
		],


//        'urlManager' => [
//            'enablePrettyUrl' => true,
//            'showScriptName' => false,
//            'rules' => [
//
//            ]
//        ],

    ],
    'params' => $params,
];

Backend

Код: Выделить всё

<?php
$params = array_merge(
	require(__DIR__ . '/../../common/config/params.php'),
	require(__DIR__ . '/../../common/config/params-local.php'),
	require(__DIR__ . '/params.php'),
	require(__DIR__ . '/params-local.php')
);

return [
	//'homeUrl' => '/admin/',
	'id' => 'app-backend',
	'basePath' => dirname(__DIR__),
	'controllerNamespace' => 'backend\controllers',
	'bootstrap' => ['log'],
	'modules' => [],
	'components' => [
		'request' => [
			'csrfParam' => '_csrf-backend',
			'baseUrl' => '/admin',
		],
		'user' => [
			'identityClass' => 'common\models\User',
			'enableAutoLogin' => true,
			'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
		],
		'session' => [
			// this is the name of the session cookie used for login on the backend
			'name' => 'advanced-backend',
		],
		'log' => [
			'traceLevel' => YII_DEBUG ? 3 : 0,
			'targets' => [
				[
					'class' => 'yii\log\FileTarget',
					'levels' => ['error', 'warning'],
				],
			],
		],
		'errorHandler' => [
			'errorAction' => 'site/error',
		],


		'urlManager' => [
			'class' => 'yii\web\UrlManager',
			'enablePrettyUrl' => true,
			'enableStrictParsing' => true,
			'showScriptName' => false,
		],

	],


	'params' => $params,
];

Изображение

Ответить