php scripts in subdir

Discussion in 'General' started by Arianna, Mar 16, 2016.

  1. Arianna

    Arianna Member

    Hi everybody,

    after our discussion about contao I moved homes mount point and now my sites are mounted under /var/www/clients as required.
    I have a site with wordpress (it works well), but under the root directory they have a dir with a php script that should list the dir content.
    If I execute it from prompt it works
    # php index.php
    <HTML><BODY><pre>
    <A HREF="cslarch.rdf">cslarch.rdf</A>
    <A HREF="cslseri.rdf">cslseri.rdf</A>
    <A HREF="devewp/">devewp/</A>
    </pre></BODY></HTML>

    but in the browser the page is empty
    <html>
    <head></head>
    <body>
    <pre></pre>
    </body>
    </html>

    Any idea?
    A.
     
  2. Arianna

    Arianna Member

    the root directory is the document root..... :)
     
  3. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    Are the directories it should display also within the same document_root?
    Put
    Code:
    <?php
    ini_set('display_errors', 1);
    
    to your code to see any issues.
     
  4. Arianna

    Arianna Member

    Yes, they are.
    The script is in /var/www/clients/client29/web42/web/RePEc/csl with other files.
    I added the line you suggested without any kind of output.

    A.
     
  5. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    The only reason I could think of is a wrong path within the script / script uses relative paths and gets executed in a non-expected context of folders without looking at the code / url call.
     
  6. Arianna

    Arianna Member

    I put echo getcwd() . "\n"; in the code and I get
    /var/www/clients/client29/web42/web/RePEc/csl

    But echo exec('whoami'); returns "apache" even if the site is configured to use php-fpm
    web42 18013 17988 0 15:03 ? 00:00:00 php-fpm: pool web42
    web42 18014 17988 0 15:03 ? 00:00:00 php-fpm: pool web42

    ?
    A.
     
  7. Arianna

    Arianna Member

    ..if I put the script in the document root it works......
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Please check that you dont have a .htaccess file in that directory that tries to enable mod_php for the .php extension and check the .htaccess file in the web root as well.
     
  9. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    it should not return apache, maybe an issue with your vhost config?
    Check wether your setting ( php as fpm ) has been written to the apache vhost file or if there is an .err file.
    The fpm processes might spawn anyway.
     
  10. Arianna

    Arianna Member

    in the web root there's the default wordpress .htaccess file and in the RePEc/csl no .htaccess file
     
  11. Arianna

    Arianna Member

    No .err file. But how can I check if fpm has been written? Non fpm strings in the vhost file.

    :(
    A.
     
  12. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    the .err file would be in /etc/apache/sites-available
    But you could try switching PHP versions to any other and back to FPM, the issue could have several causes - maybe they're sorted out already?
     
  13. Arianna

    Arianna Member

    changing from fpm to fast-cgi it works......

    A.
     
  14. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    And back to FPM aswell? Running as FastCGI is not the best option ... Then check again if there's an .err file
     
  15. Arianna

    Arianna Member

    No. It doesn't. No .err file. In every .vhost file there are <IfModule mod_fcgid.c> sections, but none aboute php-fpm.
    In ISPConfig I can configure FGI for the default version of php, and for any additional verison available also FPM.
    Could be here the trick?
     
  16. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    Have you enabled mod_fastcgi and actions to make php-fpm work with your apache configuration? The needed extra steps are explained in the howto.
     
  17. Arianna

    Arianna Member

    I followed this tutorial:
    https://www.howtoforge.com/perfect-...l-php-pureftpd-postfix-dovecot-and-ispconfig3

    But with phpinfo I noticed that if I set Fast-CGI I have:
    Server API: CGI/FastCGI
    and the vhost contains:
    [...]
    <IfModule mod_fcgid.c>
    IdleTimeout 300
    ProcessLifeTime 3600
    # MaxProcessCount 1000
    DefaultMinClassProcessCount 0
    DefaultMaxClassProcessCount 100
    IPCConnectTimeout 3
    IPCCommTimeout 600
    BusyTimeout 3600
    </IfModule>
    <Directory /var/www/clients/client13/web36/web>
    <FilesMatch "\.php[345]?$">
    SetHandler fcgid-script
    </FilesMatch>
    FCGIWrapper /var/www/php-fcgi-scripts/web36/.php-fcgi-starter .php
    FCGIWrapper /var/www/php-fcgi-scripts/web36/.php-fcgi-starter .php3
    FCGIWrapper /var/www/php-fcgi-scripts/web36/.php-fcgi-starter .php4
    FCGIWrapper /var/www/php-fcgi-scripts/web36/.php-fcgi-starter .php5
    Options +ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
    [...]

    But if I set PHP-FPM I have:
    Server API: Apache 2.0 Handler
    and vhost contains:
    [...]
    <IfModule mod_fastcgi.c>
    <Directory /var/www/clients/client13/web36/cgi-bin>

    Order allow,deny
    Allow from all
    </Directory>
    <Directory /var/www/clients/client13/web36/web>
    <FilesMatch "\.php[345]?$">
    SetHandler php5-fcgi
    </FilesMatch>
    </Directory>
    Action php5-fcgi /php5-fcgi
    Alias /php5-fcgi /var/www/clients/client13/web36/cgi-bin/php5-fcgi-*-80-sites.unimi.it
    FastCgiExternalServer /var/www/clients/client13/web36/cgi-bin/php5-fcgi-*-80-sites.unimi.it -idle-timeout 300 -host 127.0.0.1:9045 -pass-header Authorization
    </IfModule>
    <IfModule mod_proxy_fcgi.c>
    ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ fcgi://127.0.0.1:9045/var/www/clients/client13/web36/web/$1
    </IfModule>
    [...]

    :'(
    A.
     
  18. Arianna

    Arianna Member

    PS: sorry if I reply after days, but I have a lot of other work to do.....
     
  19. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    It is absolutely correct, ISPConfig refers mod_fcgid as FastCGI and uses the "real" FastCGI module for php-fpm.
    You might want to
    Code:
    yum install mod_fastcgi php-fpm
    
    And disable Loadmodule of mod_proxy_fcgi if you don't need it - else you have to patch the ISPConfig template because in its current implementation I'd consider it buggy.
    It's beeing said that mod_proxy_fcgi doesn't work well with sockets on centos but besides that - and more important part - it overrides the php configuration for fastcgi and does not pass additional authentication headers to php.

    If these packages are not available ( mod_fastcgi at least ) you might need to enable rpmforge sources for that.
    https://www.howtoforge.com/using-php5-fpm-with-apache2-on-centos-6.2
     
  20. Arianna

    Arianna Member

    1) I already have installed mod_fastcgi and php-fpm (processes are triggered).
    2) no Loadmodule of mod_proxy_fcgi found in httpd.conf
    3) how can I patch the ISPConfig template?

    thanx thanx thanx
    A.
     

Share This Page