We're upgrading our server infrastructure on Amazon and I'm attempting to migrate a PHP site based on CodeIgniter (version 1.7.2) to a new server which has AmazonLinux as the OS. The previous server was Ubuntu, running PHP 5.3.3-1ubuntu9.5 on apache2. The PHP version on the new AmazonLinux server is 5.3.29, running on httpd.
When I try to access the URL in the new server, the code is currently stopping in system/core/CodeIgniter.php
at this line:
$CI = new $class();
I haven't been able to see any relevant error messages in the httpd error log specified in virtual hosts for the app, nor in the default httpd error log. Using the lynx command line client to access the URL simply shows a internal server 500 error, while accessing through a regular browser just shows a blank page.
Any ideas? I know the Code Igniter version is pretty old, circa 2009. But it's compatible with PHP 5.3, which we're running on the new server. This is legacy code and will disappear at some point, so we have no interest in upgrading the PHP or CI level - unless we're forced to due to the upgrade.
The problem turned out to be a database access issue. Specifically, the version of PHP on the new server turned out to not support deprecated calls to php-mysql APIs (e.g. @mysql_pconnect or @mysql_connect)
The solution was to
1) Download the mysql library which supports the legacy calls. In the case of AmazonLinux, this is accomplished as follows:
sudo yum install php-mysql
2) Find where the library was downloaded e.g.
find / -name mysql.so
This may have been shown in the install as well, but that is a way to find it anytime. YMMV, but in my case, the library name was:
/usr/lib64/php-zts/modules/mysql.so
3) Change php.ini (as shown in phpinfo when called from a php page on the httpd/apached server) as follows:
a) change "extension_dir" to show where the mysql.so is installed:
extension_dir = "/usr/lib64/php-zts/modules"
b) Then add the following lines:
extension=mysqli.so
extension=mysql.so
extension=pdo_mysql.so
Reboot apache and you should be good to go.
Note: the specific legacy call not supported, which is part of of the version of CodeIgnitor I'm working with, was this:
return @mysql_pconnect($this->hostname, $this->username, $this-
The php error log showed this error:
PHP Fatal error: Call to undefined function mysql_connect() in xxx.php on line xx