I installed php services and Apache2 on my raspberry pi without errors. But, when I opened a browser and entered my page URL, it wrote

<?php echo "Hello";?>

instead of Hello.

I have tried reinstalling and have checked that the Apache PHP module is installed and enabled with a2enmod, the script runs fine when run directly with php on the terminal.

Anyone know how to fix that? Thanks for any help

  • 1
    What web server are you using and what's the name of the file containing your PHP script? You may need to configure your web server to execute the file with php and send the output to the browser rather than send the contents to the browser as-is. – Roger Jones Feb 24 '19 at 18:13
  • webserver is apache2 and how can i configure webserver? Name of file is index.php – Kuba Kropáček Feb 24 '19 at 18:22
  • 1
    Can you add the extra information to your question about using Apache2, confirming the libapache2-mod-php is installed and configured and that you can run the script from the terminal without errors. Maybe also add the installation steps you've followed to get to this point? – Roger Jones Feb 26 '19 at 11:28
  • If i knew how to confirm it, i would do it – Kuba Kropáček Feb 26 '19 at 18:38

Fact assumption table Fact assumption table

Solution 1

Try your script without the tags. It's possible that Apache automatically runs the script through PHP only and not HTML with PHP. This will mean that it sees echo 'Hello' only if it understands the rest of the code. If it is only running PHP it might not understand the tags and just print out the whole thing. There's a slim chance but try it out just in case. See if that will help.

Solution 2

Your web browser may not support PHP. You should check what web browser you're using. If you're using Midori, it might not support it. Try doing this on a different device and accessing another browser like Google Chrome.

Solution 3

Make sure that your file extension is not .txt - This might be the reason for it not seeing and not compiling your code.

Solution 4

Taken from this stackoverflow question

Make sure that Apache's httpd.conf file has the PHP MIME type in it. This should be something like AddType application/x-httpd-php .php . This tells Apache to run .php files as PHP.


Possible links that may help:

Another stack overflow question . PHP.net . If your HTTPS.config file is wrong

I hope this helps.


  • At first i wanna say thanks for help, and for the second none of solutions helped, i removed php tags and tried on other browsers and different devices and it showed echo "Hello"; istead of Hello – Kuba Kropáček Feb 27 '19 at 18:54
  • This seems like a problem for Apache and not Raspberry Pi then, here are some links for a question that is similar: stackoverflow.com/questions/5121495/… ••• Here's another link as well: php.net/install – Bobbay Feb 27 '19 at 19:09
  • I know that too, but that page didnt helped me – Kuba Kropáček Feb 27 '19 at 19:38
  • Ok, I'll sketch up a fact - assumption sheet and get back to you soon – Bobbay Feb 27 '19 at 20:03
  • P.S. is it possible that the file extension is not .php? That could be the cause of all this. – Bobbay Feb 27 '19 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.