Reading time: 2 mins

How to Install Linux Server for Php and MySql

By admin, July 28, 2020

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 a Ubuntu 18.04 server.

Let’s assume you already have access to a server. So in order to access the server you will need to ssh into it.

Step 1:

ssh username@IP

If you are using a PEM KEY (Highly Recommended approach)
You’d use

ssh -i “path to your key file” ubuntu@IP

Step 2:

sudo apt-get update

The command above tells the system to check if any packages that are available on the system have updates. It doesn’t actually upgrade the packages installed.

Step 3:

sudo apt install apache2

This installs the apache2 web server on your system.
This is the server that takes all the information your browser requests and sends it back to the browser.
It handles communication to other web-servers( proxy ) / Single tenant web-server or Multi Tenant  (i.e. whether 2 domains and point to the same server to show different sites respectively)

Step 4:

sudo service apache2 status

This command checks if your server is running proper.

Step 5:
Next we can move on to installing php

sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php

You’re adding the php7.4 repository to your system. Now again we will update our package list

sudo apt-get update

Once done you can now setup php7.4

sudo apt -y install php7.4

Step 6:

php -v

The command above will check your installation. It should display your php version.

php -m  

To see all modules. Now you will need modules depending on your requirements 
You can install them by running

sudo apt install php7.4-X  php7.4-XX

Where X and XX are your modules names you get after running php -m

Few basic ones are:

sudo apt install libapache2-mod-php7.4 php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-mysql php7.4-cli php7.4-zip php7.4-curl 

You can install multiple php versions on your system and you can disable or enable them by running a2dismod  X or a2ensite X
Let’s break this up for you   
A2         dis       mod        X
Apache disable module   module name
Try to figure out the other one using the pattern above. 
Remember this pattern, you may need it in the future for other things like a2disconf or a2dissite (will explain it in another post)

Ok now let’s configure your PHP

sudo vim /etc/php/7.4/apache2/php.ini

Find these Variables and set them to your preference
memory_limit = 256
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = Europe/London

Step 8:
Next we need to setup MYSQL

sudo apt install mysql-server mysql-client

Step 9:
Run this command after

sudo mysql_secure_installation

This command will help you configure your default mysql user and other settings.

Connect to the database

sudo mysql -u root -p

Enter the password you entered in the previous step

Create your new user now

CREATE USER 'username'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL ON *.* TO 'username'@'localhost' IDENTIFIED BY 'yourpassword';

That’s it! You are all set to go to the /var/www/html/ folder using your SFTP/FTP client and set up your new website.

Read more blogs like these on


Let’s build something together

About Agaetis

The word Agaetis means excellence. Keeping up with the name, we at Agaetis Technologies are firm believers in sparing no effort to deliver excellence through our work. Our websites are crafted with love and care that enables our clients to engage with visitors on a higher plane.


Brandbook | Portfolio Design | UI Design | UX Design | Social Media Banners| Social Media Posts | Website Design | Ecommerce Design | User Experience | Interface Design | Prototyping | Responsive Design

Web Application Development

Custom Development | Ecommerce Development | Enterprise Frameworks Integrations | Dynamic Websites | Headless CMS Development | Wordpress | API Integration | Saas Solutions | Paas Solutions | Social Networking | CRM Developments | ERP Developments | Invoice Generators | Custom Wordpress Theme creation | Custom Opencart Theme creation | Opencart Development | Shopify

Website Development

Offshore Web Development | Portfolio Website | Company Website | Blogs

Strategy & Consultation

Digital Strategy | Market Research | Content Strategy | Analysis | Ecommerce Strategy | Technical Consultation

Digital Marketing

SEO/SEM | SMM | SEO Audit Report | Pagespeed Report | Data insights and analysis report.