Install PHP, MySQL and PHPMyAdmin in Ubuntu VirtualBox

To install PHP, MySQL, and phpMyAdmin on Xubuntu running in VirtualBox, follow these steps:

Step 1: Update Package Repository

Open a terminal and update your package list:

sudo apt update
sudo apt upgrade

Step 2: Install Apache Web Server

You need a web server to run PHP. Install Apache:

sudo apt install apache2

Step 3: Install PHP

Next, install PHP along with some common extensions:

sudo apt install php libapache2-mod-php php-mysql

Step 4: Install MySQL Server

Now, install the MySQL server:

sudo apt install mysql-server

After installation, it's a good idea to run the security script:

sudo mysql_secure_installation

Follow the prompts to secure your MySQL installation.

Step 5: Install phpMyAdmin

Now, install phpMyAdmin:

sudo apt install phpmyadmin

During the installation, you will be prompted to choose a web server to configure. Select Apache by pressing Space to mark it, then Enter.

You'll also be prompted to configure the database for phpMyAdmin. Choose Yes and provide your MySQL credentials when asked.

Step 6: Configure Apache to Serve phpMyAdmin

You may need to create a configuration file for phpMyAdmin:

echo 'Include /etc/phpmyadmin/apache.conf' | sudo tee -a /etc/apache2/apache2.conf

Step 7: Restart Apache

To apply the changes, restart Apache:

sudo systemctl restart apache2

Step 8: Access phpMyAdmin

You can access phpMyAdmin in your web browser by navigating to:

http://localhost/phpmyadmin

Log in with your MySQL credentials.

Step 9: Testing PHP

To ensure PHP is working, create a PHP info file:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Now, access it via:

http://localhost/info.php

You should see the PHP info page.

Step 10: Clean Up

For security reasons, you may want to remove the info.php file after testing:

sudo rm /var/www/html/info.php

Conclusion

You now have a functioning LAMP stack (Linux, Apache, MySQL, PHP) with phpMyAdmin on your Xubuntu VirtualBox setup! If you encounter any issues, check the Apache error logs for troubleshooting:

sudo tail -f /var/log/apache2/error.log