In this article, we will begin with installing the LAMP stack on a Ubuntu 18.04 server. LAMP stands for Linux, Apache, MySQL, and PHP. Linux is the operating system, Apache is the web server for the application, MySQL is the database, and PHP is the programming language. To follow through this tutorial, you can use a virtual machine and spin up a new Ubuntu 18.04 server (it’s free). For some more information virtual machines, please visit this article:

If you already know how to do this and just want to set everything up as fast as possible, there is a script here that should get everything setup for installing LAMP stack and a WordPress site (You may have to change a few things in the script, like the database password. The comments should help explain what the script does): To run it, just run “bash full” and make sure it has the proper permissions.

A more detailed article on this can be found at This article pretty much covers the same thing, but the one on this page is just much shorter and gets straight to the point.


To start, let’s run the following commands:

sudo apt update
sudo apt install apache2

Now let’s make sure the firewall doesn’t interfere with our web server by running this:

sudo ufw allow in "Apache Full"
sudo systemctl restart apache2


We will now install the database by running:

sudo apt install mysql-server

The command below is just a security script that helps remove some potentially dangerous settings. You can answer Yes for most of them. The MySQL section in this article here explains it in more detail:

sudo mysql_secure_installation

The settings are up to you, but here are what I answered for this project:
Password validate plug: N
New Password: CHANGEME
Confirm Passowrd: CHANGEME
Remove anonymous users: Y
Disallow root login remotely: N
Remove test database: Y
Reload priviledge table: Y

The password you set above will be for the ‘root’ user.


Now we can install PHP on the server along with some dependencies by running:

sudo apt install php libapache2-mod-php php-mysql
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

Then we can set it so that Apache prioritizes php files by opening up /etc/apache2/mods-enabled/dir.conf and change the order of the entries there so that it looks like this:

DirectoryIndex index.php index.html index.cgi index.xhtml index.htm

Now let’s restart the Apache server for the changes to take affect

sudo systemctl restart apache2

The LAMP stack should be all setup now! In the next article, we will use this to install WordPress onto our server.


The next article can be found here.