Code Monkey home page Code Monkey logo

lempfleet's Introduction

๐Ÿšข LempFleet

Dead simple LEMP multi-site docker skeleton ๐Ÿ’€

Sometimes, you would want to share a single server for multiple websites, but you still want to use docker. Maybe you just want to have a much simpler docker setup for your development, and you dont want to have multiple instances of mysql, nginx, and having to build/rebuild tons of images.

Well, no matter what your reason is. Here's a very simple, drop-in, multi-site setup for docker on a LEMP stack.

Laravel 6.0 support ready out-of-the-box

Stacks

  1. Linux Alpine (php:7.3-fpm-alpine)
    • Installed packages : libpng-dev libzip-dev zlib-dev unzip zip git composer
    • Installed php extensions : gd pdo_mysql mysqli mbstring zip exif pcntl
  2. NGINX (nginx:alpine)
  3. Mysql (mysql:latest)

Setting up

  1. Clone this repository
$ git clone https://github.com/askaoru/LempFleet docker
  1. Go into the directory and start the containers
$ cd docker && docker-compose up -d
  1. That's all! You should be able to see that the containers are running and exec into them! Check running services
$ docker-compose ps

    Name                  Command              State                    Ports
-----------------------------------------------------------------------------------------------
applications   docker-php-entrypoint php-fpm   Up      9000/tcp
database       docker-entrypoint.sh mysqld     Up      0.0.0.0:3306->3306/tcp, 33060/tcp
webserver      nginx -g daemon off;            Up      0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp

Accessing the container

$ docker exec -it applications /bin/sh

Adding a project

It's very simple!

  1. Add your project into the app folder Example
- app
  - project1 <-- here
    - index.php
  - project2 <-- and here
    - index.php
- mysql
- nginx
- php
- docker-compose.yml
  1. Create nginx conf file for your projects
- app
- mysql
- nginx
  - project1.cnf <-- this
  - project2.cnf <-- and this
- php
- docker-compose.yml

with the following contents for each of them

server {
    listen 80;
    index index.php index.html;
    server_name project.test; # Change accordingly
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /app/project; # Change accordingly
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
    location / {
        try_files $uri $uri/ /index.php?$query_string;
        gzip_static on;
    }
}
  1. And done! All you need to do now is just to restart the services
$ docker-compose down && docker-compose up -d

That's all!

Feel free to open an issue if you have any question and pull requests are appreciated!

lempfleet's People

Contributors

n-az avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.