I think I have killed my LAMP server!

The server is CentOS 6.6 and has Apache 2.2 and PHP 5.4 installed. I didn't originally install anything - it was provisioned this way by my hosting provider.

Everything has been working fine on the server until I tried to install phpMyAdmin. I executed the following commands:

sudo rpm -ivh epel-release*

sudo yum install phpmyadmin

Then I restarted Apache but when I tried to browse to my PHP application (which had been working fine) I got a 500 Internal Server Error. I checked the Apache error log, and saw the following:

[Thu Nov 06 22:37:35 2014] [notice] Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips mod_bwlimited/1.4 configured -- resuming normal operations
[Thu Nov 06 22:37:38 2014] [error] [client] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mcrypt.so' - libmcrypt.so.4: cannot open shared object file: No such file or directory in Unknown on line 0
[Thu Nov 06 22:37:38 2014] [error] [client] Premature end of script headers: index.php

I have checked /etc/php.d/mcrypt.ini and it has the following:

; Enable mcrypt extension module

I thought it might have been some kind of version conflict in that the installed version of PHP was 5.4, but phpMyAdmin was expecting 5.3.

#php -v

PHP 5.4.28 (cli) (built: May  7 2014 13:54:44)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

I have since uninstalled phpMyAdmin and tried re-installing PHP, but I think I have completely buggered my server!

This is (ahem) a production environment and now nothing seems to be working.

Would appreciate any support/advice.

  • 1
    If it's a production system, why did you attempt to install phpMyAdmin? That's one of the last things you would want on a server. Anyway, revert the change (with yum history undo) and then start from there. – Michael Hampton Nov 6 '14 at 14:10
  • I tried the yum history undo command, and got the following output: Loaded plugins: fastestmirror No transaction ID given Error: Failed history undo – Paul Hobbs Nov 6 '14 at 16:00
  • Well, you need to do that, then! – Michael Hampton Nov 6 '14 at 16:02
  • I'm sorry, do what? – Paul Hobbs Nov 6 '14 at 16:07
  • Once I get PHP (and my application) working again, I still need to install phpMyAdmin - I need to edit some of the data in the database. – Paul Hobbs Nov 6 '14 at 16:12
  1. I agree with Michael Hampton's statement that you should not have phpMyAdmin installed on a production server.

  2. I prefer to install phpMyAdmin via a git checkout rather than their package. This gives you control over what the hostname is, adding an .htpasswd authentication, ssl, etc. (I'm sure all that can be done via the package but why bother doing it another way when you're already setting up sites and already have a method for doing so?). The repo for phpMyAdmin can be found at https://github.com/phpmyadmin/phpmyadmin and can be cloned as the site, allowing you to update as frequently as you like via a simple git pull.

  3. Better than phpMyAdmin would be to install something like MySQL Workbench (http://dev.mysql.com/downloads/workbench/) and configure the server to communicate on port 3306 only to your ip (via security rules in AWS or iptables/firewall, etc).

  4. Better even than using MySQL Workbench would be to ssh into the server and run mysql commands via the CLI. Locally, without external communication.

Now that I've said all that, your post mentioned an error Unable to load dynamic library... This means you're missing a package. In your case, it's the mcrypt.

@note: all commands are executed as root. You can also sudo every command below.

First step is to figure out what version of php you have installed:

# yum list installed | grep php

This should give you a response such as:

php55.x86_64                         5.5.18-1.92.amzn1             @amzn-updates

In my scenario, I have php55 installed (you may have simply php.x86_64 or php54.x86_64). I now know I need to search for mcrypt and install it:

# yum search php55-mcrypt


php55-mcrypt.x86_64 : Standard PHP module provides mcrypt library support

Package found! (the reason why I search is sometimes the package names are not what you'd expect so you may need to search just for mcrypt for example, and look through the results for the one you want.

Finally, install and restart httpd:

# yum install php55-mcrypt
# service httpd restart

If when trying to restart httpd you get a similar error for another package, rinse and repeat.

| improve this answer | |
  • In re-reading the question I see you mention you have php54 installed so ignore all my talk about finding the version of php =) – Beshoy Girgis Nov 6 '14 at 17:47
  • I ran the yum list installed command, and I got the following: php.x86_64 5.3.3-40.el6_6 @updates php-common.x86_64 5.3.3-40.el6_6 @updates php-mcrypt.x86_64 5.3.3-3.el6 @epel – Paul Hobbs Nov 6 '14 at 22:58
  • Sorry for the ugly formatting - I don't think I can insert line breaks in a comment. There were a bunch of other PHP related packages as well. The results of that command suggest to me that the version of PHP is 5.3 but when I run php -v it says 5.4 (see my original post) – Paul Hobbs Nov 6 '14 at 23:06
  • Try running which php to see which php executable you're running. You are correct though, you have php 5.3 installed via yum. Did you do a manual installation of php, i.e. compile from source, etc to get php5.4? – Beshoy Girgis Nov 7 '14 at 8:55
  • 1
    Note: knowing you were using WHM would have been great to know in your original question. – Beshoy Girgis Nov 8 '14 at 9:11

It turns out that phpMyAdmin was already installed (and was accessible via cPanel). I got the hosting provider to investigate the PHP issue, and they performed an EasyApache rebuild through WHM, and this resolved the problems.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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