|
| 1 | +#### Install Docker |
| 2 | +``` |
| 3 | +Login Digital Ocean |
| 4 | +Add Droplet |
| 5 | +1 Click Install docker |
| 6 | +Choose Droplet |
| 7 | +reset ROOT password |
| 8 | +check email |
| 9 | +``` |
| 10 | + |
| 11 | +#### SSH to your Server |
| 12 | + |
| 13 | +``` |
| 14 | +ssh root@ipaddress |
| 15 | +``` |
| 16 | +you will be prompt of that password. |
| 17 | +type the password you receive in your email |
| 18 | + |
| 19 | +then it will ask to you to change a new password |
| 20 | +just change it to the custom root password you want |
| 21 | + |
| 22 | +After SSH |
| 23 | +you can check that docker command is working by typing |
| 24 | + |
| 25 | +``` |
| 26 | +$root@midascode:~# docker |
| 27 | +``` |
| 28 | + |
| 29 | +#### Set Up Your Laravel Project |
| 30 | + |
| 31 | +``` |
| 32 | +$root@midascode:~# apt-get install git |
| 33 | +$root@midascode:~# git clone https://github.com/laravel/laravel |
| 34 | +$root@midascode:~# cd laravel |
| 35 | +$root@midascode:~/laravel# git checkout develop |
| 36 | +$root@midascode:~/laravel/ git submodule add https://github.com/LaraDock/laradock.git |
| 37 | +$root@midascode:~/laravel/ cd laradock |
| 38 | +``` |
| 39 | + |
| 40 | +#### Install docker-compose command |
| 41 | + |
| 42 | +``` |
| 43 | +$root@midascode:~/laravel/laradock# curl -L https://github.com/docker/compose/releases/download/1.8.0/run.sh > /usr/local/bin/docker-compose |
| 44 | +$root@midascode:~/chmod +x /usr/local/bin/docker-compose |
| 45 | +``` |
| 46 | + |
| 47 | +#### Create Your LaraDock Containers |
| 48 | + |
| 49 | +``` |
| 50 | +$root@midascode:~/laravel/laradock# docker-compose up -d nginx mysql |
| 51 | +``` |
| 52 | + |
| 53 | +#### Go to Your Workspace |
| 54 | + |
| 55 | +``` |
| 56 | +docker-compose exec workspace bash |
| 57 | +``` |
| 58 | + |
| 59 | +#### Install laravel Dependencies, Add .env , generate Key and give proper permission certain folder |
| 60 | + |
| 61 | +``` |
| 62 | +$ root@0e77851d27d3:/var/www/laravel# composer install |
| 63 | +$ root@0e77851d27d3:/var/www/laravel# cp .env.example .env |
| 64 | +$ root@0e77851d27d3:/var/www/laravel# php artisan key:generate |
| 65 | +$ root@0e77851d27d3:/var/www/laravel# exit |
| 66 | +$root@midascode:~/laravel/laradock# cd .. |
| 67 | +$root@midascode:~/laravel# sudo chmod -R 777 storage bootstrap/cache |
| 68 | +``` |
| 69 | + |
| 70 | +you can then view your laravel site at your ipaddress |
| 71 | +for example |
| 72 | +``` |
| 73 | +192.168.1.1 |
| 74 | +``` |
| 75 | + |
| 76 | +You will see there Laravel Default Welcome Page |
| 77 | + |
| 78 | +but if you need to view on your custom domain name |
| 79 | +which you would. |
| 80 | + |
| 81 | +#### Using Your Own Domain Name |
| 82 | +login to your DNS provider |
| 83 | +Godaddy, Namecheap what ever... |
| 84 | +And Point the Custom Domain Name Server to |
| 85 | + |
| 86 | +``` |
| 87 | +ns1.digitalocean.com |
| 88 | +ns2.digitalocean.com |
| 89 | +ns3.digitalocean.com |
| 90 | +``` |
| 91 | +In Your Digital Ocean Account go to |
| 92 | +``` |
| 93 | +https://cloud.digitalocean.com/networking/domains |
| 94 | +``` |
| 95 | +add your domain name and choose the server ip you provision earlier |
| 96 | + |
| 97 | +#### Serve Site With NGINX (HTTP ONLY) |
| 98 | +Go back to command line |
| 99 | +``` |
| 100 | +$root@midascode:~/laravel/laradock# cd nginx |
| 101 | +$root@midascode:~/laravel/laradock/nginx# vim laravel.conf |
| 102 | +``` |
| 103 | +remove default_server |
| 104 | +``` |
| 105 | +
|
| 106 | + listen 80 default_server; |
| 107 | + listen [::]:80 default_server ipv6only=on; |
| 108 | +
|
| 109 | +``` |
| 110 | + and add server_name (your custom domain) |
| 111 | +``` |
| 112 | + listen 80; |
| 113 | + listen [::]:80 ipv6only=on; |
| 114 | + server_name yourdomain.com; |
| 115 | +``` |
| 116 | + |
| 117 | +#### Rebuild Your Nginx |
| 118 | +``` |
| 119 | +$root@midascode:~/laravel/laradock/nginx# docker-compose down |
| 120 | +$root@midascode:~/laravel/laradock/nginx# docker-compose build nginx |
| 121 | +``` |
| 122 | + |
| 123 | +#### Re Run Your Containers MYSQL and NGINX |
| 124 | +``` |
| 125 | +$root@midascode:~/laravel/laradock/nginx# docker-compose up -d nginx mysql |
| 126 | +``` |
| 127 | + |
| 128 | +###### View Your Site with HTTP ONLY (http://yourdomain.com) |
| 129 | + |
| 130 | +#### Run Site on SSL with Let's Encrypt Certificate |
| 131 | + |
| 132 | +###### Note: You need to Use Caddy here Instead of Nginx |
| 133 | + |
| 134 | +###### To go Caddy Folders and Edit CaddyFile |
| 135 | + |
| 136 | +``` |
| 137 | +$root@midascode:~/laravel/laradock# cd caddy |
| 138 | +$root@midascode:~/laravel/laradock/caddy# vim Caddyfile |
| 139 | +``` |
| 140 | + |
| 141 | +Remove 0.0.0.0:80 |
| 142 | + |
| 143 | +``` |
| 144 | +0.0.0.0:80 |
| 145 | +root /var/www/laravel/public |
| 146 | +``` |
| 147 | +and replace with your https://yourdomain.com |
| 148 | + |
| 149 | +``` |
| 150 | +https://yourdomain.com |
| 151 | +root /var/www/laravel/public |
| 152 | +``` |
| 153 | +uncomment tls |
| 154 | + |
| 155 | +``` |
| 156 | +#tls self-signed |
| 157 | +``` |
| 158 | +and replace self-signed with your email address |
| 159 | + |
| 160 | +``` |
| 161 | +tls midascodebreaker@gmai.com |
| 162 | +``` |
| 163 | +This is needed Prior to Creating Let's Encypt |
| 164 | + |
| 165 | +#### Run Your Caddy Container without the -d flag and Generate SSL with Let's Encrypt |
| 166 | + |
| 167 | +``` |
| 168 | +$root@midascode:~/laravel/laradock/caddy# docker-compose up caddy |
| 169 | +``` |
| 170 | + |
| 171 | +you will be prompt here to enter your email... you may enter it or not |
| 172 | +``` |
| 173 | +Attaching to laradock_mysql_1, laradock_caddy_1 |
| 174 | +caddy_1 | Activating privacy features... |
| 175 | +caddy_1 | Your sites will be served over HTTPS automatically using Let's Encrypt. |
| 176 | +caddy_1 | By continuing, you agree to the Let's Encrypt Subscriber Agreement at: |
| 177 | +caddy_1 | https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf |
| 178 | +caddy_1 | Activating privacy features... done. |
| 179 | +caddy_1 | https://yourdomain.com |
| 180 | +caddy_1 | http://yourdomain.com |
| 181 | +``` |
| 182 | + |
| 183 | +After it finish Press Ctrl + C to exit ... |
| 184 | + |
| 185 | +#### Stop All Containers and ReRun Caddy and Other Containers on Background |
| 186 | + |
| 187 | +``` |
| 188 | +$root@midascode:~/laravel/laradock/caddy# docker-compose down |
| 189 | +$root@midascode:~/laravel/laradock/caddy# docker-compose up -d mysql caddy |
| 190 | +``` |
| 191 | +View your Site in the Browser Securely Using HTTPS (https://yourdomain.com) |
| 192 | + |
| 193 | +##### Note that Certificate will be Automatically Renew By Caddy |
| 194 | + |
| 195 | +>References: |
| 196 | +> |
| 197 | +- [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04) |
| 198 | +- [https://www.digitalocean.com/products/one-click-apps/docker/](https://www.digitalocean.com/products/one-click-apps/docker/) |
| 199 | +- [https://docs.docker.com/engine/installation/linux/ubuntulinux/](https://docs.docker.com/engine/installation/linux/ubuntulinux/) |
| 200 | +- [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/) |
| 201 | +- [https://caddyserver.com/docs/automatic-https](https://caddyserver.com/docs/automatic-https) |
| 202 | +- [https://caddyserver.com/docs/tls](https://caddyserver.com/docs/tls) |
| 203 | +- [https://caddyserver.com/docs/caddyfile](https://caddyserver.com/docs/caddyfile) |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | + |
| 214 | + |
0 commit comments