Symfony3 on ISPConfig3.1 : install and issues

Discussion in 'General' started by jbonlinea, Nov 22, 2016.

  1. jbonlinea

    jbonlinea New Member

    Dear all,
    I'm totally new to symfony and a beginer in server set-up, I did quite a huge research but excuse me if the answer is obvious or was just in front of me.
    I know my post is terribly long, but organised fo quick reading, and it reflect how much effort I’ve put into this, so please be kind :)
    I'll really apprecite your help

    BRIEF ISSUE DESCRIPTION
    I installed and want to use the symfony demo they provide
    in dev, everything works smoothly (see below)
    in prod
    • the twig template code area is empty in all the pages,
    • the blog page will show a blank page after two or three visits (actually it seems to be time related not number of visit related)
    However every other pages are, and continue to be displayed properly (apparently at least)
    I've done quite a few testings and it seems that there might be a symlink issue, and/or permission issue, and or a cache issue (every time i empty the cache, the blog page is properly displayed and become blanck after few visits)

    INSTALLING AND TESTING THE DEMO

    once the server is configured (the server is distant, cf. MY CONFIG for details)
    symfony installation without composer
    - followed : http://symfony.com/doc/current/setup.html)
    —> everything was smooth​

    installing the demo (symfony_test.mydomain.com being a vhost created for testing purpose)
    - cd /var/www/symfony_test.mydomain.com/web/
    - symfony demo
    —> console returns successfully installed

    test the requirements (following : http://symfony.com/doc/current/reference/requirements.html)
    - php bin/symfony_requirements
    —> Your system is ready to run Symfony projects
    —> Optional recommendations : intl ICU version installed on your system is outdated (55.1) and does not match the ICU data bundled with Symfony (57.1)​

    edit the /web/config.php file to add my IP and run the script (I'm working on a distant server via ssh/ftp/ and so on)
    —> same result as above​

    ——Everything seems ok ——

    BUMPING INTO THE ISSUE
    ——First navigation : ——
    go to http://symfony_test.mydomain.com/symfony_demo/web/
    - looks cool
    - after few clicks, http://symfony_test.mydomain.com/symfony_demo/web/en/blog/
    —> return a blank page
    after two or three visit of http://symfony_test.mydomain.com/symfony_demo/web/en/blog/, where ever I reach there from, it returns a black page. However every other pages are, and continue to be displayed properly (apparently at least)

    LOGS
    —> in firebug, the network tab returns an « 500 internal server error », but agin the page displayed is blank, firebug report :
    Code:
    Connection close
    Content-Length 0
    Content-Type text/html; charset=UTF-8
    Date Tue, 22 Nov 2016 18:14:09 GMT
    Server Apache/2.4.18 (Ubuntu)
    
    Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Encoding gzip, deflate
    Accept-Language fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
    Connection keep-alive
    Cookie PHPSESSID=l9276sd3eh94u90hhdi0mv9rl2
    Host symfony_test.mydomain.com
    Referer http://symfony_test.mydomain.com/symfony_demo/web/fr
    Upgrade-Insecure-Requests 1
    User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:50.0) Gecko/20100101 Firefox/50.0
    —> Apache vhost log

    —> Symfony logs
    I have no prod.log
    I have a dev.log, containing this kind of lines :
    • [2016-11-22 19:38:49] request.INFO: Matched route "{route}". {"route":"_wdt","route_parameters":{"_controller":"web_profiler.controller.profiler:toolbarAction","token":"eb7d27","_route":"_wdt"},"request_uri":"http://symfony_test.mydomain.com/symfony_demo/web/app_dev.php/_wdt/eb7d27","method":"GET"} []
    • [2016-11-22 19:38:49] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
     
    Last edited: Nov 22, 2016
  2. jbonlinea

    jbonlinea New Member

    APACHE CONFIG
    —> MY CONFIG
    - ubuntu 16.04 LTS, Apache 2.4, PHP 7 in Fast-CGI mode ; all is up to date
    - ISPConfig 3.1 (up to date auto install script) ; the demo has its own vhost for testing
    (the last point may be where the permissions issues comes form, but that's not so clear)

    —> server configuration
    - followed : http://symfony.com/doc/current/setup/web_server_configuration.html
    —> used the minimum configuration, but took into account that
    - having apache 2.4 involves to replace Order Allow,Deny by Require all granted
    - php-cgi needs RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] to operate​

    —>in ISPConfig,
    - the vhost folder is symlinked thus
    /var/www/symfony_test.mydomain.com -> /var/www/clients/client1/web3/

    - the default .conf file of my vhost contains both
    <Directory /var/www/symfony_test.mydomain.com/web>
    </Directory>

    and
    <Directory /var/www/clients/client1/web3/web>
    </Directory>

    Each filled with the same directives

    Thus, in IPSConf -> web domain (vhost) -> option -> apache directive, I added the directive provided for the minimum configuration
    Code:
    <Directory /var/www/symfony_testmydomain.com/web>
      AllowOverride All
      Require all granted
      Allow from All
    </Directory>
    <Directory /var/www/clients/client1/web3/web>
      AllowOverride All
      Require all granted
      Allow from All
    </Directory>
    <Directory /var/www/symfony_testmydomain.com/>
      Options FollowSymlinks
    </Directory>
    <Directory /var/www/clients/client1/web3/>
      Options FollowSymlinks
    </Directory>
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    - restart apache
    —> server return a error 403 if I try to access to http://symfony_test.mydomain.com/symfony_demo/
    —> apache has taken my directives into account​

    back to the demo (cache cleared)
    —> same as in first navigation​

    By default the .conf contain some directive about which I have two remarks :
    - some option are preceded by a + ; since I’ve read that if an option had a + or a -, then all the option should have a + or -
    —> I thus added a + before the FollowSymlinks requested by the minimum configuration
    - the default .conf already contained Option +FollowSymlinks however for the directories var/www/symfony_test.mydomain.com/web and /var/www/clients/client1/web3/web ; Note, the web folder is included in the /var/www/symfony_testmydomain.com/ and the /var/www/clients/client1/web3/
    —> I thus removed the Option +FollowSymlink affecting the web directory in the default .conf​

    - restart apache
    back to the demo (cache cleared)
    —> same as in first navigation​

    Moreover, ISPConfig recreate the .conf file as it is by default when changed from the ssh terminal
    - I thus tried without the Option +FollowSymlinks specified for the upper level (/var/www/symfony_testmydomain.com/ and /var/www/clients/client1/web3/)
    —> but no changes​

    I’ve also played with the directive to avoir duplicates between ISPConfig default directives and the required ones by the minimum configuration
    All together the issue remain and the logs stay the same

    .HTACCESS
    I tried to rename the .htaccess file situated in http://symfony_test.mydomain.com/symfony_demo/web/ and go to :
    http://symfony_test.mydomain.com/symfony_demo/web/
    —> I’m not redirected towards app.php
    —> the blog page is blank after two three visits
    However I haven’t tried the optimized configuration that disable .htacces since it requires
    <Directory /var/www/symphony_test.mydomain.com/web>
    AllowOverride None
    </Directory>

    which is opposed to the default ISPConfig directive
    <Directory /var/www/symfony_test.mydomain.com/web>
    AllowOverride All
    </Directory>


    TEST IN THE DEV ENVIRONMENT
    well it works smoothly !
    I’ve read that in dev environment the cache was rebuilt at every request, that’s one thing that took me on the way to cache…
    but remember I had two issues, first /web/en/blog/ returned a black pages after the second or third call, but wile the "twig template code" area is empty in all the pages in prod mode, in dev mode it’s displayed like a charm !

    I can play with the toolbar and access to /web/app_dev.php/profiler
    There are no missing messages

    —>SYMFONY_DEMO_KERNEL—>
    - changing $kernel = new AppKernel('prod', false); to $kernel = new AppKernel('prod', true); in /web/app.php
    —> Solved one of the two issues
    —> the "twig template code" area is filled​
    but
    —> the blog page remain blank after two or three visits and the vhost log remain the same :
    —> [Tue Nov 22 20:09:57.194561 2016] [fcgid:warn] [pid 5972] [client my.ip.adress.here:port] mod_fcgid: stderr: PHP Fatal error: Cannot declare class Symfony\\Component\\HttpFoundation\\Response, because the name is already in use in /var/www/clients/client1/web3/web/symfony_demo/var/cache/prod/classes.php on line 3745, referer: http://symfony_test.mydomain.com/sy.../ut-eleifend-mauris-et-risus-ultrices-egestas

    —> TESTING THE CACHE —>
    emptying the cache in the console
    php bin/console cache:clear --env=prod
    php bin/console cache:clear --env=dev

    —> [OK] …

    back to the demo
    —> same as in first navigation
    I’ve also tried to remove the caches the hard way (rm -rf)

    —> SET UP AND FIX PERMISSIONS —>
    (followed: http://symfony.com/doc/current/setup/file_permissions.html)

    First try (logged in as root via ssh) :
    - HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
    - setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var
    - setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var
    - ls -l
    —> drwxrwxr-x+ 5 web3 client1 4096 nov. 13 21:36 var
    —> there is a + so the ACL are properly set up​

    Second try (logged in as root via ssh) :
    - uncomment umask(0000); in /bin/console and in /web/app_dev.php
    - add umask(0000); in /web/app.php right after (two test, one at a time) :
    - <?php
    - use Symfony\Component\HttpFoundation\Request;

    Third try
    - chmod 777 /var
    - chmod 777 /var/cache
    - chmod 777 /var/logs

    Fourth
    - chmod 777 /web

    —> COMBINED TESTS —>
    Trying all the above one by one, two by two, all together, while rebooting apache and the server and clearing cache at every step

    - clearing cache
    - re-testing the requirement
    —> Ok, same result as above​

    As I started to get mad I tried
    - chmod -R 777 /var/www/symfony_test.mydomain.com/web/symfony_demo
    —> but hell, still not solved
    Wonder if there are really any permission issues, maybe not !

    —>PHP CONFIG—>
    PDO-SQLite PHP extension
    —> enabled (v 3.11.0), as required by the symfony_demo according to symfony_demo/REDME.md​

    OpenBasedir
    —> as defined by ISPConfig, URL of the symfony demo : /var/www/symfony_test.mydomain.com/web:​
    Code:
    /var/www/clients/client1/web3/web:
    /var/www/clients/client1/web3/private:
    /var/www/clients/client1/web3/tmp:
    /var/www/symfony_test.mydomain.com/web:
    /srv/www/symfony_test.mydomain.com/web:
    /usr/share/php5:
    /usr/share/php:
    /tmp:
    /usr/share/phpmyadmin:
    /etc/phpmyadmin:
    /var/lib/phpmyadmin
    
    —> should not be an issue

    LAST WORD

    Oh you're still here ?! me too ! I'm so stuck !
    spend my day reading tuto, docs, and post
    must have a way to run synfomy3 on ISPConfig3.1

    You rock
    Regards
    J.
     
    Last edited: Nov 22, 2016

Share This Page