Installing LAMP Stack on Ubuntu / Debian

A LAMP (Linux, Apache, MySQL, PHP) stack is a common, free, and open-source web stack used for hosting web page in a Linux environment. It’s the most common software stack that powers dynamic websites and web applications. Here Linux is an OS, Apache is the popular web server developed by Apache Foundation, MySQL is a relational database management system used for storing data and PHP is the widely used programing language. In this article, we will discuss the way to install a lamp stack on Ubuntu/ Debian

Requirements

Minimal Ubuntu 18.04 server Installation.

SSH access to the server

Root user privileges or use the sudo command to run all commands


1) Update Software Packages

Before installing the LAMP stack, you want to update the sources and software packages. To do this, please execute the subsequent command:

$ sudo apt update

$ sudo apt upgrade


2) Install Apache Web Server

To install the Apache Web server, please enter the following command. The apache2-utils package will install some useful utilities just like the Apache HTTP server benchmarking tool.

$ sudo apt install -y apache2 apache2-utils

Once the installation process has been completed, apache should be automatically started. You’ll check the apache status using the following command:

$ sudo systemctl status apache2

If the apache service isn’t running, start it using the command:

$ sudo systemctl start apache2

You can also enable Apache to automatically start at system boot time by using the command:

$ sudo systemctl enable apache2

Apache version can be checked by using the command:

$ apache2 –v


3) PHP Installation

PHP is one of the foremost widely used server-side scripting languages used to generate dynamic content on websites and apps. Ubuntu 18.04 has default PHP 7.2 for installation. But we propose adding additional PPA for PHP installation which includes multiple other versions of PHP. You’ll use the following commands to install PHP packages and update apt-cache on your system.

$ sudo apt-get install python-software-properties

$ sudo add-apt-repository ppa:ondrej/php

$ sudo apt update

$ sudo apt install -y php7.2

You may also need to install some additional PHP modules for supporting various tasks.

$ sudo apt install php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-xml


4) Install MariaDB Database Server

MariaDB is a free, open-source database management system forked from MySQL and it’s a community-developed project being led by the unique developers of MySQL. Enter the following command to install it on Ubuntu 18.04.

$ sudo apt install mariadb-server mariadb-client

Once the installation process has been completed, mariadb should be automatically started. You’ll check the mariadb status using the following command:

$ systemctl status mariadb

If the mariadb service isn’t running, start it using the command:

$ sudo systemctl start mariadb

You can also enable mariadb to automatically start at system boot time by using the command:

$ sudo systemctl enable mariadb

The MariaDB installation isn’t secure by default, you need to execute a security script that comes with the package. You’ll be asked to enter a root password to make sure that no one-can log in to the MariaDB.

$ sudo mysql_secure_installation

Once you execute the script, it’ll ask you to enter the MariaDB root password, press Enter key as the root password isn’t set yet. Then enter ‘y’ to set the basis password for the MariaDB server.

Then enter yes/y to the following security questions:

Set root password? [Y/n]: y

Remove anonymous users? (Press y|Y for Yes, the other key for No) : y

Disallow root login remotely? (Press y|Y for Yes, the other key for No) : y

Remove test database and access to it? (Press y|Y for Yes, the other key for No) : y

Reload privilege tables now? (Press y|Y for Yes, the other key for No) : y

You can run the following command to log in without providing MariaDB root password.

$sudo mariadb -u root

To exit, run

exit;

Check MariaDB server version information.

$ mariadb –version

Congrats! You’ve successfully installed the LAMP stack (Apache, MariaDB, and PHP7.2you’re your Ubuntu 18.04 server.

If you would like any longer help, please do contact our support department.



  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How can I change a database password on cPanel?

Changing MySQL database password via cPanel You can change your database’s password by...

How can I change my PHP version on cPanel?

Changing PHP version via cPanel Your Hosting Account's PHP version can be changed at any time,...

How can I create a new MySQL database in cPanel?

Creating a new MySQL database at Servers GATE using cPanel   You can easily create a new MySQL...

How can I locate my MySQL database details on cPanel?

Locating your MySQL database details via cPanel You can easily locate your MySQL databases...

How can I set up a redirect on cPanel?

Creating a redirect on cPanel Your hosting redirects can be easily managed with the assistance...