Перейти к публикации
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

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


 Поделиться

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

Приветствую Всех! Заезженная тема, но никак не могу подружить 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 быстрее но много заморочек... 

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

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


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. заморочек не много. https://opencart-cms.ru/blog/?p=300

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

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

Просто делюсь, что на моём хостинге (сравнивайте с .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]

 

 

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

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

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

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

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


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

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

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

 

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

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

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

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

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

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

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


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 - какой-то прям космической разницы нет, при адекватных настройках.

Изменено пользователем 100napb
дполнил коментами конфиг
Ссылка на комментарий
Поделиться на других сайтах

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;
    }
}

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


  • 11 месяцев спустя...
  • 1 месяц спустя...
В 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?

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


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

 

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

  • 1 месяц спустя...

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

 

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

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

 

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


Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы оставить комментарий

Создать аккаунт

Зарегистрируйтесь для получения аккаунта. Это просто!

Зарегистрировать аккаунт

Войти

Уже зарегистрированы? Войдите здесь.

Войти сейчас
 Поделиться

×
×
  • Создать...

Важная информация

На нашем сайте используются файлы cookie и происходит обработка некоторых персональных данных пользователей, чтобы улучшить пользовательский интерфейс. Чтобы узнать для чего и какие персональные данные мы обрабатываем перейдите по ссылке. Если Вы нажмете «Я даю согласие», это означает, что Вы понимаете и принимаете все условия, указанные в этом Уведомлении о Конфиденциальности.