Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Trying to setup an Apache VirtualHosting environment with PHP in a freshly created CentOS node under DigitalOcean cloud server.

The trouble is, although Virtual hosting is working per se, PHP isn't.

Server Setup:

  • Web Server : CentOS 6.5 with Apache/2.2.15
  • PHP Version: 5.3.3 (To be used as an Apache Module)

Steps Taken:

Logging in as the root user,

  • Installing Apache and php : yum -y install httpd php
  • Creating a new virtual host configuration file like below:

File: /etc/httpd/conf.d/vhosts.conf

NameVirtualHost *:80
<VirtualHost *:80>
     ServerAdmin admin@example.org
     ServerName example.org
     ServerAlias www.example.org
     DocumentRoot /srv/www/example.org/public_html/
     ErrorLog /srv/www/example.org/logs/error.log
     CustomLog /srv/www/example.org/logs/access.log combined
  • Creating new directories for the virtual host site

Like below,

mkdir -p /srv/www/example.org/public_html
mkdir -p /srv/www/example.org/logs
  • Placing a .php and .html test files like below:

Files under /srv/www/example.org/public_html/ (DocumentRoot)

echo "<HTML>It work's</HTML>"      > /srv/www/example.org/public_html/index.html
echo "<?php echo ("It works"); ?>" > /srv/www/example.org/public_html/index.php

Next, when I point my browser to index.html, it works. But when I point my browser to index.php I get a blank page.


(Things that I already did/checked without any luck)

  • Ensured Apache is running and DocumentRoot is accessible
  • All the directories are 755 and files 644
  • Checked Apache access log. The html page requests are there with 200 status code, but no .php page request present in access log
  • No error in Apache or PHP error log, no error in /var/log/messages
  • Tried adding php_admin_flag engine on in vhost config file

Also see below the contents of /etc/httpd/conf.d/php.conf

<IfModule prefork.c>
  LoadModule php5_module modules/libphp5.so
<IfModule worker.c>
  LoadModule php5_module modules/libphp5-zts.so
AddHandler php5-script .php
AddType text/html .php
DirectoryIndex index.php
share|improve this question
Could you show us the contents of index.php (rather than the command you used to create it)? Testing this on the command line using curl --include http://www.example.org/index.php might give you a more useful error message. –  Ladadadada Jan 14 '14 at 7:32
@Ladadadada When I try the above curl command from my local machine, it returns curl: (52) Empty reply from server –  hashbrown Jan 14 '14 at 7:46
try to use php -v and give us the result of php -i | grep "configure" –  Jérémy Munoz Jan 14 '14 at 10:00
What was logged in Apache's error log? –  Michael Hampton Jan 14 '14 at 15:25
@MichaelHampton Apparently Apache error log did not log any error on this. Also access log only shows access request to .html files, but not logging any access request to .php files –  hashbrown Jan 15 '14 at 3:17

2 Answers 2

In my experience PHP renders a blank page when it encounters a serious underlying error. It is usually easy to fix, but unfortunately nothing is typically logged in the Apache logs, PHP logs, or syslog making the troubleshooting process difficult.

Find your php.ini configuration file using:

php -i | grep "php.ini"

This should produce something like this:

Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini

Edit this configuration file (/etc/php.ini in this case) with your favorite text editor and be sure that displaying errors and startup errors is turned on. The entries should look like this:

display_errors = On
display_startup_errors = On

Finally restart Apache so that it reads the new PHP configuration and access your page via curl or a browser. This should produce an error message that will help in the troubleshooting process.

share|improve this answer

The first thing you should do is check the Apache error logs which you have set in your Apache config; copied below:

NameVirtualHost *:80
<VirtualHost *:80>
     ServerAdmin admin@example.org
     ServerName example.org
     ServerAlias www.example.org
     DocumentRoot /srv/www/example.org/public_html/
     ErrorLog /srv/www/example.org/logs/error.log
     CustomLog /srv/www/example.org/logs/access.log combined

PHP runs under Apache so any errors that pop up will show up in the server logs. I recommend logging into the server & using tail like so:

tail -f -n 200 /srv/www/example.org/logs/error.log

But is that the general Apache log for you? Or is that DigitalOcean’s config? Because that path of /srv/www/example.org/logs/ seems quite odd. Under standard Linux it would be in a location like this:

tail -f -n 200 /var/log/apache2/error.log

Irregardless of where the logs are actually being sent, that will be the key to what is happening—or not happening—with PHP & Apache on your server.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.