Giter VIP home page Giter VIP logo

docker-lemp-mongo-multisite's Introduction

Docker: Host Multiple SSL-Enabled LEMP Sites

Docker is great for linking together multiple technologies, but some aspects of it are not terribly obvious.

One such use case is when you want to host multiple PHP sites on the same server.

This repo lets you set up a LEMP stack with a few extra bells and whistles.

In case you're unfamiliar with the term LEMP, it's an awful acronym for:

  • Linux
  • Nginx (which is pronounce "Engine-X"...so this is really stretching)
  • Mariadb
  • PHP

This repo also features MongoDB and Certbot.

Getting started

  1. Modify .env to fit the particulars of your setup. Use absolute file paths.
  2. Modify docker-compose.yml; replacing example.com and othersite.com with your own URLs.
  3. Modify nginx/vhosts/example.com and replace occurences of example.com with your URLs.
  4. Create the following directories: /database, /lets-encrypt, /logs, /mongo-db/, and nginx/certs/
  5. Run setup.sh. It creates the dhparam.key file that your server will need to create valid SSL connections. The key generation is set to its highest setting, and it will take a fair amount of time to work its magic. Go get a coffee or something.

File locations You can place your web sites in any directory on your server that you wish. If you chose a directory other than /sites/example.com, be sure to update the references in your .env file to point to the appropriate directory.

Launch the containers with docker-compose up -d. This runs Docker in detached mode. You'll see a message that your containers have launched, but you will not see continuous logs on your screen.

Open a new web browser and pull up your domain name. If it doesn't appear, check the Nginx logs to see what went wrong.

Logs

Nginx logs are written to logs/nginx/access.log and logs/nginx/error.log

To view the logs for other services, type sudo journalctl <service name>

Certbot

Once the non-SSL version of your site appears, it's time to generate the SSL certificate with Let's Encrypt.

Log into certbot with docker exec -it certbot bash

Then, run:

./certbot-auto certonly --email [email protected] --webroot -w /www -d domain.com -d www.domain.com -d otherdomain.com

Please replace the domains in the string above with your own values. Certbot will then update itself and attempt to validate your domain. Once it does, you can add the SSL-specific segments to your vhost files.

Adding SSL to Nginx Configuration

  1. Navigate to vhosts.secure/example.com
  2. Copy the second server block and paste it into your existing vhosts/example.com file. Replace all instances of example.com with your own domain name.
  3. Restart nginx: docker restart nginx
  4. Attempt to access the secure version of your domain name.

You can check the quality of your setup by verifying it at the SSL Labs web site.

docker-lemp-mongo-multisite's People

Contributors

kaizen-soze avatar

Forkers

codyselman

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.