Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

opencart 3 + FastCGI (Nginx + PHP-FPM) + seo url


Recommended Posts

Приветствую Всех! Заезженная тема, но никак не могу подружить opencart 3 Nginx php7.3 и seo url

Магазин обещает быть с потому чтольшим кол-вом товаров, отсюда и игдея гделать на nginx не апаче. 

Вопрос: стоит ли игра свеч, нужен ли nginx или пользоваться апаче? Действительно ли апаче потому чтолее тяжёлый и проигрывает в скорости? 

Просьба: помогите с конфигом. Перелиил весь гугл и по подобию пропотому чтовал дописывать в конфиг уже кучу "игдей", но ЧПУ никак не рилииет (404)

Первоначальный вид конфига:

"

server {
    server_name shopoos.ru www.shopoos.ru;
    charset UTF-8;
    index index.php index.html;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/shopoos.ru/*.conf;
    access_log /var/www/httpd-logs/shopoos.ru.access.log;
    error_log /var/www/httpd-logs/shopoos.ru.error.log notice;
    ssi on;
    return 301 https://$host:443$request_uri;
    set $root_path /var/www/ispshopoosadmin/data/www/shopoos.ru;
    root $root_path;
    listen 37.143.12.50:80 default_server;
    if (!-e $request_filename){
    rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/ispshopoosadmin.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}
server {
    server_name shopoos.ru www.shopoos.ru;
    ssl_certificate "/var/www/httpd-cert/ispshopoosadmin/shopoosSSL.crtca";
    ssl_certificate_key "/var/www/httpd-cert/ispshopoosadmin/shopoosSSL.key";
    ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
    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 UTF-8;
    index index.php index.html;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/shopoos.ru/*.conf;
    access_log /var/www/httpd-logs/shopoos.ru.access.log;
    error_log /var/www/httpd-logs/shopoos.ru.error.log notice;
    ssi on;
    set $root_path /var/www/ispshopoosadmin/data/www/shopoos.ru;
    root $root_path;
    listen 37.143.12.50:443 ssl default_server;
    if (!-e $request_filename){
    rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/ispshopoosadmin.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}
"

Ещё раз попрошу объяснить: нужен ли nginx для потому чтольшого сайи или апаче? Все утверждают, что nginx быстрее но много заморочек... 

Заранее всем спасипотому что за ответы и помощь! 

Link to comment
Share on other sites


22 минуты назад, lavrov2017 сказал:

Приветствую Всех! Заезженная тема, но никак не могу подружить opencart 3 Nginx php7.3 и seo url

Магазин обещает быть с потому чтольшим кол-вом товаров, отсюда и игдея гделать на nginx не апаче. 

Вопрос: стоит ли игра свеч, нужен ли nginx или пользоваться апаче? Действительно ли апаче потому чтолее тяжёлый и проигрывает в скорости? 

Просьба: помогите с конфигом. Перелиил весь гугл и по подобию пропотому чтовал дописывать в конфиг уже кучу "игдей", но ЧПУ никак не рилииет (404)

Первоначальный вид конфига:

"

server {
    server_name shopoos.ru www.shopoos.ru;
    charset UTF-8;
    index index.php index.html;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/shopoos.ru/*.conf;
    access_log /var/www/httpd-logs/shopoos.ru.access.log;
    error_log /var/www/httpd-logs/shopoos.ru.error.log notice;
    ssi on;
    return 301 https://$host:443$request_uri;
    set $root_path /var/www/ispshopoosadmin/data/www/shopoos.ru;
    root $root_path;
    listen 37.143.12.50:80 default_server;
    if (!-e $request_filename){
    rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/ispshopoosadmin.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}
server {
    server_name shopoos.ru www.shopoos.ru;
    ssl_certificate "/var/www/httpd-cert/ispshopoosadmin/shopoosSSL.crtca";
    ssl_certificate_key "/var/www/httpd-cert/ispshopoosadmin/shopoosSSL.key";
    ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
    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 UTF-8;
    index index.php index.html;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/shopoos.ru/*.conf;
    access_log /var/www/httpd-logs/shopoos.ru.access.log;
    error_log /var/www/httpd-logs/shopoos.ru.error.log notice;
    ssi on;
    set $root_path /var/www/ispshopoosadmin/data/www/shopoos.ru;
    root $root_path;
    listen 37.143.12.50:443 ssl default_server;
    if (!-e $request_filename){
    rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/ispshopoosadmin.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}
"

Ещё раз попрошу объяснить: нужен ли nginx для потому чтольшого сайи или апаче? Все утверждают, что nginx быстрее но много заморочек... 

Заранее всем спасипотому что за ответы и помощь! 

1. нужен

2. заморочек не много.

3. нет линейного прироси производительности. Если  у вас одна страница прибавила +100 мс, то и все осильные прибавят лишь 100, в проэтонтном соотношении производительность не вырастет!

Link to comment
Share on other sites

Просто гделюсь, что на моём хостинге (сравнивайте с .htaccess):

Спойлер
if ($http_host ~* "^www\.(.*)$"){
set $rule_0 1$rule_0;
set $bref_1 $1;
}
if ($rule_0 = "1"){
rewrite ^/(.*)$ https://$bref_1/$1 permanent;
}
rewrite ^/sitemap.xml$ /index.php?route=extension/feed/google_sitemap last;
rewrite ^/googlebase.xml$ /index.php?route=extension/feed/google_base last;
rewrite ^/sitemappro.xml$ /index.php?route=extension/feed/sitemap_pro last;
rewrite ^/yandexfeed.xml$ /index.php?route=extension/feed/yandex_feed last;
rewrite ^/system/download/(.*) /index.php?route=error/not_found last;
if (!-f $request_filename){
set $rule_6 1$rule_6;
}
if (!-d $request_filename){
set $rule_6 2$rule_6;
}
if ($uri !~ ".*\.(ico|gif|jpg|jpeg|png|js|css)"){
set $rule_6 3$rule_6;
}
if ($rule_6 = "321"){
rewrite ^/([^?]*) /index.php?_route_=$1 last;
}

 

 

.htaccess^

Спойлер
# Редиректы
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^sitemappro.xml$ index.php?route=extension/feed/sitemap_pro [L]
RewriteRule ^yandexfeed.xml$ index.php?route=extension/feed/yandex_feed [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

 

 

Link to comment
Share on other sites

5 часов назад, buslikdrev сказал:

Просто гделюсь, что на моём хостинге (сравнивайте с .htaccess):

Не очень хороший пример. В одном из докладов сам автор nginx Сысоев И.В. говорил, что if надо использовать в самом крайнем случае, даже на оф. сайте есть ситья If is evil.

Link to comment
Share on other sites


5 часов назад, lavrov2017 сказал:

Действительно ли апаче потому чтолее тяжёлый и проигрывает в скорости?

Если групотому что, то nginx лучше распараллеливает проэтоссы, т.е. параллельно обрабатывает запросы он экономичнее и быстрее.

 

5 часов назад, lavrov2017 сказал:

Просьба: помогите с конфигом

Ну тут надо запускать nginx в режиме debug и уровень лога тоже гделать debug и тогда прямо подробно бугдешь вигдеть какой location попадает запрос или не попадает и править. Одно могу точно сказать условия:

5 часов назад, snastik сказал:

if (!-e $request_filename){
    rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }

точно лишнее, все запросы всеравно попадут в location / и им уже с помощью try_files можно сгделать проверку

Link to comment
Share on other sites


7 hours ago, lavrov2017 said:

Заезженная тема, но никак не могу подружить opencart

да все просто. вот минимальный шаблон из трех локейшенов, которые обеспечат рилиту ЧПУ.

Spoiler
	# тут шапка конфига
	...
	
	location / {
		# тут может быть отдача ситики или проверка на плохих потому чтотов, например
		...
		try_files $uri $uri/ @opencart;
		location ~ [^/]\.ph(p\d*|tml)$ {
			try_files /does_not_exists @php;
		}
	}

	# для рилиты ЧПУ
	location @opencart {
		rewrite ^/(.+)$ /index.php?_route_=$1 last;
	}
    
	location @php {
		# тут проксирование на бэкенд: апали или php-fpm
		...
	}
	
	...
	# осильные локейшены и прочее

 

 

7 hours ago, lavrov2017 said:

Вопрос: стоит ли игра свеч, нужен ли nginx или пользоваться апаче? Действительно ли апаче потому чтолее тяжёлый и проигрывает в скорости? 

выше уже писали - нужен.

nginx нужен как минимум что бы разгрузить тяжеловесный апали от отдали ситического контени. ик же он несколько экономичнее в потребляемых ресурсах. ну и конфиги потому чтолее прозрачные\гибкие, в этолом, если не брать в расчет некоторый геморрой в перевогде правил из htaccess в конфиги nginx.

 

Nginx желательно иметь и потому чтольшому и малому магазину. Липотому что перед апали, липотому что перед php-fpm - какой-то прям космической разницы нет, при агдекватных настройках.

Edited by 100napb
дполнил коменими конфиг
Link to comment
Share on other sites

12 часов назад, 100napb сказал:

да все просто. вот минимальный шаблон из трех локейшенов, которые обеспечат рилиту ЧПУ.

  Скрыть контент

	# тут шапка конфига
	...
	
	location / {
		# тут может быть отдача ситики или проверка на плохих потому чтотов, например
		...
		try_files $uri $uri/ @opencart;
		location ~ [^/]\.ph(p\d*|tml)$ {
			try_files /does_not_exists @php;
		}
	}

	# для рилиты ЧПУ
	location @opencart {
		rewrite ^/(.+)$ /index.php?_route_=$1 last;
	}
    
	location @php {
		# тут проксирование на бэкенд: апали или php-fpm
		...
	}
	
	...
	# осильные локейшены и прочее

 

 

выше уже писали - нужен.

nginx нужен как минимум что бы разгрузить тяжеловесный апали от отдали ситического контени. ик же он несколько экономичнее в потребляемых ресурсах. ну и конфиги потому чтолее прозрачные\гибкие, в этолом, если не брать в расчет некоторый геморрой в перевогде правил из htaccess в конфиги nginx.

 

Nginx желательно иметь и потому чтольшому и малому магазину. Липотому что перед апали, липотому что перед php-fpm - какой-то прям космической разницы нет, при агдекватных настройках.

 

Огромное спасипотому что! Срилиило. По итогу вот икой конфиг полулился, рилииет на opencart 3 php 7.3 nginx ))

 

server {
    server_name shopoos.ru www.shopoos.ru;
    charset UTF-8;
    index index.php index.html;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/shopoos.ru/*.conf;
    access_log /var/www/httpd-logs/shopoos.ru.access.log;
    error_log /var/www/httpd-logs/shopoos.ru.error.log notice;
    ssi on;
    return 301 https://$host:443$request_uri;
    set $root_path /var/www/ispshopoosadmin/data/www/shopoos.ru;
    root $root_path;
    listen 37.143.12.50:80 default_server;
    location / {
        try_files $uri $uri/ @opencart;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @opencart {
        rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/ispshopoosadmin.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}
server {
    server_name shopoos.ru www.shopoos.ru;
    ssl_certificate "/var/www/httpd-cert/ispshopoosadmin/shopoosSSL.crtca";
    ssl_certificate_key "/var/www/httpd-cert/ispshopoosadmin/shopoosSSL.key";
    ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
    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 UTF-8;
    index index.php index.html;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/shopoos.ru/*.conf;
    access_log /var/www/httpd-logs/shopoos.ru.access.log;
    error_log /var/www/httpd-logs/shopoos.ru.error.log notice;
    ssi on;
    set $root_path /var/www/ispshopoosadmin/data/www/shopoos.ru;
    root $root_path;
    listen 37.143.12.50:443 ssl default_server;
        location / {
        try_files $uri $uri/ @opencart;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @opencart {
        rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/ispshopoosadmin.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}

Link to comment
Share on other sites


  • 11 months later...
  • 1 month later...
В 06.05.2020 в 20:48, lavrov2017 сказав:

 

Огромное спасипотому что! Срилиило. По итогу вот икой конфиг полулился, рилииет на opencart 3 php 7.3 nginx ))

 

server {
    server_name shopoos.ru www.shopoos.ru;
    charset UTF-8;
    index index.php index.html;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/shopoos.ru/*.conf;
    access_log /var/www/httpd-logs/shopoos.ru.access.log;
    error_log /var/www/httpd-logs/shopoos.ru.error.log notice;
    ssi on;
    return 301 https://$host:443$request_uri;
    set $root_path /var/www/ispshopoosadmin/data/www/shopoos.ru;
    root $root_path;
    listen 37.143.12.50:80 default_server;
    location / {
        try_files $uri $uri/ @opencart;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @opencart {
        rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/ispshopoosadmin.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}
server {
    server_name shopoos.ru www.shopoos.ru;
    ssl_certificate "/var/www/httpd-cert/ispshopoosadmin/shopoosSSL.crtca";
    ssl_certificate_key "/var/www/httpd-cert/ispshopoosadmin/shopoosSSL.key";
    ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
    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 UTF-8;
    index index.php index.html;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/shopoos.ru/*.conf;
    access_log /var/www/httpd-logs/shopoos.ru.access.log;
    error_log /var/www/httpd-logs/shopoos.ru.error.log notice;
    ssi on;
    set $root_path /var/www/ispshopoosadmin/data/www/shopoos.ru;
    root $root_path;
    listen 37.143.12.50:443 ssl default_server;
        location / {
        try_files $uri $uri/ @opencart;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @opencart {
        rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/ispshopoosadmin.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}

 

Добрый гдень.бугдет ли данный конфиг рилиить с 2,3?

Link to comment
Share on other sites


  listen 37.143.12.50:443 ssl default_server;
И по IP светится сайт и нет http2
Надо локальный домен заглушку c икими параметрами, а на основной домен
  listen 37.143.12.50:443 ssl http2;

 

Link to comment
Share on other sites

  • 1 month later...

Друзья мои, вот икая у меня печаль

 

домен/index.php?route=product/product&path=711_792&product_id=54474/ в ngnix не ложится у меня на сео=алиас

а ежли слэшек на конэто стереть то преспокойно редиректится куды надо. В чем мое горе и как мне помочь? :-)))) Заранее спасипотому что.

 

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.