php includes not working in virtual sites

Discussion in 'Installation/Configuration' started by dbg1991, May 29, 2019.

  1. dbg1991

    dbg1991 New Member

    I have followed Till Brehm's excellent tutorial Perfect Server - Ubuntu 18.04 and everything seems to be working ok except for php includes on test sites I have set bup using ISPconfig 3.
    phpinfo() works on the default server at /var/www/html
    but not on virtual sites at /var/www/clients/client1/web1 where it just shows a blank screen
    I have set up the site for suPHP and the test index.php runs but without the header and footer includes.
    I've copied the page to /var/www/html and it displays as it should.
    Version PHP 7.2.17-0ubuntu0.18.04.1 (cli) (built: Apr 18 2019 14:12:38) ( NTS )
    In the build I have not bothered with
    Metronome, PHP Opcode, PHP-FPM, HHVM, Mailman or Bind
    Any advice would be very much appreciated
     
  2. MaxT

    MaxT Active Member HowtoForge Supporter

    probably it works but the php error display is disabled.
    Try creating a test.php script "<?php phpinfo(); ?>" inside /var/www/clients/client1/web1

    then locate in the displaying info where is the .ini config file. of your php
    Edit that file to show all errors and other parameters you can need. Then restart both the php-fpm and apache

    # service php7.0-fpm restart (use the php-fpm number version you are using)
    # systemctl restart apache2

    hope it helps
     
  3. dbg1991

    dbg1991 New Member

     
  4. dbg1991

    dbg1991 New Member

    That's the problem - that test script will not work in /var/www/clients/client1/web1 just returns a blank screen as if php not enabled but that script does work in /var/www/html.
    I think it must have something to do with the Apache config
     
  5. MaxT

    MaxT Active Member HowtoForge Supporter

    maybe are not using the same php.ini.
    For this reason I wrote you about checking the php.ini working inside the /var/www/clients/client1/web1.
    To confirm if this is the same.
     
  6. dbg1991

    dbg1991 New Member

    Perhaps I'm not being clear. When I run the test.php script "<?php phpinfo(); ?> in /var/www/clients/client1/web1 not information is displayed at all.
    When I run the same test script in /var/www/html it returns the full list.
    I've checked with a simple testpage2.php and discovered that the virtual host is running it as html and it appears that ISPconfig 3 has not enabled the suPHP for the site.
    I'll see if I can edit the apache config manually.
    Thanks for your help
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    The website directory is /var/www/clients/client1/web1/web and not /var/www/clients/client1/web1
     
  8. dbg1991

    dbg1991 New Member

    Thanks Till that's where I have been running it and there is no php at that location.
    When I set the domain with ispconfig3 I selected SuPHP from the drop down list but as far as I can see this has not been enabled.
    Not sure how to go about getting SuPHP enabled


    Below an extract from /etc/apache2/sites-available
    <Directory /var/www/###.co.uk>
    AllowOverride None
    Require all denied
    </Directory>

    <VirtualHost *:80>

    DocumentRoot /var/www/clients/client1/web1/web

    ServerName ###.co.uk
    ServerAlias www.###.co.uk
    ServerAdmin webmaster@###.co.uk


    ErrorLog /var/log/ispconfig/httpd/###.co.uk/error.log

    Alias /error/ "/var/www/###.co.uk/web/error/"
    ErrorDocument 400 /error/400.html
    ErrorDocument 401 /error/401.html
    ErrorDocument 403 /error/403.html
    ErrorDocument 404 /error/404.html
    ErrorDocument 405 /error/405.html
    ErrorDocument 500 /error/500.html
    ErrorDocument 502 /error/502.html
    ErrorDocument 503 /error/503.html

    <IfModule mod_ssl.c>
    </IfModule>

    <Directory /var/www/###.co.uk/web>
    # Clear PHP settings of this website
    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
    SetHandler None
    </FilesMatch>
    Options +FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>
    <Directory /var/www/clients/client1/web1/web>
    # Clear PHP settings of this website
    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
    SetHandler None
    </FilesMatch>
    Options +FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>




    # suexec enabled
    <IfModule mod_suexec.c>
    SuexecUserGroup web1 client1
    </IfModule>
    # suphp enabled
    <Directory /var/www/clients/client1/web1/web>
    <IfModule mod_suphp.c>
    suPHP_Engine on
    # suPHP_UserGroup web1 client1
    suPHP_ConfigPath /var/www/conf/web1
    <FilesMatch "\.php[345]?$">
    SetHandler x-httpd-suphp
    </FilesMatch>
    suPHP_AddHandler x-httpd-suphp
    </IfModule>
    </Directory>



    # add support for apache mpm_itk
    <IfModule mpm_itk_module>
    AssignUserId web1 client1
    </IfModule>

    <IfModule mod_dav_fs.c>
    # Do not execute PHP files in webdav directory
    <Directory /var/www/clients/client1/web1/webdav>
    <ifModule mod_security2.c>
    SecRuleRemoveById 960015
    SecRuleRemoveById 960032
    </ifModule>
    <FilesMatch "\.ph(p3?|tml)$">
    SetHandler None
    </FilesMatch>
    </Directory>
    DavLockDB /var/www/clients/client1/web1/tmp/DavLock
    # DO NOT REMOVE THE COMMENTS!
    # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
    # WEBDAV BEGIN
    # WEBDAV END
    </IfModule>



    </VirtualHost>
     
  9. dbg1991

    dbg1991 New Member

    A further thought
    there is a php.ini at /var/www/conf/web1
    And the last entry is
    open_basedir = '/var/www/clients/client1/web1/web:/var/www/clients/client1/web1/private:/var/www/clients/client1/web1/tmp:/var/www/###.co.uk/web:/srv/www/###.co.uk/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom'root@802989:/var/www/conf/web1#

    I notice a ref to php5 but not to php7 - could this be significant?
     
  10. dbg1991

    dbg1991 New Member

    A further further thought the ini running on the server indicates Virtual Directory Support disabled. Should this be changed to enabled?
    Extract below:
    System Linux #####.com 4.15.0-50-generic #54-Ubuntu SMP Mon May 6 18:46:08 UTC 2019 x86_64
    Build Date Apr 18 2019 14:12:38
    Server API Apache 2.0 Handler
    Virtual Directory Support disabled
    Configuration File (php.ini) Path /etc/php/7.2/apache2
    Loaded Configuration File /etc/php/7.2/apache2/php.ini
    Scan this dir for additional .ini files /etc/php/7.2/apache2/conf.d
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, this explains the problem. You selected a wrong PHP mode. suphp is an outdated PHP mode which exists only for legacy reasons for some old installations, it should not be used anymore and it will not even work on recent systems. Use php-fpm instead and enable the suexec checkbox of the website.
     
  12. dbg1991

    dbg1991 New Member

    Such a simple solution but php is now working.
    Thank you so much Till & MaxT for your kind advice.
     

Share This Page