Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


 Share

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