Wheezy Nginx - php in html not executed , phpinfo not showed

Discussion in 'Installation/Configuration' started by IzFazt, Jun 18, 2015.

  1. IzFazt

    IzFazt Member HowtoForge Supporter

    Setup Used : https://www.howtoforge.com/perfect-server-debian-wheezy-nginx-bind-dovecot-ispconfig-3

    After installing phpinfo() in this small html testcode gives blank page. Also php in html in any other existing page is not executed. I had the same problem after the Centos6 - Nginx setup.

    Next code generates blank page:
    Code:
    <html>
    <head>
    <title> PHP Test Script </title>
    </head>
    <body>
    <?php
    phpinfo( );
    ?>
    </body>
    </html>
    
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Which exact error message do you get in the error,log of the website? Maybe you creatded the file as wrong user, the file has to be owned by the web user and client group of this website, if the file is owned by root then this causes a security excpetion and the processing of the file gets stipped.
     
  3. IzFazt

    IzFazt Member HowtoForge Supporter

    Hey Till, no that's is not the issue. The testfile was put online by using an FTP account of the website, so rights are ok. The system simply does not execute php this is e.g. an Nginx error, offcourse /var/www/XXX/web/ DOES exist and the bracket is probably generated by the non executed code.

    Code:
    2015/06/18 01:16:38 [error] 16388#0: *134 open() "/var/www/XXX/web/<" failed (2: No such file or directory), client: XXX, server: XXX, request: "GET /%3C?php%20echo%20$websiteUrl;?%3Ejs/fancybox/jquery.fancybox-1.3.0.css HTTP/1.1", host: "XXX", referrer: "http://XXXX/teststats.html"
     
    Last edited: Jun 18, 2015
  4. IzFazt

    IzFazt Member HowtoForge Supporter

    tackled it under apache (php in html did not work either), it is in the default .htaccess fiel which is placed in the root of the site, I added
    Code:
    AddType application/x-httpd-php .html .htm
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Nginx does not even support .htaccess. When you are able to change a setting by adding something in a.htaccess file, then your server runs apache and not nginx and this will also explain why php is not working when ispconfig is writing a nginx config file while your server is running apache and not nginx.
     
  6. IzFazt

    IzFazt Member HowtoForge Supporter

    I know, I am sorry that's not what I meant to say, I set up 2 vps, 1 nginx, 1 apache, both wheezy and both did not parse the php in the html after the default tutorial. On the apache vps I could solve this by adding one line to the .htaccess, on the nginx it probably needs a server directive in the hosting pannel at the appropriate place, but I haven't got a clue yet which one. I have to solve this since it is not a default script setup but using a ccs3 php5 jquery template using php for some external retrieval. In the end I plan to use the nginx, the apache is set online to be online.
     
    Last edited: Jun 20, 2015
  7. NginxHolic

    NginxHolic New Member

    I had the same problem. The cause was just because wrong sources for my distribution.

    My server fetched incompatible softwares from the repo.
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Off course, file with .htm or html ending should not be parsed on a correctly configured server sas they may not contain php code. The ending .htm and html are for static content. If you want to parse them with php you can configure the handelr in apache for that in .htaccess or add the code to parse them in the nginx directives field on a nginx server.
     
  9. IzFazt

    IzFazt Member HowtoForge Supporter

    When you put it like that I understand this is correct behaviour for many environments. Do you, by any chance, can set me up on where to find some info on these directives on php in html or perhaps you even have this specific one at hand so I can finish my switch to nginx?
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    Try to add this into the nginx directives field of the website:

    Code:
    location ~ \.htm$ {
            try_files /66fcb78df93b19c4b3380d2e1492c891.txt @php;
    }
     

Share This Page