cancel
Showing results for 
Search instead for 
Did you mean: 

Nginx and Magento2: symbolic link to pub folder from child directory

Nginx and Magento2: symbolic link to pub folder from child directory

I have site on Magento 2.2.6. and in the root directory

 

/var/www/www-root/data/www/market.loc

 

I have subfolders like france/ , germany, poland/ .

 

Each subfolder has index.php and symblic link to pub/ folder that in parent(root) directory.

 

# ls -al/var/www/www-root/data/www/market.loc/france/
total 24
drwxrwxrwx  2 www-root www-data  4096 Sep  7 15:27 .
drwxr-xr-x 37 www-root www-data  4096 Jan 24 17:04 ..
-rwxrwxrwx  1 www-root www-data 11723 Sep  7 15:27 .htaccess
-rwxrwxrwx  1 www-root www-data  1602 Jan 23 20:16 index.php
lrwxrwxrwx  1 www-root www-data     6 Sep  7 15:27 pub -> ../pub

and when I load http://market/france then get correct html, but without static.. 

so 

http://market.loc/france/media/image1.png

not found.

 

Here is my index.php

 

<?php

try { require __DIR__ . '/../app/bootstrap.php'; } catch (\Exception $e) { echo <<<HTML <div style="font:12px/1.35em arial, helvetica, sans-serif;"> <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"> <h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;"> Autoload error</h3> </div> <p>{$e->getMessage()}</p> </div> HTML; exit(1); } $params = $_SERVER;

$params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [
DirectoryList::PUB => [DirectoryList::URL_PATH => ''],
DirectoryList::MEDIA => [DirectoryList::URL_PATH => 'media'],
DirectoryList::STATIC_VIEW => [DirectoryList::URL_PATH => 'static'],
DirectoryList::UPLOAD => [DirectoryList::URL_PATH => 'media/upload'],
];
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store'; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'fr'; $params['GEO_REGION'] = 'france'; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); /** @var \Magento\Framework\App\Http $app */ $app = $bootstrap->createApplication(\Magento\Framework\App\Http::class); $bootstrap->run($app);

 

and virtualhost:

 

upstream fastcgi_backend {
  server  unix:/var/www/php-fpm/www-root.sock;
}

server {
        server_name market.loc www.market.loc;
        index index.php index.html;
        include /etc/nginx/vhosts-includes/*.conf;
        include /etc/nginx/vhosts-resources/market.loc/*.conf;
        access_log /var/www/httpd-logs/market.loc.access.log;
        error_log /var/www/httpd-logs/market.loc.error.log notice;
        ssi on;
        set $MAGE_ROOT /var/www/www-root/data/www/market.loc;
        include /var/www/www-root/data/www/market.loc/nginx.conf.sample;
        listen 127.0.0.1:80;
}

I tried to add to nginx.conf option 

disable_symlinks off;

but still cannot load static. 

 

Thanks for any help and advise.