3

I use Plesk with nginx as proxy, which is working good. I installed laravel php framework on a subdomain. the framework provides a direcotry "public" for public files, so I changed document_root with a custom vhost.conf file this way:

DocumentRoot "/var/www/vhosts/example.com/laravel.example.com/public"

Now apache is aware of this, PHP files working without any problems, but not the static files which are handeled via nginx, I get 404 not found because I must also reconfig the document_root for nginx.

If I copy the static files, like css or js on the same dir-level as public it works, but the static files should be in "public".

how to reconfig the document root for this nginx vhost now? I tried to add

root /var/www/vhosts/example.com/laravel.example.com/public;

into the server { ... and "then location /" directive ...

to a custom nginx.conf file in the "conf" directroy of plesk for this vhost but dont work.

Danzzz
  • 523
  • 8
  • 26

1 Answers1

4

For Plesk 12.0 and above there UI controls to specify domain's additional nginx/apache directives in "Web Server Settings":

plesk customize nginx config

For Plesk 11.5 you can add custom directive:

  1. mkdir /usr/local/psa/admin/conf/templates/custom/domain

  2. cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/

  3. add in /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php:

    <?php if (file_exists($VAR->domain->physicalHosting->vhostDir . '/conf/nginx.conf')): ?>
        include <?php echo $VAR->domain->physicalHosting->vhostDir;?>/conf/nginx.conf;
    <?php endif ?>
    
  4. /usr/local/psa/admin/bin/httpdmng --reconfigure-all # to apply new configuration for all domains

As result, if domain has conf/nginx.conf - it will be included into virtual host config.

Oleg Neumyvakin
  • 9,706
  • 3
  • 58
  • 62
  • 1
    worked great, thx and sorry for late comeback ... after restarting nginx i have this warnings: nginx: [warn] conflicting server name "laravel.example.com" on 118.xxx.104.xxx:80, ignored ... but i works now – Danzzz Jun 15 '13 at 13:42
  • looks like there is duplication of ServerName directive in conf/nginx.conf. I think you can play around with removing duplicate directives. – Oleg Neumyvakin Jun 15 '13 at 14:16