fbpx LAMP in 2 Minutes: Install Apache, MySQL and PHP on Linux | Certificação Linux

LAMP Stack in 2 Minutes

📅 07/20/2018 ⏱ 2 min ✍️ Uira Ribeiro
Linux
LAMP Stack in 2 Minutes
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

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 mysql mkdir nginx mkdir html docker-compose up -d (learn what docker is and get to know the 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;

include fastcgi_params;

}

}

Learn and develop your skills with the complete Docker for DevOps course from Certificação Linux. You can enroll here with a 7-day free trial. If you already have an account, you can access it here.

Liked it? Share :-)

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp