Vous êtes sur la page 1sur 10

7/6/2018 Guide: Set Up Laravel 5.3 with Docker + LaraDock + Let's Encrypt SSL in Digital Ocean within 5 Minutes.

SIGN
UP
SEARCH T SEARCH
SIGN
IN

SEARCH THE FORUM SEARCH

SIGN IN

SIGN UP

CATALOG

SERIES

SKILLS

PODCAST

DISCUSSIONS

Guide: Set Up Laravel 5.3 with Docker + LaraDock + Let's


Encrypt SSL in Digital Ocean within 5 Minutes.
PUBLISHED 1 YEAR AGO BY MIDASCODEBREAKER

Here is what i did to Set up a laravel Project in Digital Ocean

Install Docker

Login Digital Ocean


Add Droplet
1 Click Install docker
Choose Droplet
reset ROOT password
check email

SSH to your Server

https://laracasts.com/discuss/channels/guides/guide-set-up-laravel-with-docker-laradock-in-digital-ocean-with-5-minutes 1/10
7/6/2018 Guide: Set Up Laravel 5.3 with Docker + LaraDock + Let's Encrypt SSL in Digital Ocean within 5 Minutes.

ssh root@ipaddress

you will be prompt of that password. type the password you receive in your email

then it will ask to you to change a new password just change it to the custom root password you
want

After SSH you can check that docker command is working by typing

$root@midascode:~# docker

Set Up Your Laravel Project

$root@midascode:~# apt-get install git


$root@midascode:~# git clone https://github.com/laravel/laravel
$root@midascode:~# cd laravel
$root@midascode:~/laravel# git checkout develop
$root@midascode:~/laravel/ git submodule add https://github.com/LaraDock/laradock.git
$root@midascode:~/laravel/ cd laradock

Install docker-compose command

$root@midascode:~/laravel/laradock# curl -L
https://github.com/docker/compose/releases/download/1.8.0/run.sh > /usr/local/bin/docker-compose
$root@midascode:~/chmod +x /usr/local/bin/docker-compose

Create Your LaraDock Containers

$root@midascode:~/laravel/laradock# docker-compose up -d nginx mysql

Go to Your Workspace

docker-compose exec workspace bash

Install laravel Dependencies, Add .env , generate Key and give


proper permission certain folder
https://laracasts.com/discuss/channels/guides/guide-set-up-laravel-with-docker-laradock-in-digital-ocean-with-5-minutes 2/10
7/6/2018 Guide: Set Up Laravel 5.3 with Docker + LaraDock + Let's Encrypt SSL in Digital Ocean within 5 Minutes.

$ root@0e77851d27d3:/var/www/laravel# composer install


$ root@0e77851d27d3:/var/www/laravel# cp .env.example .env
$ root@0e77851d27d3:/var/www/laravel# php artisan key:generate
$ root@0e77851d27d3:/var/www/laravel# exit
$root@midascode:~/laravel/laradock# cd ..
$root@midascode:~/laravel# sudo chmod -R 777 storage bootstrap/cache

you can then view your laravel site at your ipaddress for example

192.168.1.1

You will see there Laravel Default Welcome Page

but if you need to view on your custom domain name which you would.

Using Your Own Domain Name


login to your DNS provider Godaddy, Namecheap what ever... And Point the Custom Domain Name
Server to

ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com

In Your Digital Ocean Account go to

https://cloud.digitalocean.com/networking/domains

add your domain name and choose the server ip you provision earlier

Serve Site With NGINX (HTTP ONLY)


Go back to command line

$root@midascode:~/laravel/laradock# cd nginx
$root@midascode:~/laravel/laradock/nginx# vim laravel.conf

remove default_server

listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

https://laracasts.com/discuss/channels/guides/guide-set-up-laravel-with-docker-laradock-in-digital-ocean-with-5-minutes 3/10
7/6/2018 Guide: Set Up Laravel 5.3 with Docker + LaraDock + Let's Encrypt SSL in Digital Ocean within 5 Minutes.

and add server_name (your custom domain)

listen 80;
listen [::]:80 ipv6only=on;
server_name yourdomain.com;

Rebuild Your Nginx

$root@midascode:~/laravel/laradock/nginx# docker-compose down


$root@midascode:~/laravel/laradock/nginx# docker-compose build nginx

Re Run Your Containers MYSQL and NGINX

$root@midascode:~/laravel/laradock/nginx# docker-compose up -d nginx mysql

View Your Site with HTTP ONLY (http://yourdomain.com)

Run Site on SSL with Let's Encrypt Certi cate


Note: You need to Use Caddy here Instead of Nginx

To go Caddy Folders and Edit CaddyFile

$root@midascode:~/laravel/laradock# cd caddy
$root@midascode:~/laravel/laradock/caddy# vim Caddyfile

Remove 0.0.0.0:80

0.0.0.0:80
root /var/www/laravel/public

and replace with your https://yourdomain.com

https://yourdomain.com
root /var/www/laravel/public

uncomment tls

https://laracasts.com/discuss/channels/guides/guide-set-up-laravel-with-docker-laradock-in-digital-ocean-with-5-minutes 4/10
7/6/2018 Guide: Set Up Laravel 5.3 with Docker + LaraDock + Let's Encrypt SSL in Digital Ocean within 5 Minutes.

#tls self-signed

and replace self-signed with your email address

tls midascodebreaker@gmai.com

This is needed Prior to Creating Let's Encypt

Run Your Caddy Container without the -d ag and Generate SSL


with Let's Encypt

$root@midascode:~/laravel/laradock/caddy# docker-compose up caddy

you will be prompt here to enter your email... you may enter it or not

Attaching to laradock_mysql_1, laradock_caddy_1


caddy_1 | Activating privacy features...
caddy_1 | Your sites will be served over HTTPS automatically using Let's Encrypt.
caddy_1 | By continuing, you agree to the Let's Encrypt Subscriber Agreement at:
caddy_1 | https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf
caddy_1 | Activating privacy features... done.
caddy_1 | https://yourdomain.com
caddy_1 | http://yourdomain.com

After it nish Press Ctrl + C to exit ...

Stop All Containers and ReRun Caddy and Other Containers on


Background

$root@midascode:~/laravel/laradock/caddy# docker-compose down


$root@midascode:~/laravel/laradock/caddy# docker-compose up -d mysql caddy

View your Site in the Browser Securely Using HTTPS (https://yourdomain.com)

Note that Certiface will be Automatically Renew By Caddy

References :

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
https://www.digitalocean.com/products/one-click-apps/docker/
https://docs.docker.com/engine/installation/linux/ubuntulinux/

https://laracasts.com/discuss/channels/guides/guide-set-up-laravel-with-docker-laradock-in-digital-ocean-with-5-minutes 5/10
7/6/2018 Guide: Set Up Laravel 5.3 with Docker + LaraDock + Let's Encrypt SSL in Digital Ocean within 5 Minutes.

https://docs.docker.com/compose/install/ https://caddyserver.com/docs/automatic-https
https://caddyserver.com/docs/tls https://caddyserver.com/docs/caddy le

mahmoudz 10 months ago (8,100 XP)

Awesome article. Thanks for sharing.

afraz 7 months ago (6,140 XP)

Really helpful information thanks for sharing.

tomx 2 weeks ago (1,310 XP)

If you're having dif culty creating the LaraDock containers, ensure that you have
rst run # cp .env.example .env

Please sign in or create an account to participate in this conversation.

CREATE ACCOUNT

CHOOSE A FILTER

All Threads

Popular This Week

Popular All Time

Solved

Unsolved

No Replies Yet
https://laracasts.com/discuss/channels/guides/guide-set-up-laravel-with-docker-laradock-in-digital-ocean-with-5-minutes 6/10
7/6/2018 Guide: Set Up Laravel 5.3 with Docker + LaraDock + Let's Encrypt SSL in Digital Ocean within 5 Minutes.

Leaderboard

OR PICK A CHANNEL

All

Code Review

Eloquent

Envoyer

Forge

General

Guides

JavaScript

Laravel

Lumen

Mix

Requests

Servers

Site Feedback

Spark

Testing

Tips

Vue

How To edit insert into users value???


GUIDES • 1 DAY AGO BY TEGUH_RIJANANDI

https://laracasts.com/discuss/channels/guides/guide-set-up-laravel-with-docker-laradock-in-digital-ocean-with-5-minutes 7/10
7/6/2018 Guide: Set Up Laravel 5.3 with Docker + LaraDock + Let's Encrypt SSL in Digital Ocean within 5 Minutes.

Please Guys, help me for edit this default command?? i am want add 18
some code again like a school name, or address SQLSTATE[HY000]:
General error: 1...

Can anyone open this page?


GUIDES • 5 DAYS AGO BY BEHNAMPMDG3
05
Hi; For some reason, I cant access...

Visual studio code php storm method docblocks


GUIDES • 1 WEEK AGO BY LARS-JANSSEN
04
Hi, How do I get the same docblocks like in phpstorm for a method
but then in visual studio code`? Found th...

'remember_token' doesn't have a default value


GUIDES • 4 DAYS AGO BY TEGUH_RIJANANDI

whats should i do?? In users table i have 5 column 04


(Name,email,password,update_at,created_at), but in regsitration form i
dont have inputs with rem...

Package Development Laracast for Laravel 5?


GUIDES • 2 DAYS AGO BY SANDERVANHOOFT
02
Hello, was wondering if there are any plans to update the Package
Development larac...

Expected response code 250 but got code "535", with message "535-5.7.8
GUIDES • 4 DAYS AGO BY CRONIX
01
Whats i should?? Swift_TransportException thrown with message
"Expected response code 250 but got code "535", with message &q...

https://laracasts.com/discuss/channels/guides/guide-set-up-laravel-with-docker-laradock-in-digital-ocean-with-5-minutes 8/10
7/6/2018 Guide: Set Up Laravel 5.3 with Docker + LaraDock + Let's Encrypt SSL in Digital Ocean within 5 Minutes.

Lots of your peers think Laracasts is one of the best things ever. So buy Jeffrey lunch
once a month, see for yourself, and massively level up your skills in the process.

LEARN

Library
Lesson Index
Books
Sign Up
Sign In

DISCUSS

Forum
Laracasts Snippet
https://laracasts.com/discuss/channels/guides/guide-set-up-laravel-with-docker-laradock-in-digital-ocean-with-5-minutes 9/10
7/6/2018 Guide: Set Up Laravel 5.3 with Docker + LaraDock + Let's Encrypt SSL in Digital Ocean within 5 Minutes.

Laravel Podcast
Support

EXTRAS

Statistics
Testimonials
FAQ
Youtube
Get a Job
RSS
Privacy
Terms

© Laracasts 2018. All rights reserved. Yes, all of them. That means you, Todd.

Proudly hosted with Laravel Forge and DigitalOcean.

https://laracasts.com/discuss/channels/guides/guide-set-up-laravel-with-docker-laradock-in-digital-ocean-with-5-minutes 10/10