Страница 1 из 1
Ngnix + Openserver 6 + Opencart
Добавлено: 05 дек 2024, 11:56
greenzlat
Не могу настроить nginx на OSP6.
конфиг проекта:
[sborka.site]
aliases = www sborka.site
enabled = on
environment = System
ip = auto
nginx_engine = Nginx-1.26
node_engine =
php_engine = PHP-7.4-FCGI
project_dir = {base_dir}
project_url = https://{host_decoded}
public_dir = {base_dir}
ssl = on
ssl_cert_file = auto
ssl_key_file = auto
start_command =
terminal_codepage = 65001
HOST = MySQL-5.6
Не создавая конфиг nginx - в логах высвечивается следующее:
nginx: [warn] conflicting server name "sborka.site" on 127.127.126.63:80, ignored
nginx: [warn] conflicting server name "sborka.site" on 127.127.126.63:443, ignored
Прописываю конфиг для nginx в файле sborka.site\.osp\nginx\sborka.site.conf
location / {
#ЧПУ
if (!-e $request_filename){
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
}
Страница
https://sborka.site/robots.txt грузится нормально.
А
https://sborka.site/ - не загружается - выскакивает окно сохранения страницы.
Подскажите куда копать, какой конфиг внести, чтобы в логах не было ошибок?
Re: Ngnix + Openserver 6 + Opencart
Добавлено: 05 дек 2024, 14:56
Ink0gnit0
@greenzlat,
Попробуйте в такой конфигурации:
- [КОРЕНЬ_OSP]\home\sborka.site\.osp\
project.ini
[sborka.site]
php_engine = PHP-7.4-FCGI
nginx_engine = Nginx-1.26
- [КОРЕНЬ_OSP]\home\sborka.site\.osp\nginx\
sborka.site.conf
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
#ЧПУ
if (!-e $request_filename){
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
try_files $uri $uri/ =404;
# try_files $uri $uri/ /index.php$is_args$args;
}
location ~ [^/]\.php(/|$) {
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass $php_server:9000;
include fastcgi.conf;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location ~ /\. {
deny all;
}
Re: Ngnix + Openserver 6 + Opencart
Добавлено: 05 дек 2024, 16:12
greenzlat
Ink0gnit0 писал(а): ↑05 дек 2024, 14:56
@greenzlat,
Попробуйте в такой конфигурации:
- [КОРЕНЬ_OSP]\home\sborka.site\.osp\
project.ini
[sborka.site]
php_engine = PHP-7.4-FCGI
nginx_engine = Nginx-1.26
- [КОРЕНЬ_OSP]\home\sborka.site\.osp\nginx\
sborka.site.conf
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
#ЧПУ
if (!-e $request_filename){
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
try_files $uri $uri/ =404;
# try_files $uri $uri/ /index.php$is_args$args;
}
location ~ [^/]\.php(/|$) {
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass $php_server:9000;
include fastcgi.conf;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location ~ /\. {
deny all;
}
Так не помогло. Сайт работает, но ЧПУ не работает.
Вот конфиг с VDS рабочий:
location / {
index index.php index.html;
# try_files $uri $uri/ /index.php?$args;
#cronos start
#location ~ [^/]\.ph(p\d*|tml)$ {
# try_files /does_not_exists @php;
#}
#ЧПУ
if (!-e $request_filename){
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
#точки входа для вызова php
location ~ ^/(index|admin/index)\.php {
try_files /does_not_exists @php;
}
#запрещаем доступ для всех остальных файлов с расширением php, чтобы не открывались как обычные текстовые файлы
location ~* \.(php|log|tpl|txt|twig|xml|ini)$ {
deny all;
}
#запрещаем открытие файлов, начинающихся с точки
location ~ /\. {
deny all;
}
#запрещаем открытие файлов из директории system
location ~ ^/system/ {
deny all;
}
#разрешаем доступ к robots
location = /robots.txt {
allow all;
}
#разрешаем доступ к sitemap.xml и делаем рерайт правило, либо меняем на другой route
location = /sitemap.xml {
allow all;
rewrite ^/(.*)$ /index.php?route=extension/feed/google_sitemap last;
}
location = /sitemappage.xml {
allow all;
rewrite ^/(.*)$ /index.php?route=extension/feed/yandex_sitemap last;
}
#cronos end
}
location @php {
include fastcgi_params;
fastcgi_pass $php_server:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass $php_server:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
Но на локалке не работает ЧПУ
Re: Ngnix + Openserver 6 + Opencart
Добавлено: 05 дек 2024, 18:16
Ink0gnit0
Rewrite блока конфигурационного файла:
#ЧПУ
if (!-e $request_filename){
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
, сработает на VDS c ОС Linux (например, /opt/storage/file.bin)
Для Windows, не учитывается наименование диска в полному пути к файлу (например, C:/osp/storage/file.bin). Попробуйте убрать "/":
#ЧПУ
if (!-e $request_filename){
rewrite ^(.+)$ /index.php?_route_=$1 last;
}
Re: Ngnix + Openserver 6 + Opencart
Добавлено: 06 дек 2024, 12:21
greenzlat
Неа, не помогло