Installing LAMP (Apache/MySQL/PHP) stack on Ubuntu

LAMP or Linux, Apache, MySQL, and PHP is the default software stack most PHP+MySQL based applications use, it's the easiest and quickest way to get your PHP+MySQL application online. A LAMP stack can be installed on your Ubuntu install with the following commands.

Updating the system

We first update the system to make sure that all our installed packages are upto date. Your Ubuntu system can be updated easily with the following command,

apt-get update && apt-get upgrade

updating

Install Apache

Apache can be installed with the following command, usually Apache comes pre-installed on the default Ubuntu images we have but if your VPS has been installed with a minimal OS image, then it won't come with Apache pre-installed.

apt-get install apache2

install apache

Once the install finishes, start Apache with the following command,

service apache2 start

start apache

Install PHP

Here we install PHP and the PHP-mysql plugin for PHP to communicate with your MySQL server.

apt-get install php php-mysql

install php

Restart Apache so that Apache detects PHP and enables it,

service apache2 restart

restart apache

Install MySQL

MySQL can be installed with the following command,

apt-get install mysql-server

install mysql

install php

Setup MySQL with a root password

/usr/bin/mysql_secure_installation

secure install

Start MySQL once the above step is complete,

service mysql start

start mysql

Set Apache/MySQL services to start on boot

update-rc.d apache2 enable
update-rc.d mysql enable

on boot

Done! Load your VPSes IP address in the browser and it should display the default Apache page!

All your files to be displayed go into the default web-root at

/var/www/

Last Modified: January 10 2018 20:43:04