AlvaEdison
VIP
Добрый день.
Выкладываю свой вариант конфига nginx, для запуска OpenCart.
Тестирование проводил на третьей версии OpenCart, на других версиях не пробовал, тем не менее на других версиях OpenCart должен работать.
Предполагаю, что конфиг не идеален, так как я в этом не крайне силён.
Если найдутся на данном форуме люди, которые помогут его допилить/переписать - будет здорово, это будет полезно сообществу нашего форма
Конфиг выкладываю ниже, а также дополнительно прикрепляю его вложением.
В конфиге включёны:
В конфиге необходимо заменить информацию:
Если выше я написал что-то не корректно, или не в полной мере - прошу не кидать в меня тапками, а дополнить и поделиться своим опытом,
так как я "новичок-первопроходец" в данном вопросе, как и большинство из нас здесь присутствующих я полагаю.
Конфиг я использовал в ISP панели, если это будет кому-то интересно.
Всем спасибо.
Выкладываю свой вариант конфига nginx, для запуска OpenCart.
Тестирование проводил на третьей версии OpenCart, на других версиях не пробовал, тем не менее на других версиях OpenCart должен работать.
Предполагаю, что конфиг не идеален, так как я в этом не крайне силён.
Если найдутся на данном форуме люди, которые помогут его допилить/переписать - будет здорово, это будет полезно сообществу нашего форма
Конфиг выкладываю ниже, а также дополнительно прикрепляю его вложением.
В конфиге включёны:
- HTTP2.
- Rewrite.
- GZIP на 6 уровень
- Принудительная переадресация на HTTPS
- HSTS
- Включён журнал запросов и ошибок
- Работает ЧПУ
В конфиге необходимо заменить информацию:
- Домен "yourdomain.test" заменяем на свой.
- IP адрес сервера "1.1.1.1" заменяем на свой.
- Проверить, чтобы директива nginx совпадала с той, что в конфиге "include /etc/nginx/..."
- Проверить, чтобы совпадала директива, где находится папка сайта "/var/www/yourusername/data/www;"
- Проверить, чтобы корректно был указан путь к *.sock файлам "/var/www/php-fpm/yourusername.sock;"
- Почту заменить на свою "[email protected]"
Если выше я написал что-то не корректно, или не в полной мере - прошу не кидать в меня тапками, а дополнить и поделиться своим опытом,
так как я "новичок-первопроходец" в данном вопросе, как и большинство из нас здесь присутствующих я полагаю.
Конфиг я использовал в ISP панели, если это будет кому-то интересно.
Всем спасибо.
Код:
server {
server_name yourdomain.test *.yourdomain.test www.yourdomain.test;
charset UTF-8;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/yourdomain.test/*.conf;
access_log /var/www/httpd-logs/yourdomain.test.access.log;
error_log /var/www/httpd-logs/yourdomain.test.error.log notice;
ssi on;
set $root_path /var/www/yourusername/data/www;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
}
set $subdomain yourdomain.test;
if ($host ~* ^((.*).yourdomain.test)$) {
set $subdomain $1;
}
root $root_path/$subdomain;
return 301 https://$host:443$request_uri;
index index.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/yourusername.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
gzip on;
gzip_comp_level 6;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
listen 1.1.1.1:80;
}
server {
server_name yourdomain.test *.yourdomain.test www.yourdomain.test;
ssl_certificate "/var/www/httpd-cert/yourusername/yourdomain.test_le1.crtca";
ssl_certificate_key "/var/www/httpd-cert/yourusername/yourdomain.test_le1.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;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/yourdomain.test/*.conf;
access_log /var/www/httpd-logs/yourdomain.test.access.log;
error_log /var/www/httpd-logs/yourdomain.test.error.log notice;
ssi on;
set $root_path /var/www/yourusername/data/www;
set $subdomain yourdomain.test;
if ($host ~* ^((.*).yourdomain.test)$) {
set $subdomain $1;
}
root $root_path/$subdomain;
autoindex off;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
}
if (!-f $request_filename){
set $rule_3 1$rule_3;
}
if (!-d $request_filename){
set $rule_3 2$rule_3;
}
if ($uri !~ ".*\.(ico|gif|jpg|jpeg|png|js|css)"){
set $rule_3 3$rule_3;
}
if ($rule_3 = "321"){
rewrite ^/([^?]*) /index.php?_route_=$1 last;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|svgz|eot|otf|woff|ttf|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
expires max;
etag on;
log_not_found off;
}
location = /sitemap.xml {
rewrite ^(.*)$ /index.php?route=extension/feed/google_sitemap break;
}
location = /googlebase.xml {
rewrite ^(.*)$ /index.php?route=extension/feed/google_base break;
}
location /system {
rewrite ^/system/storage/(.*) /index.php?route=error/not_found break;
}
location ~* (\.(tpl|ini))$ {
deny all;
}
location ~ (?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt)) {
deny all;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location /index.html {
rewrite ^(.*)$ https://yourdomain.test/ permanent;
}
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/yourusername.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
gzip on;
gzip_comp_level 6;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
listen 1.1.1.1:443 ssl http2;
}
Вложения
-
1.3 KB Просмотры: 13
Последнее редактирование: