Помогите настроить nginx для работы OkayCMS.

nsd_net

Создатель
Регистрация
12 Июл 2009
Сообщения
29
Реакции
7
Всем привет.
Поделитесь конфигом nginxa для корректной работы cms.
Проблема в том, что после установки открывается только корневая страница сайта.
Переходы по разделам не работают.
Код:
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name доменное_имя_или_IP_адрес_сервера;

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

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

    location ~ /\.ht {
        deny all;
    }
}
 
Код:
server {
   listen          80;
   server_name     site.ru www.site.ru;
   root /var/www/site.ru/html;
   index index.php;
   client_max_body_size 64M;

   access_log off;
   
   
   
   

   location = /favicon.ico {
         log_not_found off;
         access_log off;
   }

   location = /robots.txt {
         allow all;
         log_not_found off;
         access_log off;
   }

   location  \.(txt|log)$ {
         allow 192.168.0.0/16;
         deny all;
   }

   

     
     
     
      location /backend {
       
     
      index index.php;
     
      location ~ \.php$ {
               try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                fastcgi_pass   unix:/var/run/php5-fpm.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include fastcgi_params;
                fastcgi_ignore_client_abort on;
                fastcgi_param  SERVER_NAME $http_host;
        }
     
     
     
   }
   
   
     
     
     
     
     
   rewrite   ^/admin/?$  /backend last;
   
   location ~* ^/(api|cache|compiled|config|design/(.*)/html|payment|Smarty|view)/(.*) { deny all; }

   location / {
         try_files $uri @rewrite;
   }

   
   
   
   
   location @rewrite {
      rewrite ^/catalog/([^/]+)/?$   index.php?module=ProductsView&category=$1;
      rewrite ^/catalog/([^/]+)   index.php?module=ProductsView&category=$1;
      rewrite ^/catalog/([^/]+)/([^/]+)/?$   index.php?module=ProductsView&category=$1&brand=$2;
      rewrite ^/products/([^/]+)/?$   index.php?module=ProductView&product_url=$1;
      rewrite ^/products/?$   index.php?module=ProductsView;
      rewrite ^/all-products/?$   index.php?module=ProductsView;
      rewrite ^/brands/([^/]+)/?$   index.php?module=ProductsView&brand=$1;
      rewrite ^/brands/([^/]+)/page_([^/]+)/?$   index.php?module=ProductsView&brand=$1&page=$2;
      rewrite ^/search/([^/]+)/?$   index.php?module=ProductsView&keyword=$1;
      rewrite ^/search/?$   index.php?module=ProductsView;
      rewrite ^/blog/([^/]+)/?$   index.php?module=BlogView&url=$1;
      rewrite ^/blog/?$   index.php?module=BlogView;
      rewrite ^/wishlist/([^/]+)/?$   index.php?module=WishlistView&id=$2&lang_label=$1;
      rewrite ^/wishlist/?$   index.php?module=WishlistView&lang_label=$1;
      rewrite ^/wishlist/delete/?$   index.php?module=WishlistView&id=$1&action=delete;
      rewrite ^/comparison/?$   index.php?module=ComparisonView;
      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;
      rewrite ^/order/([^/]+)/?$   index.php?module=OrderView&url=$1;
      rewrite ^/order/?$   index.php?module=OrderView;
      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;
      rewrite ^/sitemap.xml?$   sitemap.php last;
      rewrite ^/yandex.xml?$   yandex.php last;
      rewrite ^/contact/?$   index.php?module=FeedbackView;
      rewrite ^/order/([^/]+)/([^/]+)/?$   index.php?module=OrderView&url=$1&file=$2;
      if (!-f $request_filename){
         set $rule_26 1$rule_26;
      }
      if (!-d $request_filename){
         set $rule_26 2$rule_26;
      }
      if ($rule_26 = "21"){
         rewrite ^/([^/]+)/?$ /index.php?module=PageView&page_url=$1;
      }
      rewrite ^/?$ /index.php?module=MainView&page_url=;
     
      rewrite ^ /index.php;
   }

   location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                fastcgi_pass   unix:/var/run/php5-fpm.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include fastcgi_params;
                fastcgi_ignore_client_abort on;
                fastcgi_param  SERVER_NAME $http_host;
        }

   location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
if (!-e $request_filename){
rewrite ^/files/products/(.+) /resize/resize.php?file=$1&token=$query_string;
}
}
   
   
   
}
 
Свои параметры вставте вверху и будет все тип-топ

а что бы еще проще все что начинается со строчки
Код:
location @rewrite
 
Назад
Сверху