Перейти до вмісту
Пошук в
  • Детальніше...
Шукати результати, які ...
Шукати результати в ...

Настройка NGINX в режиме PHP-FPM для OpenCart/ocStore 2.3


Recommended Posts

Здравствуйте. Делаю новый сайт на ocStore 2.3, версия PHP 7.3 и хочу перейти на PHP FastCGI (Nginx + PHP-FPM), помогите настроить фаил конфига nginx.

 

Моя проблема в том что у меня на сайте два языка и добавлена приставка ru и en для разных языков.
Для этого я использую модуль SEO CMS MULTILANG 2 57.0 (мультиязык / мультирегион)

 

Из-за этого такие ссылки не открываются и выдают ошибку 404:
domain.ru/ru/index.php?route=common/currency/currency
domain.ru/en/index.php?route=common/currency/currency

 

Если убираю приставку ru и en то все работает.
domain.ru/index.php?route=common/currency/currency - такая ссылка открывается.

 

Еще пример:
domain.ru/ru/index.php?route=information/information&information_id=4 - не открывается, выдает ошибку 404
Если убираю приставку ru то domain.ru/index.php?route=information/information&information_id=4 открывается

 

Если ставлю обработчик PHP CGI 7.3 то все работает так что дело не в модуле.

 

Код конфига:

server {
	server_name domain.ru www.domain.ru;
	charset off;
	index index.php index.html;
	disable_symlinks if_not_owner from=$root_path;
	include /etc/nginx/vhosts-includes/*.conf;
	include /etc/nginx/vhosts-resources/domain.ru/*.conf;
	access_log /var/www/httpd-logs/domain.ru.access.log;
	error_log /var/www/httpd-logs/domain.ru.error.log notice;
	set $root_path /var/www/user/data/www/domain.ru;
	root $root_path;
	
location / {
    #Редирект с без www на www
    if ($http_host ~ "^domain.ru"){
    rewrite ^(.*)$ https://www.domain.ru$1 redirect;
    }
	
    if (!-e $request_filename){
    rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }

    location ~ [^/]\.ph(p\d*|tml)$ {
        try_files /does_not_exists @php;
    }

    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
        expires 365d;
    }
}

	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/3.sock;
		fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
		try_files $uri =404;
		include fastcgi_params;
	}
	return 301 https://$host:443$request_uri;
	ssi on;
	listen 185.197.160.60:80;
}
server {
	server_name domain.ru www.domain.ru;
	ssl_certificate "/var/www/httpd-cert/user/domain.ru_le1.crtca";
	ssl_certificate_key "/var/www/httpd-cert/user/domain.ru_le1.key";
	ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
	ssl_prefer_server_ciphers on;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
	ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
	charset off;
	index index.php index.html;
	disable_symlinks if_not_owner from=$root_path;
	include /etc/nginx/vhosts-includes/*.conf;
	include /etc/nginx/vhosts-resources/domain.ru/*.conf;
	access_log /var/www/httpd-logs/domain.ru.access.log;
	error_log /var/www/httpd-logs/domain.ru.error.log notice;
	set $root_path /var/www/user/data/www/domain.ru;
	root $root_path;

location / {
    #Редирект с без www на www
    if ($http_host ~ "^domain.ru"){
    rewrite ^(.*)$ https://www.domain.ru$1 redirect;
    }
	
    if (!-e $request_filename){
    rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }

    location ~ [^/]\.ph(p\d*|tml)$ {
        try_files /does_not_exists @php;
    }

    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
        expires 365d;
    }
}

	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/3.sock;
		fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
		try_files $uri =404;
		include fastcgi_params;
	}
	add_header Strict-Transport-Security "max-age=31536000;";
	ssi on;
	listen 185.197.160.60:443 ssl;
}
Надіслати
Поділитися на інших сайтах


  • 6 months later...
16.12.2022 в 14:31, markimax сказал:

Доброго

Так, це не вірно налаштований config nginx

 

Підкажіть як можна налаштувати

не працює

try_files $uri $uri/ @opencart;
  }

  location @opencart {
    rewrite ^/(.+)$ /index.php?_route_=$1 last;
  }
 
}

Надіслати
Поділитися на інших сайтах


В 11.07.2023 в 00:59, param сказав:

 

Підкажіть як можна налаштувати

не працює

try_files $uri $uri/ @opencart;
  }

  location @opencart {
    rewrite ^/(.+)$ /index.php?_route_=$1 last;
  }
 
}

 

Надіслати
Поділитися на інших сайтах

Створіть аккаунт або увійдіть для коментування

Ви повинні бути користувачем, щоб залишити коментар

Створити обліковий запис

Зареєструйтеся для отримання облікового запису. Це просто!

Зареєструвати аккаунт

Вхід

Уже зареєстровані? Увійдіть тут.

Вхід зараз
  • Зараз на сторінці   0 користувачів

    • Ні користувачів, які переглядиють цю сторінку

×
×
  • Створити...

Important Information

На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність.