Score:0

PHP7.4 not running on apache2

cn flag

I'm running trying to run php7.4 on an Apache2. For some reason, when I try to run any use any php scripts in my code, they do not run, and all that is shown is the comment.

What I have in my code is this:

<?php                                                                                                                  
include("developers.php");                                                                                             
?> 

However, what shows up on the html source when loaded in a browser is this:

<!--?php
include("developers.php");
?--!>

I've tested this with multiple different scripts, so I do not believe that it is any issue with the php itself. I also installed php7.4, as well as libapache2-mod-php7.4. I also enabled the php7.4 module in apache2. Furthermore I have tried multiple different .htaccess and apache2.conf configurations, including adding

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>

and

<FilesMatch "/.php$">
    SetHandler application/x-httpd-php
</FilesMatch>

I noticed that when I did not include the <FilesMatch> tags, then the php code will run, however then the page itself breaks, and the javascript and css on my page does not run properly.

I also commented out this section in the php7.4.conf:

# Running PHP scripts in user directories is disabled by default
#
# To re-enable PHP in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
#<IfModule mod_userdir.c>
#    <Directory /home/*/public_html>
#        php_admin_flag engine Off
#    </Directory>
#</IfModule>

I am running my server on Debian 11, if that helps.

Can anyone help me with this?

NOTE: This question was originally on StackOverflow, however I was told by a user there to repost it here, as it is offtopic for StackOverflow.

Also none of https://stackoverflow.com/questions/12828163/why-are-my-php-tags-converted-to-html-comments https://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-but-the-code-shows-in-the-browser-source-code PHP not being parsed in apache2, php module is installed and enabled answer my question.

I found several other answers to similar questions as well, which I won't link here due to not being able to find all the links now, but I couldn't find anything of use.

Score:0
hm flag

Had a similar problem. PHP works in terminal but apache2 doens't seems to parse it. reinstalled all the application again but nothing worked.

then i saw the apache2.conf file where it says

IncludeOptional mods-enabled/*.conf

it was loading files from mods-enabled folder. when i did ls -l , i realised there was a broken symlink. unlinked it and created a new symlink for the installed php version and it all worked again.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.