Install LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu

Exported on 23-Aug-2021 15:43:34

Using Attune to install LAMP Stack

This blueprint installs a LAMP (Linux Apache MySQL [MariaDB] PHP Stack. This full stack can be used to easily serve PHP web application content.
Pre-Blueprint Attune setup
  1. On the Inputs tab, create a Linux node for the host you wish to install the stack on.
  2. On the Inputs tab, create Linux credentials to connect to the host you wish to install the stack on.
  3. On the Inputs tab, create a basic credential that you wish to use for the MySQL root user.
Blueprint Steps
  1. Download all of the latest versions of currently installed Ubuntu packages and install them.
  2. Configure built-in firewall to allow SSH, http and https traffic.
  3. Install the Apache web server to serve web pages.
  4. Install MariaDB (aka MySQL).
  5. Secure the MariaDB install to remove default logins and set a secure root password.

Parameters

Name Type Script Reference Default Value Comment
Host_Creds Linux OS Credential host_creds
Hostname Linux / Unix Server hostname
MySQL Root Generic Credential mysqlRoot

1 - Upgrade apt

The connection details have changed from the last step.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
sudo apt update -y
sudo apt upgrade -y

2 - Open FW Ports

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
sudo ufw allow ssh #allow ssh in Ubuntu firewall
sudo ufw allow 80 #allow http access
sudo ufw allow 443 #allow https access
sudo ufw enable #enable Ubuntu firewall

3 - Install Apache

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
sudo apt install -y apache2

4 - Install PHP

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
sudo apt install -y php7.4 php7.4-mysql php-common php7.4-cli php7.4-json php7.4-common php7.4-opcache libapache2-mod-php7.4

5 - Install MariaDB

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
sudo apt install -y mariadb-server mariadb-client

6 - MariaDB Secure Installation

This step has the following parameters

Name Script Reference Default Value
MySQL Root {mysqlRoot.password} None

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
sudo mysql_secure_installation <<EOF
y
{mysqlRoot.password}
{mysqlRoot.password}
y
y
y
y
EOF

# 1. set root password
# 2. set MySQL root password
# 3. confirm MySQL root password
# 4. remove anonymous users
# 5. disable remote root login
# 6. remove test DB
# 7. save changes