Categories: How-To

LAMP in 2 Minutes

Linux + Nginx + Mysql + PHP + phpMyAdmin in 2 minutes

Create a Linux server with Nginx web server, Mysql database and PHP in less than 2 minutes.

Commands used

curl -fSSL https://get.docker.com/ | sh

sudo systemctl enable docker.service

Sudo Systemctl Start Docker

curl -L “https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s) -$ (uname -m)” -o /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

mkdir LEMP

CD LEMP

mkdir logs

Touch logs/nginx-access.log

Touch logs/nginx-error.log

mkdir to MySQL

mkdir nginx

mkdir html

docker-compose up -d (learn what docker is and learn about docker commands here)docker-compose.yml file

nginx:

image: tutum/nginx

Ports:

– “80:80”

links:

– phpfpm

– MySQL

volumes:

-. /nginx/default:/etc/nginx/sites-available/default

-. /nginx/default:/etc/nginx/sites-enabled/default

– /Users/Uiraribeiro/Documents/LearnLinux/Public_HTML:/usr/share/nginx/html

phpfpm:

image: php:fpm

Ports:

– “9001:9000”

volumes:

– /Users/Uiraribeiro/Documents/LearnLinux/Public_HTML:/usr/share/nginx/html

links:

– MySQL

MySQL:

image: mariadb

Environment:

MYSQL_ROOT_PASSWORD: admin

volumes:

-. /mysql:/var/lib/mysql

phpmyadmin:

image: phpmyadmin/phpmyadmin

restart: always

links:

– MySQL

Ports:

– 8181:80

Environment:

MYSQL_USERNAME: admin

MYSQL_ROOT_PASSWORD: admin

PMA_ARBITRARY: 1

nginx/default file

server {

listen 80;

root /usr/share/nginx/html;

index index.php index.html index.html;

server_name 127.0.0.1; # CHANGE YOUR IP HERE

location/{

try_files $uri $uri/ /index.php $is_args$args;

}

location ~ .php$ {

fastcgi_split_path_info ^ (.+ .php) (/.+) $;

fastcgi_pass phpfpm:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

includes fastcgi_params;

}

}

Learn and develop your skills with the full Docker for DevOps course from the Linux Certification. You can enroll here with a free 7-day trial. If you already have an account, you can log in here.

Did you like it? Share 🙂

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Recent Posts

Sudo command on Linux (privilege scale) [Basic Guide]

The sudo command on Linux executes a given command as if it were another user.…

2 years ago

SS command on Linux (investigate the network) [Basic Guide]

The ss command on Linux is extremely useful for investigating sockets, providing various information about…

2 years ago

Free Linux command (memory usage) [Basic Guide]

Free Linux command shows the amount of total memory in use and available, as well…

2 years ago

Linux while command (loop – while) [Basic Guide]

The shell has structures for testing conditions and executing certain program sequences several times (loop),…

2 years ago

Linux fstab file (disk mount setup) [Basic Guide]

The /etc/fstab file stores the configuration of which devices should be mounted and what is…

2 years ago

Netcat command on Linux (Swiss network knife) [Basic Guide]

The Netcat Command in Linux or nc is a utility used to do “almost anything”…

2 years ago

This website uses cookies.