Getting a blank PHP page on top of Apache

In the new installation cloud cloud server (CentOS), I installed php and Apache. The web server is working 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) 

However, the browser will show blank pages (white page) if I try to visit any php page.

Here is what I have done so far for troubleshooting:

  • A page has been created with the following contents: <?php phpinfo(); ?> <?php phpinfo(); ?> . It displays a blank page when viewed from a browser.
  • To make sure that apache points to the correct directory, placed a static .html page there and saw that this is fine in the browser, so apache works and the directory is correct.
  • In /etc/php.ini the display_errors directive has been changed to On . Still blank page.
  • In the Apache configuration file ( /etc/httpd/conf/httpd.conf ) this line found Include conf.d/*.conf . Inside the conf.d directory conf.d is a php.conf file containing the line: LoadModule php5_module modules/libphp5.so . Make sure that this .so file really exists in this place.
  • In the same file, I have these two lines: AddHandler php5-script .php and AddType text/html .php
  • Executing a php page from the CLI, it works great - so php works locally.

Then why does the browser always display a blank / white page? What else am I missing?

EDIT Based on @Nathan's suggestions,

  • I checked the Apache error log file, did not see any error being reported there.
  • My /etc/php.ini says that php error_log is located as syslog . So I checked /var/log/messages , but could not find the PHP error message
  • Then I put the regular HTML file in the php file containing the phpinfo() call. Interestingly, I found that even regular HTML texts also do not come. It still creates a blank page.
  • Then I checked the Apache access log. Surprise! There is no GET request for any of the PHP files that I tried to load in the browser. But there is a GET request for all non-php files with a return code of 200.

Apache does not even register any request for access to PHP files. Any idea why this will happen?

+12
php apache centos
source share
8 answers

It was once, but I wanted to return to this question in order to update the information that the problem is related to setting access rights to the directory.

The FPM user that I used did not have the required permissions for the index.php file in the root web directory.

To avoid these problems in the future, I created an automatic bash script that will automatically create and configure web servers in DigitalOcean boxes. Please see here https://github.com/akash-mitra/fairy

This script will be automatically

  • Installs Nginx
  • Create virtual server block for nginx
  • Installs PHP, PHP APC, PHP Curl, etc.
  • Supports PHP Fast Process Manager (php-fpm)
  • Installs Memcached
  • Installs a database (MariaDB / MySQL)
  • Optional installs PHP Composer and Laravel
  • Configures and strengthens SSH
  • Activates the firewall
  • Optionally enables SWAP space on the DO server and fixes the locale problem
0
source share

check out your phpinfo () script.

 <?php phpinfo(); ?> 

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

+17
source share

I think your php installation with apache is wrong. That is why you do not see any php page on your web server. Clean up remove all existing applications like httpd, php, php-fpm, php-cli, etc. And try to clear 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 the 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. Apache configuration 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 this search after โ€œFastCgiWrapperโ€ and make sure it is 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 in /etc/httpd/conf.d/php.conf:

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

Comment on the AddHandler and AddType lines so that they look like this:

 # # 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 
+5
source share

Do you directly go to php file? Or do you just go to the root directory?

If later, Apache may not recognize .php as a directory index.

To test, try creating the .htaccess file in the root directory of the website containing the following line:

 DirectoryIndex index.php 
+1
source share

I have the same problem ... The problem is in iptables. ( It looks like )

Try:

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

Then try reloading the page again.

If you have another solution, share it.

[ edit ] Rebooting the iptables service works for me.

Try:

 service iptables restart 
+1
source share

First of all, you should check the permissions of your file. If you do not provide reading access to the public, Apache creates a blank page without any errors.

+1
source share

Since everything looks like the default, you checked this part just to confirm

cat /etc/php.ini | grep log_errors

If log_errors is disabled, enable it and check this log below after rebooting httpd. /var/log/httpd/error_log

- Also check this part from php configuration.
cat /etc/php.ini | grep error_reporting

This value must be enabled by default for display_errors to work.
error_reporting = E_ALL

0
source share

Sorry to send the old thread ... this is important.

I also had these problems when the html response did not output

After double checking php.ini or my apache conf files and still not getting any output, I later found out that I was suppressing the class include / require error, with @ , which was nested in the constructor function. A syntax error occurred in the included file, which completely stopped all output when errors were reset.

So, first check your handlers. If you first save all your output to vars and you include various scripts in the first place, you will not have to see these errors. If you suppress file handler errors, you will get a blank screen if you have a syntax error in the file.

Find your files for all @ instances in your php code. Then turn @include "/path_to/script.php"; in include "/path_to/script.php"; or something @$foo in $foo , since such a var might refer to a dependency that causes your script to end up showing up in the httpd error log or in the http response.

0
source share

All Articles