Make sure your server is up-to-date with this guide.
The LAMP stack is a development stack that is common for PHP-based websites and web applications. LAMP stands for Linux, Apache, MySQL, PHP.
Install Apache
You will want to run the following command to install Apache:
apt-get install apache2 -y
Running this command with the -y option will automatically proceed through any parts of the installation that would prompt you for a yes/no answer.
Test your installation by opening a web browser and navigating to http://<Your_IP_Address>

Install MySQL
Run this command to install MySQL. Once again, we are using the -y option:
apt-get install mysql-server -y
It is highly recommended to set the root password for MySQL after installation. You can use the following steps to change the password:
Stop MySQL:
/etc/init.d/mysql stop
Start mysqld configuration:
mysqld --skip-grant-tables &
Start MySQL:
/etc/init.d/mysql start
Make sure MySQL is running:
/etc/init.d/mysql status

Log in to MySQL:
mysql -u root mysql
Change the root password:
UPDATE user SET authentication_string=password('YourPassword');
Type “quit
” to exit MySQL.
Install PHP
PHP is the server-side scripting language that gives your application or website the ability to interact with the server. To install PHP, run the following command:
apt-get install php libapache2-mod-php php-mbstring php-mysql -y
To verify the installation of PHP, you can check your version with this command:
php -v
