How to install LAMP on Docker with Ubuntu Server Systems

Systems  Help?

Step-by-step tutorial on how to install LAMP stack (Linux, Apache, MySQL, PHP) in a Docker, environment optimized for a server with Ubuntu Server operating system.

This tutorial is designed to give you a hassle-free experience, from getting a server and its initial configuration to the successful implementation of a robust, efficient and scalable development environment.

 A little theory

What is stack Lamp?

A LAMP stack is a combination of four different software technologies that developers use to create websites. LAMP is an abbreviation of Linux operating system, Apache web server, MySQL database server and PHP language. All four technologies are open source, meaning they are community-protected and free for anyone to use. Developers use LAMP stacks to create, host, and store web content. This is a popular method that is supported by most websites in use today.

What is Docker?

Docker is a software platform that allows you to quickly build, test, and deploy applications. Docker packages software into stable components called containers, which contain everything the software needs to run, including libraries, tools, code, and runtime. With Docker, you can quickly deploy and develop applications on any platform, knowing that your code will run.

What is Docker for?

Docker allows you to deliver code faster, standardize application operations, easily port code, and save money by improving resource utilization. With Docker, you get a single object that can run reliably anywhere. Docker's simple and straightforward syntax gives you full control. Widespread adoption means there is a large ecosystem of ready-to-use tools and applications that you can use with Docker.

 Tutorial

1

Get server and its configuration

Assign the input ports. Below I indicate the ports that must be open.

Type Protocol Port
SSH TCP 22
HTTP TCP 80
PHPMYADMIN TCP 8000
2

Install and configure Docker

3

Install repository Ubuntu Server Lamp Docker

 What software do we need to carry out this tutorial?

Since we are going to use Ubuntu Server (Linux System) we will need these programs compatible with Windows.

 Commands

Below I detail the commands to be able to carry out this tutorial. From here on, it is implicit that you already have the server installed, configured and with administrative access to it.

1

Install and configure Docker

Access as 'root'
sudo su

 For Oracle servers (OCI Oracle Cloud Infrastructure)


We eliminate IPTables
systemctl enable ufw
ufw allow 22
ufw enable
apt remove netfilter-persistent

We restart the server
reboot

As always, make sure your system has updated packages first.
apt-get update
apt-get upgrade

Next, install the dependencies.
apt-get install ca-certificates curl gnupg
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)"signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update

We install Doker and Docker Compose
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
apt install docker-compose
2

Install Ubuntu Server Lamp Docker repository

Install the repository: Ubuntu Server Lamp Docker
git clone https://github.com/juanantonioripoll/ubuntu-server-docker-lamp.git
Ubuntu Server Docker Repository Lamp

We position ourselves in the Ubuntu Server Lamp Docker directory
cd /home/ubuntu/ubuntu-server-docker-lamp/

We raise the Ubuntu Server Lamp Docker repository
docker-compose up -d

 Commands of interest

To grant permissions to the 'ubuntu-server-docker-lamp/www' directory
chown -R -v ubuntu /home/ubuntu/ubuntu-server-docker-lamp/www

To view the containers
docker ps -a

To view the images
docker images

To enter a Docker container
sudo docker exec -i -t e271 /bin/bash
'e271' are the first letters of the container name

 Access to phpmyadmin

To access phpmyadmin
http://tuipordomain:8000
User:root
Pass:root

 Programming Courses

 C# Programming Course

Free
Curso de programacion C# Sharp
  • 12 C# Lessons with their exercises
  • 224 C# Exercises with the solution
  • 224 Very useful C# Sample Codes
  • Completely Free and without registration
  • Suitable for beginners and advanced
  • Suitable for everyone
Go to C# Course  

 Java Programming Course

Free
Java Programming Course - Free
  • 12 Java Lesson with their exercises
  • 224 Java Exercises with the solution
  • 224 Very useful Java Sample Codes
  • Completely Free and without registration
  • Suitable for beginners and advanced
  • Suitable for everyone
Go to Java Course  

 VB.Net Programming Course

Free
Visual Basic (VB.Net) Programming Course - Free
  • 12 VB.Net Lessons with their exercises
  • 224 VB.Net Exercises with the solution
  • 224 Visual Basic Sample Codes
  • Completely Free and without registration
  • Suitable for beginners and advanced
  • Suitable for everyone
Go to VB.Net Course  
Juan A. Ripoll - Systems Tutorials and Programming Courses © 2024  All rights reserved.  Legal Conditions.