Перейти к содержанию
Официальный форум поддержки Simpla

Рекомендуемые сообщения

Здравствуйте!

 

Уже который день бьюсь над вопросом настройки корректной работы Simpla CMS 2.1.5 на своем сервере с Nginx+php-fpm (а значит абсолютно без апача).

 

Вот всё что я нашел:

http://forum.simplacms.ru/topic/27-nginx-i-htaccess/

http://forum.simplacms.ru/topic/1233-nginx-bez-apache/

http://forum.simplacms.ru/topic/528--passwd-na-svyazke-nginx-php-fpm/

 

Конфиги представленные по ссылкам выше некорректны, так как не подходят под текущую версию.

 

Прошу выложить верный пример конфига nginx для корректной работы cms вместе с правилами на админку и нормальной сменой пароля. А то можно подумать, что все на апаче только сидят, так как инфы вообще нет. У всех уважающих себя CMS инфа о корректной настройке nginx представлена, даже у самых молодых и зеленых.

Ссылка на сообщение
Поделиться на другие сайты

Здравствуйте!

 

Уже который день бьюсь над вопросом настройки корректной работы Simpla CMS 2.1.5 на своем сервере с Nginx+php-fpm (а значит абсолютно без апача).

 

.У всех уважающих себя CMS инфа о корректной настройке nginx представлена, даже у самых молодых и зеленых.

 

+1, Тут все за деньги, какой вопрос не спроси все по 30$ :D

Ссылка на сообщение
Поделиться на другие сайты

 

 # nginx configuration

 

charset utf-8;

 

error_page 404 /404;

 

location /admin {

rewrite ^/admin/?$ /simpla break;

}

 

location /catalog {

rewrite ^/catalog/([^/]+)/?$ /index.php?module=ProductsView&category=$1 break;

rewrite ^/catalog/([^/]+)/([^/]+)/?$ /index.php?module=ProductsView&category=$1&brand=$2 break;

}

 

location /products {

rewrite ^/products/([^/]+)/?$ /index.php?module=ProductView&product_url=$1 break;

rewrite ^/products/?$ /index.php?module=ProductsView break;

}

 

location /brands {

rewrite ^/brands/([^/]+)/?$ /index.php?module=ProductsView&brand=$1 break;

rewrite ^/brands/([^/]+)/page_([^/]+)/?$ /index.php?module=ProductsView&brand=$1&page=$2 break;

}

 

location /search {

rewrite ^/search/([^/]+)/?$ /index.php?module=ProductsView&keyword=$1 break;

rewrite ^/search/?$ /index.php?module=ProductsView break;

}

 

location /blog {

rewrite ^/blog/([^/]+)/?$ /index.php?module=BlogView&url=$1 break;

rewrite ^/blog/?$ /index.php?module=BlogView break;

}

 

location /cart {

rewrite ^/cart/?$ /index.php?module=CartView break;

rewrite ^/cart/([^/]+)/?$ /index.php?module=CartView&add_variant=$1 break;

rewrite ^/cart/remove/([^/]+)/?$ /index.php?module=CartView&delete_variant=$1 break;

}

 

location /order {

rewrite ^/order/([^/]+)/?$ /index.php?module=OrderView&url=$1 break;

rewrite ^/order/?$ /index.php?module=OrderView break;

rewrite ^/order/([^/]+)/([^/]+)/?$ /index.php?module=OrderView&url=$1&file=$2 break;

}

 

location /user {

rewrite ^/user/login/?$ /index.php?module=LoginView break;

rewrite ^/user/register/?$ /index.php?module=RegisterView break;

rewrite ^/user/logout/?$ /index.php?module=LoginView&action=logout break;

rewrite ^/user/password_remind/?$ /index.php?module=LoginView&action=password_remind break;

rewrite ^/user/password_remind/([0-9a-z]+)/?$ /index.php?module=LoginView&action=password_remind&code=$1 break;

rewrite ^/user/?$ /index.php?module=UserView break;

}

 

location /sitemap {

rewrite ^/sitemap.xml?$ /sitemap.php break;

}

 

location /yandex {

rewrite ^/yandex.xml?$ /yandex.php break;

}

 

location /contact {

rewrite ^/contact/?$ /index.php?module=FeedbackView break;

}

 

location / {

if (!-e $request_filename){

rewrite ^/([^/]*)/?$ /index.php?module=PageView&page_url=$1 break;

}

rewrite ^/?$ /index.php?module=MainView&page_url= break;

if (!-e $request_filename){

rewrite ^/files/products/(.+) /resize/resize.php?file=$1&token=$query_string;

}

}

Ссылка на сообщение
Поделиться на другие сайты

С этим конфигом те же проблемы.

 

вот эта строчка

rewrite ^/?$ /index.php?module=MainView&page_url= break;

 

непонятно что делает, если ее оставить, то вместо главной страницы выдает php код, а если ее закомментить, то на всех страницах сайта пишет "Страница не найдена". Как ее поправить?

 

И с админкой беда, в нее пароль не спрашивает

Ссылка на сообщение
Поделиться на другие сайты

вот тут про авторизацию почитайте

 

http://seriyps.ru/blog/2010/05/30/basic-http-avtorizaciya-dlya-nginx/

 

а почему у вас не пашет я хз, у меня всё работает на данной компиляции

Ссылка на сообщение
Поделиться на другие сайты

В общем сейчас в конфиге вот что

## Parse all .php file in the www directory
    location ~ \.php$ {
        fastcgi_pass   backend;
        fastcgi_param  SCRIPT_FILENAME  /sites/active/kate.lady/shop/www$fastcgi_script_name;
        include fastcgi_params;
    }
    
	location / {
		root /sites/active/kate.lady/shop/www;
		index index.php;
		if (!-e $request_filename){
			rewrite ^/([^/]*)/?$ /index.php?module=PageView&page_url=$1 break;
		}
		
		if (!-e $request_filename){
			rewrite ^/files/products/(.+) /resize/resize.php?file=$1&token=$query_string;
		}
		
		rewrite ^/?$	index.php?module=MainView&page_url= break;
		
		error_page 404 /404;
	}
	
	location /simpla/ {
		root /sites/active/kate.lady/shop/www/simpla;
		index /simpla/index.php;
		auth_basic "Unauthorized";
        auth_basic_user_file /sites/active/kate.lady/shop/www/simpla/.htpasswd;
	}

	location /catalog {
		rewrite ^/catalog/([^/]+)/?$ /index.php?module=ProductsView&category=$1 break;
		rewrite ^/catalog/([^/]+)/([^/]+)/?$ /index.php?module=ProductsView&category=$1&brand=$2 break;
	}

	location /products {
		rewrite ^/products/([^/]+)/?$ /index.php?module=ProductView&product_url=$1 break;
		rewrite ^/products/?$ /index.php?module=ProductsView break;
	}

	location /brands {
		rewrite ^/brands/([^/]+)/?$ /index.php?module=ProductsView&brand=$1 break;
		rewrite ^/brands/([^/]+)/page_([^/]+)/?$ /index.php?module=ProductsView&brand=$1&page=$2 break;
	}
	
	location /search {
		rewrite ^/search/([^/]+)/?$ /index.php?module=ProductsView&keyword=$1 break;
		rewrite ^/search/?$ /index.php?module=ProductsView break;
	}
	
	location /blog {
		rewrite ^/blog/([^/]+)/?$ /index.php?module=BlogView&url=$1 break;
		rewrite ^/blog/?$ /index.php?module=BlogView break;
	}
	
	location /cart {
		rewrite ^/cart/?$ /index.php?module=CartView break;
		rewrite ^/cart/([^/]+)/?$ /index.php?module=CartView&add_variant=$1 break;
		rewrite ^/cart/remove/([^/]+)/?$ /index.php?module=CartView&delete_variant=$1 break;
	}
	
	location /order {
		rewrite ^/order/([^/]+)/?$ /index.php?module=OrderView&url=$1 break;
		rewrite ^/order/?$ /index.php?module=OrderView break;
		rewrite ^/order/([^/]+)/([^/]+)/?$ /index.php?module=OrderView&url=$1&file=$2 break;
	}
	
	location /user {
		rewrite ^/user/login/?$ /index.php?module=LoginView break;
		rewrite ^/user/register/?$ /index.php?module=RegisterView break;
		rewrite ^/user/logout/?$ /index.php?module=LoginView&action=logout break;
		rewrite ^/user/password_remind/?$ /index.php?module=LoginView&action=password_remind break;
		rewrite ^/user/password_remind/([0-9a-z]+)/?$ /index.php?module=LoginView&action=password_remind&code=$1 break;
		rewrite ^/user/?$ /index.php?module=UserView break;
	}
	
	location /sitemap {
		rewrite ^/sitemap.xml?$ /sitemap.php break;
	}
	
	location /yandex {
		rewrite ^/yandex.xml?$ /yandex.php break;
	}
	
	location /contact {
		rewrite ^/contact/?$ /index.php?module=FeedbackView break;
	}
	
	## Images and static content is treated different
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
      access_log        off;
      expires           30d;
      root /sites/active/kate.lady/shop/www;
    }

    ## Disable viewing .htaccess & .htpassword
    location ~ /\.ht {
        deny  all;
    }

 

Авторизацию в админку сделал, но на главной по прежнему выводится текстом код из файла index.php 

Всю голову уже сломал и не могу понять почему он этот файл не воспринимает как скрипт. В админке index.php же понимает без проблем.

HELP!

Ссылка на сообщение
Поделиться на другие сайты

В общем сейчас вроде победил главную страницу

 

было

rewrite ^/?$	index.php?module=MainView&page_url= break; 

 

стало

rewrite ^/?$    /index.php?module=MainView&page_url=;
Ссылка на сообщение
Поделиться на другие сайты

Вот мой правленный конфиг в котором вроде все работает теперь

 

## Parse all .php file in the www directory
    location ~ \.php$ {
        fastcgi_pass   backend;
        fastcgi_param  SCRIPT_FILENAME  /sites/active/kate.lady/shop/www$fastcgi_script_name;
        include fastcgi_params;
    }
    
	location / {
		root /sites/active/kate.lady/shop/www;
		index index.php;
		if (!-e $request_filename){
			rewrite ^/([^/]*)/?$ /index.php?module=PageView&page_url=$1;
		}
		
		if (!-e $request_filename){
			rewrite ^/files/products/(.+) /resize/resize.php?file=$1&token=$query_string;
		}
		
		rewrite ^/?$    /index.php?module=MainView&page_url=;
		
		error_page 404 /404;
	}
	
	location /simpla/ {
		root /sites/active/kate.lady/shop/www/simpla;
		index /simpla/index.php;
		auth_basic "Unauthorized";
        auth_basic_user_file /sites/active/kate.lady/shop/www/simpla/.htpasswd;
	}

	location /catalog {
		rewrite ^/catalog/([^/]+)/?$ /index.php?module=ProductsView&category=$1;
		rewrite ^/catalog/([^/]+)/([^/]+)/?$ /index.php?module=ProductsView&category=$1&brand=$2;
	}

	location /products {
		rewrite ^/products/([^/]+)/?$ /index.php?module=ProductView&product_url=$1;
		rewrite ^/products/?$ /index.php?module=ProductsView;
	}

	location /brands {
		rewrite ^/brands/([^/]+)/?$ /index.php?module=ProductsView&brand=$1;
		rewrite ^/brands/([^/]+)/page_([^/]+)/?$ /index.php?module=ProductsView&brand=$1&page=$2;
	}
	
	location /search {
		rewrite ^/search/([^/]+)/?$ /index.php?module=ProductsView&keyword=$1;
		rewrite ^/search/?$ /index.php?module=ProductsView;
	}
	
	location /blog {
		rewrite ^/blog/([^/]+)/?$ /index.php?module=BlogView&url=$1;
		rewrite ^/blog/?$ /index.php?module=BlogView;
	}
	
	location /cart {
		rewrite ^/cart/?$ /index.php?module=CartView;
		rewrite ^/cart/([^/]+)/?$ /index.php?module=CartView&add_variant=$1;
		rewrite ^/cart/remove/([^/]+)/?$ /index.php?module=CartView&delete_variant=$1;
	}
	
	location /order {
		rewrite ^/order/([^/]+)/?$ /index.php?module=OrderView&url=$1;
		rewrite ^/order/?$ /index.php?module=OrderView;
		rewrite ^/order/([^/]+)/([^/]+)/?$ /index.php?module=OrderView&url=$1&file=$2;
	}
	
	location /user {
		rewrite ^/user/login/?$ /index.php?module=LoginView;
		rewrite ^/user/register/?$ /index.php?module=RegisterView;
		rewrite ^/user/logout/?$ /index.php?module=LoginView&action=logout;
		rewrite ^/user/password_remind/?$ /index.php?module=LoginView&action=password_remind;
		rewrite ^/user/password_remind/([0-9a-z]+)/?$ /index.php?module=LoginView&action=password_remind&code=$1;
		rewrite ^/user/?$ /index.php?module=UserView;
	}
	
	location /sitemap {
		rewrite ^/sitemap.xml?$ /sitemap.php;
	}
	
	location /yandex {
		rewrite ^/yandex.xml?$ /yandex.php;
	}
	
	location /contact {
		rewrite ^/contact/?$ /index.php?module=FeedbackView;
	}
	
	## Images and static content is treated different
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
      access_log        off;
      expires           30d;
      root /sites/active/kate.lady/shop/www;
    }

    ## Disable viewing .htaccess & .htpassword
    location ~ /\.ht {
        deny  all;
    }

 

 

директивы break пришлось убрать и везде где нужно index.php заменить на /index.php

Ссылка на сообщение
Поделиться на другие сайты

Больной вопрос... 

Разве что полностью переделывать авторизацию - классическим способом, храня пароли админов в базе.

Или делать заплатку, храня параметр в сессии - выходил или не выходил.  Но тогда второй раз  войти сразу же после выхода, возможно, не удастся...

Или подобным суперкостыльным образом http://stackoverflow.com/questions/233507/how-to-log-out-user-from-web-site-using-basic-authentication

А вообще конечно идиотская идея входить в админку через BasicAuth, имхо лучше уж в базе хранить пароли. А так вошел один раз с чужого компа и сиди думай что делать чтобы выйти..

Ссылка на сообщение
Поделиться на другие сайты

Или подобным суперкостыльным образом http://stackoverflow.com/questions/233507/how-to-log-out-user-from-web-site-using-basic-authentication

А вообще конечно идиотская идея входить в админку через BasicAuth, имхо лучше уж в базе хранить пароли. А так вошел один раз с чужого компа и сиди думай что делать чтобы выйти..

Убийство печенек, в которых хранится сессия, должно помогать. Менеджер ресурсов - печенья, уничтожить все к едрёной бабушке.

Ссылка на сообщение
Поделиться на другие сайты

Убийство печенек, в которых хранится сессия, должно помогать. Менеджер ресурсов - печенья, уничтожить все к едрёной бабушке.

Согласен, себе так и сделаю. Остается непонятным только то, почему это не сделали разработчики CMS..

Ссылка на сообщение
Поделиться на другие сайты

Согласен, себе так и сделаю. Остается непонятным только то, почему это не сделали разработчики CMS..

Насколько я понимаю проблема в кросбраузерности.

Ссылка на сообщение
Поделиться на другие сайты
  • 1 месяц спустя...

есть проблема с конфигом выше - не загружаются картинки в карточку товара по ссылкам или с помощью мастера. объект сохраняется, но имя картинки прописывается как полный путь к ней, и соответственно она не загружается и не отображается.

/files/products/http%253A%252F%252Fsavepic.ru%252F4744550.100x100.png?1ccefc601bfd80d05d173a2ed9d449b4

такой получается ссылка на картинку после загрузки. 

 

не знаю, связано это с конфигом nginx или с конфигурацией сервера и почему не работает нормально обработка имени.

сервер на nginx+php-fpm.

 

помогите, чем можете, добрые люди :)

Ссылка на сообщение
Поделиться на другие сайты
  • 3 недели спустя...
  • 7 месяцев спустя...

есть проблема с конфигом выше - не загружаются картинки в карточку товара по ссылкам или с помощью мастера. объект сохраняется, но имя картинки прописывается как полный путь к ней, и соответственно она не загружается и не отображается.

/files/products/http%253A%252F%252Fsavepic.ru%252F4744550.100x100.png?1ccefc601bfd80d05d173a2ed9d449b4

такой получается ссылка на картинку после загрузки. 

 

не знаю, связано это с конфигом nginx или с конфигурацией сервера и почему не работает нормально обработка имени.

сервер на nginx+php-fpm.

 

помогите, чем можете, добрые люди :)

 

Добавьте в файл конфигурации следующий код:

if (!-d $request_filename){
	set $rule_0 1$rule_0;
}
if (!-f $request_filename){
	set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
	rewrite ^/files/products/(.+) /resize/resize.php?file=$1&token=$args;
} 

 

 

Ссылка на сообщение
Поделиться на другие сайты
  • 2 месяца спустя...
// Routing
$url = isset($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : $_SERVER['REQUEST_URI'];
if ( strpos($url, '?') ) {
	$url = substr($url, 0, strpos($url, '?'));
}
if ( preg_match( '/catalog\/([^\/]+)\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'ProductsView';
	$_GET['category'] 	= $matches[1];
	$_GET['brand'] 	= $matches[2];
}
else
if ($url == '/') {
	$_GET['module'] 	= 'MainView';
}
else
if ( preg_match( '/catalog\/(.+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'ProductsView';
	$_GET['category'] 	= $matches[1];
}
else
if ( preg_match( '/products\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	 = 'ProductView';
	$_GET['product_url'] = $matches[1];
}
else
if ( preg_match( '/goods\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	 = 'ProductView';
	$_GET['product_url'] = $matches[1];
}
else
if ( preg_match( '/brands\/([^\/]+)\/page_([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'ProductsView';
	$_GET['brand'] 		= $matches[1];
	$_GET['page'] 		= $matches[2];
}
else
if ( preg_match( '/brands\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'ProductsView';
	$_GET['brand'] 		= $matches[1];
}
else
if ( preg_match( '/blog\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'BlogView';
	$_GET['url'] 		= $matches[1];
}
else
if ( preg_match( '/blog\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'BlogView'; 
}
else
if ( preg_match( '/news\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'BlogView';
	$_GET['url'] 		= $matches[1];
}
else
if ( preg_match( '/news\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'BlogView';
}
else
if ( preg_match( '/order\/([^\/]+)\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'OrderView';
	$_GET['url'] 		= $matches[1];
	$_GET['file'] 		= $matches[2];
}
else
if ( preg_match( '/order\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'OrderView';
	$_GET['url'] 		= $matches[1];
}
else
if ( preg_match( '/order\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'OrderView';
}
else
if ( preg_match( '/cart\/remove\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 		= 'CartView';
	$_GET['delete_variant'] = $matches[1];
}
else
if ( preg_match( '/cart\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'CartView';
	$_GET['add_variant']= $matches[1];
}
else
if ( preg_match( '/cart\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'CartView';
}
else
if ( preg_match( '/search\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'ProductsView';
	$_GET['keyword']	= $matches[1];
}
else
if ( preg_match( '/contact\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'FeedbackView';
}
else
if ( preg_match( '/user\/register\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'RegisterView';
}
else
if ( preg_match( '/user\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'UserView';
}
else
if ( preg_match( '/user\/login\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'LoginView';
}
else
if ( preg_match( '/user\/logout\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'LoginView';
	$_GET['action']		= 'logout';
}
else
if ( preg_match( '/user\/password_remind\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'LoginView';
	$_GET['action']		= 'password_remind';
}
else
if ( preg_match( '/user\/password_remind\/([^\/]+)\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'LoginView';
	$_GET['action']		= 'password_remind';
	$_GET['code']		= $matches[1];
}
else
if ( preg_match( '/search\/?$/', $url, $matches) || preg_match( '/products\/?$/', $url, $matches) ) {
	$_GET['module'] 	= 'ProductsView';
}
else {
	 preg_match( '/([^\/]+)\/?$/', $url, $matches);
	$_GET['module'] 	= 'PageView';
	$_GET['page_url'] 	= $matches[1];
}

Решил проблему роутингом в index.php вот так

Ссылка на сообщение
Поделиться на другие сайты

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Вставить как обычный текст

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

Загрузка...
×
×
  • Создать...