Mihael Опубликовано 27 июня, 2013 Жалоба Поделиться Опубликовано 27 июня, 2013 Здравствуйте! Уже который день бьюсь над вопросом настройки корректной работы 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 представлена, даже у самых молодых и зеленых. Цитата Ссылка на сообщение Поделиться на другие сайты
Dr_Brown Опубликовано 27 июня, 2013 Жалоба Поделиться Опубликовано 27 июня, 2013 Здравствуйте! Уже который день бьюсь над вопросом настройки корректной работы Simpla CMS 2.1.5 на своем сервере с Nginx+php-fpm (а значит абсолютно без апача). .У всех уважающих себя CMS инфа о корректной настройке nginx представлена, даже у самых молодых и зеленых. +1, Тут все за деньги, какой вопрос не спроси все по 30$ Цитата Ссылка на сообщение Поделиться на другие сайты
delprofile Опубликовано 27 июня, 2013 Жалоба Поделиться Опубликовано 27 июня, 2013 # 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;}} Цитата Ссылка на сообщение Поделиться на другие сайты
Mihael Опубликовано 27 июня, 2013 Автор Жалоба Поделиться Опубликовано 27 июня, 2013 С этим конфигом те же проблемы. вот эта строчка rewrite ^/?$ /index.php?module=MainView&page_url= break; непонятно что делает, если ее оставить, то вместо главной страницы выдает php код, а если ее закомментить, то на всех страницах сайта пишет "Страница не найдена". Как ее поправить? И с админкой беда, в нее пароль не спрашивает Цитата Ссылка на сообщение Поделиться на другие сайты
delprofile Опубликовано 27 июня, 2013 Жалоба Поделиться Опубликовано 27 июня, 2013 вот тут про авторизацию почитайте http://seriyps.ru/blog/2010/05/30/basic-http-avtorizaciya-dlya-nginx/ а почему у вас не пашет я хз, у меня всё работает на данной компиляции Цитата Ссылка на сообщение Поделиться на другие сайты
Mihael Опубликовано 27 июня, 2013 Автор Жалоба Поделиться Опубликовано 27 июня, 2013 В общем сейчас в конфиге вот что ## 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! Цитата Ссылка на сообщение Поделиться на другие сайты
Mihael Опубликовано 27 июня, 2013 Автор Жалоба Поделиться Опубликовано 27 июня, 2013 В общем сейчас вроде победил главную страницу было rewrite ^/?$ index.php?module=MainView&page_url= break; стало rewrite ^/?$ /index.php?module=MainView&page_url=; Цитата Ссылка на сообщение Поделиться на другие сайты
Mihael Опубликовано 27 июня, 2013 Автор Жалоба Поделиться Опубликовано 27 июня, 2013 Вот мой правленный конфиг в котором вроде все работает теперь ## 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 Цитата Ссылка на сообщение Поделиться на другие сайты
Mihael Опубликовано 27 июня, 2013 Автор Жалоба Поделиться Опубликовано 27 июня, 2013 А есть у кого-нибудь решение по логауту из админки? Цитата Ссылка на сообщение Поделиться на другие сайты
Mihael Опубликовано 27 июня, 2013 Автор Жалоба Поделиться Опубликовано 27 июня, 2013 Больной вопрос... Разве что полностью переделывать авторизацию - классическим способом, храня пароли админов в базе.Или делать заплатку, храня параметр в сессии - выходил или не выходил. Но тогда второй раз войти сразу же после выхода, возможно, не удастся...Или подобным суперкостыльным образом http://stackoverflow.com/questions/233507/how-to-log-out-user-from-web-site-using-basic-authenticationА вообще конечно идиотская идея входить в админку через BasicAuth, имхо лучше уж в базе хранить пароли. А так вошел один раз с чужого компа и сиди думай что делать чтобы выйти.. Цитата Ссылка на сообщение Поделиться на другие сайты
alaster Опубликовано 27 июня, 2013 Жалоба Поделиться Опубликовано 27 июня, 2013 Или подобным суперкостыльным образом http://stackoverflow.com/questions/233507/how-to-log-out-user-from-web-site-using-basic-authenticationА вообще конечно идиотская идея входить в админку через BasicAuth, имхо лучше уж в базе хранить пароли. А так вошел один раз с чужого компа и сиди думай что делать чтобы выйти..Убийство печенек, в которых хранится сессия, должно помогать. Менеджер ресурсов - печенья, уничтожить все к едрёной бабушке. Цитата Ссылка на сообщение Поделиться на другие сайты
Mihael Опубликовано 27 июня, 2013 Автор Жалоба Поделиться Опубликовано 27 июня, 2013 Убийство печенек, в которых хранится сессия, должно помогать. Менеджер ресурсов - печенья, уничтожить все к едрёной бабушке.Согласен, себе так и сделаю. Остается непонятным только то, почему это не сделали разработчики CMS.. Цитата Ссылка на сообщение Поделиться на другие сайты
alaster Опубликовано 28 июня, 2013 Жалоба Поделиться Опубликовано 28 июня, 2013 Согласен, себе так и сделаю. Остается непонятным только то, почему это не сделали разработчики CMS..Насколько я понимаю проблема в кросбраузерности. Цитата Ссылка на сообщение Поделиться на другие сайты
rohde Опубликовано 24 августа, 2013 Жалоба Поделиться Опубликовано 24 августа, 2013 есть проблема с конфигом выше - не загружаются картинки в карточку товара по ссылкам или с помощью мастера. объект сохраняется, но имя картинки прописывается как полный путь к ней, и соответственно она не загружается и не отображается./files/products/http%253A%252F%252Fsavepic.ru%252F4744550.100x100.png?1ccefc601bfd80d05d173a2ed9d449b4такой получается ссылка на картинку после загрузки. не знаю, связано это с конфигом nginx или с конфигурацией сервера и почему не работает нормально обработка имени.сервер на nginx+php-fpm. помогите, чем можете, добрые люди Цитата Ссылка на сообщение Поделиться на другие сайты
Romalibert Опубликовано 13 сентября, 2013 Жалоба Поделиться Опубликовано 13 сентября, 2013 Не силён в настройке нгинкс-а, может это пригодится? http://www.anilcetin.com/convert-apache-htaccess-to-nginx/ Цитата Ссылка на сообщение Поделиться на другие сайты
Lisandr Опубликовано 20 апреля, 2014 Жалоба Поделиться Опубликовано 20 апреля, 2014 есть проблема с конфигом выше - не загружаются картинки в карточку товара по ссылкам или с помощью мастера. объект сохраняется, но имя картинки прописывается как полный путь к ней, и соответственно она не загружается и не отображается./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; } Цитата Ссылка на сообщение Поделиться на другие сайты
shesternin Опубликовано 28 июня, 2014 Жалоба Поделиться Опубликовано 28 июня, 2014 // 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 вот так Цитата Ссылка на сообщение Поделиться на другие сайты
Рекомендуемые сообщения
Присоединяйтесь к обсуждению
Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.