Cannot install MySql in the LAMP stack

Posted December 19, 2016 9.5k views
LAMP StackUbuntu 16.04

Error Message:
Package php5-mysql is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package ‘php5-mysql’ has no installation candidate

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

PHP5 is no longer included as of Ubuntu 16.04 as it has been replaced with PHP 7. Instead of the package php5-mysql you will want to install the package php-mysql. For other PHP related stuff you will use php7.0 as in php7.0-gzip in place of php5-gzip

This worked for me. I installed apache first with sudo apt-get install apache2 and added ufw allow port 80 and 8080.

Then I tried to install mysql and php, but 5 wasn’t valid, so instead it is sudo apt-get install mysql-server php-mysql instead of php5-mysql

Next I did sudo apt-get install php7.0 php7.0-mcrypt

Then I authorized mysql and php in ufw. ALL worked fine.

  • Sorry, I’m a bit of a noob to this. How did you go about authorizing mysql and php in ufw. I’m running a droplet which I hope to host a wordpress site on and currently ufw is inactive, should I activate it?