Apache shows Blank page for PHP

7,373

You're missing the ? in the opening tag. It should be:

<?php
phpinfo();
?>
Share:
7,373

Related videos on Youtube

Ali SH
Author by

Ali SH

Updated on September 18, 2022

Comments

  • Ali SH
    Ali SH almost 2 years

    I've installed a fresh version of Centos 7, I'm new to Linux.

    I installed Apache using yum -y install httpd and I can open the test page and everything is ok with it.

    after that I installed PHP(5.4.16) using yum -y install php and it was successfully installed.

    after that I restarted Apache using sudo systemctl restart httpd. now I made a info.php file with this code:

    <php
    phpinfo();
    ?>
    

    and when I open http://localhost/info.php I get a blank screen with nothing in it.

    I've already read lots of topics and questions about this and I did everything but nothing helped.
    here are the things that may help you.

    Error log:

    [Sat Mar 12 12:56:33.235215 2016] [core:notice] [pid 12938] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
    [Sat Mar 12 12:56:33.236027 2016] [suexec:notice] [pid 12938] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Sat Mar 12 12:56:33.251732 2016] [so:warn] [pid 12938] AH01574: module php5_module is already loaded, skipping
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
    [Sat Mar 12 12:56:33.253398 2016] [auth_digest:notice] [pid 12938] AH01757: generating secret for digest authentication ...
    [Sat Mar 12 12:56:33.266274 2016] [lbmethod_heartbeat:notice] [pid 12938] AH02282: No slotmem from mod_heartmonitor
    [Sat Mar 12 12:56:33.271424 2016] [mpm_prefork:notice] [pid 12938] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
    [Sat Mar 12 12:56:33.271462 2016] [core:notice] [pid 12938] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
    [Sat Mar 12 12:58:08.594101 2016] [:error] [pid 12940] [client ::1:44873] script '/var/www/html/info.php' not found or unable to stat
    [Sat Mar 12 13:01:56.086456 2016] [mpm_prefork:notice] [pid 12938] AH00170: caught SIGWINCH, shutting down gracefully
    [Sat Mar 12 13:02:55.938198 2016] [core:notice] [pid 1400] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
    [Sat Mar 12 13:02:56.048201 2016] [suexec:notice] [pid 1400] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Sat Mar 12 13:02:56.077712 2016] [so:warn] [pid 1400] AH01574: module php5_module is already loaded, skipping
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
    [Sat Mar 12 13:02:56.079255 2016] [auth_digest:notice] [pid 1400] AH01757: generating secret for digest authentication ...
    [Sat Mar 12 13:02:57.017924 2016] [lbmethod_heartbeat:notice] [pid 1400] AH02282: No slotmem from mod_heartmonitor
    [Sat Mar 12 13:02:57.038794 2016] [mpm_prefork:notice] [pid 1400] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
    [Sat Mar 12 13:02:57.038866 2016] [core:notice] [pid 1400] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
    

    Apache config file : Stock file

    php.ini : stock file

    .htaccess : no file

    • Admin
      Admin over 8 years
      Do you have the file /etc/httpd/conf.d/php.conf, and can the apache user ID read it?
  • seizethecarp
    seizethecarp over 5 years
    What does that mean? How do you do that?