Apache configuration for cloudControl w/ Symfony2 and Assetic?

221 views Asked by At

I'm having problems to show my generated assets in cloudControl. After assetic:dump the assets are created un the /srv/www/code/web folder but Apache is not accessing them.

This is my Apache configuration (documentroot.conf):

DocumentRoot /app/www/web

<Directory /app/www/web>
    AllowOverride All
    Options SymlinksIfOwnerMatch
    Order Deny,Allow
    Allow from All
    DirectoryIndex app.php

    FallbackResource /app.php
</Directory>

What is the correct Apache configuration to have Assetic working?

Also, can somebody explain me the difference between the /srv/code, the ~/www (alias of the previous one) and /app/www/web (the folder used in cloudControl examples for Apache config)?

My guess was that the /app/www folder in the apache config was accessing ~/www (and so, accessing /srv/code) but I must be missing something.

2

There are 2 answers

0
eillarra On BEST ANSWER

In the end, the problem was not in the folder used in the configuration. Both /srv/www/code/web and /app/www/web work the same (as they should, considering that /app/www is an alias of /srv/www/www which is an alias of /srv/www/code, as well explained by @TooAngel).

The problem was with the assetic:dump command, which for some reason, needs to be called during the build process.

I've added this to the composer.json file, and now it works:

{
    ...
    "scripts": {
        "post-install-cmd": [
            "php app/console cache:clear --env=prod",
            "php app/console assets:install --env=prod",
            "php app/console assetic:dump --env=prod"
         ],
         ...
    },
    ...
}
1
TooAngel On

to get a better understanding of the 'insides' of a container, you can use the Secure Shell to connect to a container and see the actual directory structure. (https://www.cloudcontrol.com/dev-center/Platform%20Documentation#secure-shell-ssh)

  • /srv/www/code is the actual directory where your application code is located
  • /srv/www/www is a symlink to /srv/www/code, because of backward compatibility issues.
  • /app is a symlink to /srv/www, to simplified the path and also to have compatiblity to other buildpacks and PaaS providers.
  • ~/ is /srv/www, so from your example ~/www points to the directory where you application is located.

If your assets are located in /srv/www/code/web you should be able to use:

DocumentRoot /srv/www/code/web

<Directory /srv/www/code/web>
    AllowOverride All
    Options SymlinksIfOwnerMatch
    Order Deny,Allow
    Allow from All
    DirectoryIndex app.php

    FallbackResource /app.php
</Directory>

I hope I covered all your cases and could clear up the situation?!