Как подружить nginx + php-fpm с opencart

Статус
Закрита.
Никита

Никита

Профессор
Пользователи
Реєстрація
19.05.2014
Повідомлення
611
Репутація
63
Вік
42
Имеется не большой магазинчик, который сейчас работает на apache, решил его перевести на связку NGINX с PHP-FPM, но как оказалось - в этом режиме, работает только главная страница, так как использую SEO PRO. Подскажите пожалуйста люди добрые, что нужно прописать в конфиге, чтобы это дело, наконец-то запустилось?
Это всё установлено на Centos 7.3 с панелью ISPmanager.
 
Вот мой файл конфигурации:
NGINX:
server {
    server_name vasia.pp.ua www.vasia.pp.ua;
    charset off;
    index index.html index.php;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/vasia.pp.ua/*.conf;
    access_log /var/www/httpd-logs/vasia.pp.ua.access.log;
    error_log /var/www/httpd-logs/vasia.pp.ua.error.log notice;
    ssi on;
    return 301 https://$host:443$request_uri;
    set $root_path /var/www/vasia/data/www/vasia.pp.ua;
    root $root_path;
    listen 135.452.41.55:80;
    gzip on;
    gzip_comp_level 9;
    gzip_disable "msie6";
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
    expires max;
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
         location / {
                try_files $uri $uri/ /index.php?$args; # permalinks
                }
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@vasia.pp.ua";
        fastcgi_pass unix:/var/www/php-fpm/vasia.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}
server {
    server_name vasia.pp.ua www.vasia.pp.ua;
    ssl on;
    ssl_certificate "/var/www/httpd-cert/vasia/vasia.pp.ua.crtca";
    ssl_certificate_key "/var/www/httpd-cert/vasia/vasia.pp.ua.key";
    ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:RSA+3DES:!NULL:!RC4:!RSA+3DES;
    ssl_prefer_server_ciphers on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    add_header Strict-Transport-Security "max-age=31536000;";
    ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
    charset off;
    index index.html index.php;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/vasia.pp.ua/*.conf;
    access_log /var/www/httpd-logs/vasia.pp.ua.access.log;
    error_log /var/www/httpd-logs/vasia.pp.ua.error.log notice;
    ssi on;
    set $root_path /var/www/vasia/data/www/vasia.pp.ua;
    root $root_path;
    listen 135.452.41.55:443;
    gzip on;
    gzip_comp_level 9;
    gzip_disable "msie6";
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
    expires max;
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
     location / {
                try_files $uri $uri/ /index.php?$args; # permalinks
                }
          }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@vasia.pp.ua";
        fastcgi_pass unix:/var/www/php-fpm/vasia.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}
 
Всё оказалось немного сложнее, чем я думал. Так, что пришлось обращаться на фриланс за помощью. Вот какие правила мне набросал сис. админ:
NGINX:
location / { 
rewrite ^/sitemap.xml$ /index.php?route=feed/google_sitemap last;
    rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last;
    rewrite ^/system/download/(.*) /index.php?route=error/not_found last;
if (!-f $request_filename){
    set $rule_3 1$rule_3;
}
if (!-d $request_filename){
    set $rule_3 2$rule_3;
}
if ($uri !~ ".*.(ico|gif|jpg|jpeg|png|js|css)"){
    set $rule_3 3$rule_3;
}
if ($rule_3 = "321"){
    rewrite ^/([^?]*) /index.php?_route_=$1 last;
}
}
 
Если кому-то будет нужно, могу выложить свой полный файл конфигурации.
 
Статус
Закрита.
Назад
Зверху