Getting blank PHP page over Apache

check out your phpinfo() script.

<?php
phpinfo();
?>

missing the "php" behind the first "?" will give a blank page


I think your php installation with apache is faulty. Thats why you can not see any php page in your webserver. Clean remove all the existing apps, like httpd,php,php-fpm,php-cli etc. and try to clean isntall in this order

yum install httpd -y
yum install php php-common php-cli php-gd php-curl php-fpm -y

then make sure you restart yout httpd server.

service httpd restart

Install mod_fastcgi:

yum install  mod_fastcgi

Start the service:

service php-fpm start

Restart Apache:

service httpd restart

5. Configuration of Apache with PHP-FPM

Open the fastcgi.conf file:

nano /etc/httpd/conf.d/fastcgi.conf

Add this to the end of the file:

<IfModule mod_fastcgi.c>
                DirectoryIndex index.html index.shtml index.cgi index.php
                AddHandler php5-fcgi .php
                Action php5-fcgi /php5-fcgi
                Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
                FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
</IfModule>

After that search after "FastCgiWrapper" and make sure it's set to "off" then save the file.

The /usr/lib/cgi-bin/ directory must exist, so we create it:

mkdir /usr/lib/cgi-bin/ 

If mod_php is installed and enabled, we need to disable it so open the configuration at /etc/httpd/conf.d/php.conf:

nano /etc/httpd/conf.d/php.conf

Comment out the AddHandler and AddType lines so it looks like here:

#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
<IfModule prefork.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
  LoadModule php5_module modules/libphp5-zts.so
</IfModule>
#
# Cause the PHP interpreter to handle files with a .php extension.
#
#AddHandler php5-script .php
#AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps

Save the file and restart Apache:

service httpd restart

I have the same issue... The problem is in the iptables. (It seems like it)

Try with:

service iptables stop
## check if it stop...
service iptables status

Then try to reload the page again.

If you had other solution please share.

[edit] Restarting the iptables service is working for me.

Try:

service iptables restart

Are you navigating to the php file directly? Or are you just going to the directory root?

If the later, Apache might not be recognizing .php as the directory index.

To test, try create a .htaccess file in your web root containing the following line:

DirectoryIndex index.php

Tags:

Php

Apache

Centos