If you're running Amazon Linux AMI 2013.09 and followed the official AWS LAMP installation guide, you likely have PHP 5.3 installed by default. While PHP 5.3 was stable for its time, many modern applications require PHP 5.5 or higher for better performance and security.
When you try to install PHP 5.5 using yum install php55
, you might encounter dependency conflicts because:
- Existing PHP 5.3 packages conflict with PHP 5.5 packages
- Some dependencies were built specifically for PHP 5.3
- The default Amazon Linux repositories might not include all required packages
Here's the step-by-step method I've successfully used to upgrade PHP without breaking existing configurations:
# First, remove existing PHP packages
sudo yum remove php php-*
# Clean up yum cache
sudo yum clean all
# Install the new PHP 5.5
sudo yum install php55 php55-common php55-pdo php55-mysqlnd php55-xml
# Verify the installation
php -v
If you encounter missing dependencies, you might need to enable additional repositories:
# Enable the Amazon Linux Extras repository
sudo amazon-linux-extras enable php7.2
# Alternatively, for EPEL repository
sudo yum install epel-release
After upgrading, don't forget to:
- Restart Apache:
sudo service httpd restart
- Check PHP info: create a
phpinfo.php
file with<?php phpinfo(); ?>
- Test your applications thoroughly
For more PHP version options, consider the Remi repository:
# Install Remi repository
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
# Install specific PHP version
sudo yum --enablerepo=remi-php55 install php
When attempting to upgrade PHP on older Amazon Linux AMIs (specifically the 2013.09 release), you'll encounter dependency conflicts when running:
sudo yum install php55
The system tries to preserve existing PHP 5.3 packages while installing the new version, creating unresolvable package conflicts.
The proper approach involves completely removing existing PHP packages before installing the new version. Here's the full working sequence:
# First remove existing PHP packages
sudo yum remove php php-*
# Clear yum cache
sudo yum clean all
# Install the new PHP 5.5 stack
sudo yum install php55 php55-common php55-pdo php55-mysqlnd php55-xml
For systems with custom configurations, preserve your php.ini before removal:
# Backup configuration
sudo cp /etc/php.ini /etc/php.ini.bak
# After fresh installation
sudo cp /etc/php.ini.bak /etc/php55/php.ini
After installation, confirm the new version is active:
php -v
# Should show: PHP 5.5.x
For web server integration (Apache), restart the service:
sudo service httpd restart
On newer Amazon Linux 2 systems, consider using the extras library:
sudo amazon-linux-extras enable php7.3
sudo yum install php-cli php-pdo php-fpm php-json