Configure LAMP on Ubuntu

A very good tutorial can be found here: https://chabolla.dev/wamp-lamp-stack-install-on-windows/ and another one here: https://www.how2shout.com/how-to/how-to-install-apache-mysql-php-phpmyadmin-on-windows-10-wsl.html – don’t try them both at the same time, rather take them one at a time.

However, if after following it, for some reason, mysql or phpmyadmin does not work, try one of the following fixes

Very useful stuff

1. If, for some reason you get the following error: Phpmyadmin. mysqli_real_connect(): (HY000/2002): Permission denied. Connection for controluser as defined in your configuration failed – try to use the following fix:

In the file /etc/phpmyadmin/config-db.php, change

$dbserver=’localhost’;
to
$dbserver=’127.0.0.1′;

Afterwards, restart Apache2

Source

2. To delete Linux apps from the command line, use the following commands:

sudo apt-get remove --purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean

you can replace mysql* with any other app name such as php* or phpmyadmin* or apache*. You can also use multiple apps like so:

sudo apt-get remove --purge mysql* php* phpmyadmin* apache*

3. Reconfigure phpmyadmin post-install

sudo dpkg-reconfigure phpmyadmin

4. MySQL won’t start – error: su: warning: cannot change directory to /nonexistent: No such file or directory

mysql user is looking for a home directory, which seems to have not been assigned. To do that, you can execute:

sudo systemctl stop mysql.service
sudo usermod -d /var/lib/mysql/ mysql
sudo systemctl start mysql.service

or

sudo service mysql stop
sudo usermod -d /var/lib/mysql/ mysql
sudo service mysql start

Source

5. ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’

Try to remove and reinstall all the apps

5. Create Virtual Hosts

Very useful article here: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04-quickstart

I still wasn’t able to add a virtual host outside the /var/www folder, but I should be able to do it in the future.

Comments

Leave a Reply