In a newly setup digitalOcean cloud server (CentOS), I have installed php and Apache. The webserver is running fine:
[root@a2m5cent01 httpd]# service httpd status
httpd (pid 11232) is running...
[root@a2m5cent01 httpd]# php --version | head -1
PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57)
But browser is showing blank pages (white page) if I try to visit any php page.
Here is what I have done so far to troubleshoot:
<?php phpinfo(); ?>
. It displays a blank page when viewed from browser..html
page there, and saw it comes out fine in browser, so apache is working and directory is correct./etc/php.ini
, changed display_errors
directive to On
. Still blank page/etc/httpd/conf/httpd.conf
) found this line Include conf.d/*.conf
. Inside conf.d
directory, there is a php.conf
file containing the line:
LoadModule php5_module modules/libphp5.so
. Ensured that this .so file actually exists in this place.AddHandler php5-script .php
and AddType text/html .php
Then why is it always shows a blank/white page over the browser? What else am I missing?
EDIT Based on suggestions from @Nathan,
/etc/php.ini
says, php error_log is located as syslog
. So I checked /var/log/messages
but could not find any PHP error messageHTML
in the php file containing phpinfo()
call. Interestingly I found that even the normal HTML texts are also not coming. It still produces blank page.access
log. Surprise! There is no GET
request for any of the PHP files I tried to load in the browser. But GET request for all the non-php files are there with 200 return code. Apache is not even logging any access request for PHP files. Any idea why would that happen?
Missing Code The most common reason for a blank page is that the script is missing a character. If you left out a ' or } or ; somewhere, your PHP won't work. You don't get an error; you just get a blank screen.
No, it does not need to be Apache; you can also use other HTTP servers such as for example Nginx or Node.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With