PHP Not Working

Discussion in 'Installation/Configuration' started by kassie, Jun 5, 2007.

  1. kassie

    kassie New Member

    Hi All,

    Sorry for all the stupid questions...

    I have created a website and checked use php scripts.

    When i go to the site it actually shows the code of index.php and not the page itself.


    Any suggestions??
     
  2. Hans

    Hans Moderator Moderator

    Did you enable php scripts for the website within ISPConfig?
     
  3. kassie

    kassie New Member

     
  4. Hans

    Hans Moderator Moderator

    Hi Kassie,

    What is in your /etc/apache2/vhosts/Vhosts_ispconfig.conf for that website?

    I like to see it, because maybe some modules for php are missing.
     
  5. kassie

    kassie New Member

    <VirtualHost 10.0.2.41:80>
    ServerName www.sabres.za.net:80
    ServerAdmin [email protected]
    DocumentRoot /var/www/web1/web
    ServerAlias sabres.za.net webmail.sabres.za.net
    DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
    ErrorLog /var/www/web1/log/error.log
    php_admin_flag safe_mode Off
    # {STATSALIAS}
    Alias /error/ "/var/www/web1/web/error/"
    ErrorDocument 400 /error/invalidSyntax.html
    ErrorDocument 401 /error/authorizationRequired.html
    ErrorDocument 403 /error/forbidden.html
    ErrorDocument 404 /error/fileNotFound.html
    ErrorDocument 405 /error/methodNotAllowed.html
    ErrorDocument 500 /error/internalServerError.html
    ErrorDocument 503 /error/overloaded.html
    AliasMatch ^/~([^/]+)(/(.*))? /var/www/web1/user/$1/web/$3
    AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web1/user/$1/web/$3
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^webmail\.sabres\.za\.net [NC]
    RewriteRule ^/(.*) http://196.36.108.11:81/webmail/$1 [L,R]
    </VirtualHost>


    The other one is
    <VirtualHost 10.0.2.41:80>
    ServerName www.mfsolutions.co.za:80
    ServerAdmin [email protected]
    DocumentRoot /var/www/web2/web
    ServerAlias www.mfsolutions.co.za
    DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
    ErrorLog /var/www/web2/log/error.log
    php_admin_flag safe_mode Off
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    # {STATSALIAS}
    Alias /error/ "/var/www/web2/web/error/"
    ErrorDocument 400 /error/invalidSyntax.html
    ErrorDocument 401 /error/authorizationRequired.html
    ErrorDocument 403 /error/forbidden.html
    ErrorDocument 404 /error/fileNotFound.html
    ErrorDocument 405 /error/methodNotAllowed.html
    ErrorDocument 500 /error/internalServerError.html
    ErrorDocument 503 /error/overloaded.html
    AliasMatch ^/~([^/]+)(/(.*))? /var/www/web2/user/$1/web/$3
    AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web2/user/$1/web/$3
    </VirtualHost>
     
  6. Hans

    Hans Moderator Moderator

    Some items to verify

    Are there any error messages in Apache's error log?
    (/var/log/apache2/error.log)

    Do you have this line at the end within your /etc/apache2/apache2.conf:

    Include /etc/apache2/vhosts/Vhosts_ispconfig.conf


    Do you have these lines within /etc/apache2/mods-available/dir.conf:


    <IfModule mod_dir.c>

    DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl index.xhtml

    </IfModule>

    Make sure that you've commented out the mime-types within /etc/mime.types like this:


    #application/x-httpd-php phtml pht php
    #application/x-httpd-php-source phps
    #application/x-httpd-php3 php3
    #application/x-httpd-php3-preprocessed php3p
    #application/x-httpd-php4 php4


    After any modification restart Apache2:

    /etc/init.d/apache2 restart
     
  7. kassie

    kassie New Member

    (/var/log/apache2/error.log)
    [Tue Jun 05 20:26:19 2007] [warn] long lost child came home! (pid 26701)
    [Tue Jun 05 21:55:35 2007] [notice] caught SIGTERM, shutting down
    [Tue Jun 05 21:56:37 2007] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
    PHP Warning: Module 'json' already loaded in Unknown on line 0
    [Tue Jun 05 21:56:39 2007] [notice] Apache/2.2.3 (Ubuntu) PHP/5.2.1 mod_ssl/2.2.3 OpenSSL/0.9.8c configured -- resuming normal operations
    [Tue Jun 05 21:56:42 2007] [notice] caught SIGTERM, shutting down
    [Tue Jun 05 21:56:52 2007] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
    PHP Warning: Module 'json' already loaded in Unknown on line 0
    [Tue Jun 05 21:56:52 2007] [notice] Apache/2.2.3 (Ubuntu) PHP/5.2.1 mod_ssl/2.2.3 OpenSSL/0.9.8c configured -- resuming normal operations
     
  8. kassie

    kassie New Member

    I Have Found the problem...

    [Wed Jun 06 07:42:54 2007] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
    PHP Warning: Module 'json' already loaded in Unknown on line 0
    [Wed Jun 06 07:42:54 2007] [notice] Apache/2.2.3 (Ubuntu) PHP/5.2.1 mod_ssl/2.2.3 OpenSSL/0.9.8c configured -- resuming normal operations


    Now the question. Where to fix this??
     
  9. chuckl

    chuckl New Member

    Should your individual websites not have an addtype line for php?

    AddType application/x-httpd-php .php .php3 .php4 .php5
     
  10. kassie

    kassie New Member

    Thanks,

    That helped
     
  11. kassie

    kassie New Member

    10 Minutes later...

    It's not working anymore... I changed nothing after that.

    Any other suggesstions?
     
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    That is normal. Never edit the file Vhost_ispconfig.conf!

    If you want to enable PHP, you must enable the PHP checkbox in ISPConfig and hit the save button.
     
  13. kassie

    kassie New Member

    Hey Till,

    I do that but it still doesn't work. Could the problem be in apache not load php?
     
  14. chuckl

    chuckl New Member

    Obvious question is 'You do have PHP installed?' I think I'm right in saying that the IspConfig PHP and main Apache webserver PHP's are different animals.
    You should check /home/admispconfig/ispconfig/lib/config.inc.php for what you have set in $go_info["server"]["apache2_php"] = 'addtype'. You may need to set that to 'both' or 'filter' suPHP, depending on what you have loaded.
    Did you follow the 'Perfect Setup how-to' for Ubuntu when you installed the system?
    Check the Vhosts file again to see if you have the type handler or filter set to load for your website. i.e. having ticked the PHP scripts box in IspConfig, it should have modified the Vhosts file, and make sure they're not set twice, or conflicting settings.
    Check the Apache and website logs for any complaints about permissions.
    What error messages, if any, are you getting, other than the 'php as text' error?
    it is usua;;y worth creating a 3 line php file e.g.
    <?php
    phpinfo();
    ?>

    save it as test.php or whatever on a website, and see if that runs.
     
  15. kassie

    kassie New Member

    $go_info["server"]["apache2_php"] = 'filter,addtype,engine'; // one string of one or more comma seperated options: 'filter' = set PHP filters, 'addtype' = Set PHP addtype, 'both' = Set Filter + Addtype, 'engine' = Use "php_admin_flag engine on/off", suphp = SuPHP wrapper enabled, 'addhandler' = Set PHP AddHandler (nescessary for SuSE 10.2)


    Does this help
     
  16. chuckl

    chuckl New Member

    Kallie, I might be wrong, as I don't use it, but the 'engine' in that line and the 'php_admin_flag safe_mode off in your vhosts file would seem to be switching off the php engine?
    I would give it a test changing that to 'both' or 'addtype'
     
  17. kassie

    kassie New Member

    Still not working...

    Any aother suggestions??
     
  18. chuckl

    chuckl New Member

    Yes, continue with the list I posted above. Essentially, your server is not running php, or is not recognising php as something that it can run and interpret.
    So, in no particular order:
    PHP is not loaded on the Apache server.
    You have rewrites active which are messing it up
    The file permissions/owners of the php script files prevent them being executed.
    PHP is disabled for that vhost.
    You have a funny in your config - suPHP, PHP as CGI etc that is preventing it running.
    etc etc etc

    I would create a new vhost, enable PHP, CGI, all except safe mode, and place the phpinfo() script file in the web root, and see if it executes. You want to cut it down to the simplest system possible.
     
  19. Hans

    Hans Moderator Moderator

    Other suggestion

    I am not sure if you're running suPHP on your server.
    If so, check the permissions of the folder which contains the php script.
    The permissions of the folder, which contains your php script must be set to chmod 755.

    If you are not able to solve the problem, probably a module for php is missing.
    In that case, you can consider to install php again as described within the perfect setup.
    This will do not harm.
     
  20. chuckl

    chuckl New Member

    Kassie,
    been giving it some thought, if after you manually added the addtype line to one of the vhosts the PHP on that site started working, you should double check that PHP is ticked on a site in the IspConfig control panel, and then check the vhosts file to see that that or a similar line is present there.
    If not, I'd say your IspConfig install is producing a vhosts config that is incompatible with your webserver setup
     

Share This Page