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. Feb 24, 2019 at 18:13
  • webserver is apache2 and how can i configure webserver? Name of file is index.php
    – ScreaMyCZE
    Feb 24, 2019 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? Feb 26, 2019 at 11:28
  • If i knew how to confirm it, i would do it
    – ScreaMyCZE
    Feb 26, 2019 at 18:38

2 Answers 2


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
    – ScreaMyCZE
    Feb 27, 2019 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
    – Bobbbay
    Feb 27, 2019 at 19:09
  • I know that too, but that page didnt helped me
    – ScreaMyCZE
    Feb 27, 2019 at 19:38
  • Ok, I'll sketch up a fact - assumption sheet and get back to you soon
    – Bobbbay
    Feb 27, 2019 at 20:03
  • P.S. is it possible that the file extension is not .php? That could be the cause of all this.
    – Bobbbay
    Feb 27, 2019 at 20:08

I reinstalled the whole RPI and installed all things again, not sure what caused the problem but it worked

  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year.
    – Ingo
    Jul 10, 2020 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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