A “LAMP” stack is a group of open-source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP.
In this guide, we will install a LAMP stack on an Ubuntu 18.04 server.
Step 1: Login to server
First you need to get inside the server and we are using ssh to login to server (below command), you would be prompted for password and as it is correct your are in.
Step 2: Login to root user, we will install apache, mysql, php using root user
sudo su –
Step 3: Updating package information on server
sudo apt update
Step 4: Installing Apache
The Apache web server is among the most popular web servers in the world. It’s well-documented and has been in wide use for much of the history of the web, which makes it a great default choice for hosting a website.
sudo apt install apache2
Check if apache is up http://18.104.22.168, if its done you will see page like below.
Step 4: Installing MYSQL
Now that you have your web server up and running, it is time to install MySQL. MySQL is a database management system. Basically, it will organize and provide access to databases where your site can store information.
sudo apt install mysql-server
When the installation is complete, run a simple security script that comes pre-installed with MySQL which will remove some dangerous defaults and lock down access to your database system. Start the interactive script by running:
Set password for root user of mysql, for this you have to use command mysql on terminal and get inside mysql database using commands
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘Welspunr0cks&*^’;
Step 5: Installing PHP 7.3
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
Install PHP 7.3
sudo apt install php7.3
Basic module for php
sudo apt install php-pear php7.3-curl php7.3-dev php7.3-gd php7.3-mbstring php7.3-zip php7.3-mysql php7.3-xml php7.3-fpm libapache2-mod-php7.3 php7.3-imagick php7.3-recode php7.3-tidy php7.3-xmlrpc php7.3-intl
Enabling fpm with apache2
sudo a2enmod actions fcgid alias proxy_fcgi
Let’s configure the Apache VirtualHost to run with FPM/FastCGI. For this tutorial, we use default VirtualHost. Edit VirtualHost host configuration file in text editor. You can create new VirtualHost as per your requirements, so make sure to enable any new VirtualHost.
sudo vim /etc/apache2/sites-available/000-default.conf
sudo systemctl restart apache2.service