Installing PHP 5 and MySQL 5.5 on Ubuntu 18.04

While I fully understand the security implications of running these legacy and unsupported versions of PHP and MySQL. I had an application that had these dependancies, but I wanted to move to a supported LTS version of Ubuntu.

Once you have Ubuntu 18.04 installed with Apache 2, you can use following the steps below to get PHP 5.6.40 and MySQL 5.5.56 installed.

Installing MySQL 5.5.56 on Ubuntu

Download MySQL version 5.5.56 from the MySQL site

wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz

Create mysql group

sudo groupadd mysql

Create mysql user and add it to the mysql group

sudo useradd -g mysql mysql

Extract the downloaded MySQL .tar file

sudo tar -xvf mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz

Move the extracted .tar file to /usr/local

sudo mv mysql-5.5.56-linux-glibc2.5-x86_64 /usr/local/

Change directory to /usr/local and rename the extracted folder

cd /usr/local sudo mv mysql-5.5.56-linux-glibc2.5-x86_64 mysql

Change owner of the directory to mysql

cd mysql sudo chown -R mysql:mysql *

Install the required lib package

sudo apt install libaio1

Execute the MySQL installer script

sudo scripts/mysql_install_db --user=mysql

Set the MySQL directory owner from outside the directory

sudo chown -R root .

Set the MySQL directory owner from inside the directory

sudo chown -R mysql data

Copy the MySQL config file to the /etc directory

sudo cp support-files/my-medium.cnf /etc/my.cnf

Start MySQL Server

sudo bin/mysqld_safe --user=mysql & sudo cp support-files/mysql.server /etc/init.d/mysql.server

Set MySQL root password

sudo bin/mysqladmin -u root password '[your new password]'

Add MySQL path to the system

sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

Now reboot your server

Once the server is back up and running. Start MySQL.

sudo /etc/init.d/mysql.server start

Check the status to ensure it is running

sudo /etc/init.d/mysql.server status

Enable MySQL on startup

sudo update-rc.d -f mysql.server defaults

Now reboot again and check MySQL starts on boot

Now you can login to MySQL with the password you set above

sudo mysql -u root -p

Installing PHP 5.6.40 on Ubuntu

Add the following repository and install PHP

sudo add-apt-repository -y ppa:ondrej/php
sudo apt update
sudo apt install php5.6

One Comment

  1. Dude, thanks lot!

    Works pretty well, everything.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.