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 [email protected] 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 </VirtualHost> - 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 .phpand.htmltest 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.
Troubleshooting
(Things that I already did/checked without any luck)
- Ensured Apache is running and DocumentRootis accessible
- All the directories are 755and files644
- Checked Apache access log. The html page requests are there with 200 status code, but no .phppage 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 onin 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> <IfModule worker.c> LoadModule php5_module modules/libphp5-zts.so </IfModule> AddHandler php5-script .php AddType text/html .php DirectoryIndex index.php 


index.php(rather than the command you used to create it)? Testing this on the command line usingcurl --include http://www.example.org/index.phpmight give you a more useful error message.curlcommand from my local machine, it returnscurl: (52) Empty reply from server.phpfiles