Jump to content

PHP code is not rendered properly on web browser


w01f

Recommended Posts

Posted

I've just installed Apache with PHP-FPM based on the following tutorial

How to Setup Apache with PHP-FPM on Ubuntu 20.04

wolf@linux:~$ dpkg -l apache2 libapache2-mod-fcgid software-properties-common php7.4 php7.4-fpm
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                          Version             Architecture        Description
+++-=============================-===================-===================-===============================================================
ii  apache2                       2.4.29-1ubuntu4.14  amd64               Apache HTTP Server
ii  libapache2-mod-fcgid          1:2.3.9-1           amd64               FastCGI interface module for Apache 2
ii  php7.4                        7.4.12-3+ubuntu18.0 all                 server-side, HTML-embedded scripting language (metapackage)
ii  php7.4-fpm                    7.4.12-3+ubuntu18.0 amd64               server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  software-properties-common    0.96.24.32.14       all                 manage the repositories that you install software from (common)
wolf@linux:~$ 

Test PHP with phpinfo() function

wolf@linux:/var/www/html$ cat info.php 
<?php phpinfo(); ?>
wolf@linux:/var/www/html$ 

The only issue right now is PHP file seems to be processed properly in CLI, but not via web browser.

wolf@linux:/var/www/html$ php info.php | head
phpinfo()
PHP Version => 7.4.12

System => Linux 4.15.0-122-generic #124-Ubuntu SMP Thu Oct 15 13:03:05 UTC 2020 x86_64
Build Date => Oct 31 2020 17:04:09
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc/php/7.4/cli
Loaded Configuration File => /etc/php/7.4/cli/php.ini
Scan this dir for additional .ini files => /etc/php/7.4/cli/conf.d
wolf@linux:/var/www/html$ 

Unfortunately, it's not working on web browser

enter image description here

What wrong in this case and what should I do to troubleshoot it?

Posted

I just created a fresh VM (VirtualBox) and followed the instructions in the page you linked in your post and it all worked out well. Browsing the info.php file works without any problems and showing the expected results. Not using 20.04 though, but Ubuntu 18.04.4 LTS. Try again from scratch and see if some of the steps where unintentionally skipped and/or look for error messages while installing or restarting services, etc.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...