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
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.
IF ALL ELSE FAILS, TRY TO USE PHP WITH A DIFFERENT COMPILER.
Possible links that may help:
Another stack overflow question . PHP.net . If your HTTPS.config file is wrong
I hope this helps.
Regards
-
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 HelloScreaMyCZE– ScreaMyCZE2019年02月27日 18:54:14 +00:00Commented 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/installBobbbay– Bobbbay2019年02月27日 19:09:03 +00:00Commented Feb 27, 2019 at 19:09
-
I know that too, but that page didnt helped meScreaMyCZE– ScreaMyCZE2019年02月27日 19:38:57 +00:00Commented Feb 27, 2019 at 19:38
-
Ok, I'll sketch up a fact - assumption sheet and get back to you soonBobbbay– Bobbbay2019年02月27日 20:03:28 +00:00Commented 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– Bobbbay2019年02月27日 20:08:57 +00:00Commented 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– Ingo2020年07月10日 09:13:34 +00:00Commented Jul 10, 2020 at 9:13
php
and send the output to the browser rather than send the contents to the browser as-is.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?