If you already install apache web server, the next thing to do is installing php and mysql database, in this article i will show you how to install php 7.2 and mysql 5.7 on xubuntu 18.04 bionic.
How to install PHP on Xubuntu 18.04
- open command line on xubuntu
- run update command
sudo apt-get update
sudo apt-get install php7.2
Once installed you can test php by creating script that runs phpinfo() function, like this:
<?php
phpinfo();
?>
How to install MySQL on Xubuntu 18.04
- open command line on xubuntu
- run update command
sudo apt-get update
sudo apt-get install mysql-server
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
FLUSH PRIVILEGES;
quit
mysql -u root -h localhost -p
quit
sudo apt-get install php7.2-mysql
Once mysql is installed you can test by creating php script that connect to mysql, like this:
<?php
$mysqli = new mysqli("localhost", "root", "yourpassword", "mysql");
$result = $mysqli->query("SELECT 'Hello, dear MySQL user!' AS _message FROM DUAL");
$row = $result->fetch_assoc();
echo htmlentities($row['_message']);
?>