Configurar Laravel con Mysql en Docker
Versión 3 (Guillermo Zdanowicz, 04/01/2019 11:01)
1 | 1 | Guillermo Zdanowicz | h1. Configurar Laravel con Mysql en Docker |
---|---|---|---|
2 | 1 | Guillermo Zdanowicz | |
3 | 1 | Guillermo Zdanowicz | INSTALO DOCKER PARA MYSQL |
4 | 1 | Guillermo Zdanowicz | docker run --name automysql -v /home/backup/bdmysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root911 -d mysql:5.7 |
5 | 1 | Guillermo Zdanowicz | |
6 | 1 | Guillermo Zdanowicz | INSTALO DOCKER PARA NGINX VINCULANDO MYSQL |
7 | 1 | Guillermo Zdanowicz | docker run --name autodocker -d --link automysql:mysql -p 8080:80 -v "/home/projects/autogestion:/var/www/app:rw" --restart=always romeoz/docker-nginx-php:7.2 |
8 | 1 | Guillermo Zdanowicz | |
9 | 1 | Guillermo Zdanowicz | VERIFICO DOCKERS INSTALADOS |
10 | 1 | Guillermo Zdanowicz | sudo docker ps -a |
11 | 1 | Guillermo Zdanowicz | |
12 | 1 | Guillermo Zdanowicz | PARO DOCKER |
13 | 1 | Guillermo Zdanowicz | docker stop autodocker |
14 | 1 | Guillermo Zdanowicz | |
15 | 1 | Guillermo Zdanowicz | ELIMINO DOCKER |
16 | 1 | Guillermo Zdanowicz | docker rm autodocker |
17 | 1 | Guillermo Zdanowicz | |
18 | 1 | Guillermo Zdanowicz | INICIO DOCKER |
19 | 1 | Guillermo Zdanowicz | docker start autodocker |
20 | 1 | Guillermo Zdanowicz | |
21 | 1 | Guillermo Zdanowicz | EN SERVIDOR LOCAL BAJAR POR EJEMPLO EN /home/projects el codigo del repositorio |
22 | 1 | Guillermo Zdanowicz | |
23 | 1 | Guillermo Zdanowicz | BAJO DEL REPOSITORIO EL CODIGO |
24 | 1 | Guillermo Zdanowicz | git clone (link repositorio en este caso de llama autogestion la carpeta) |
25 | 1 | Guillermo Zdanowicz | |
26 | 1 | Guillermo Zdanowicz | docker run --name autodocker -d --link automysql:mysql -p 8080:80 -v "/home/projects/autogestion:/var/www/html:rw" --restart=always romeoz/docker-nginx-php:7.2 |
27 | 1 | Guillermo Zdanowicz | |
28 | 1 | Guillermo Zdanowicz | //INGRESO AL DOCKER DEL NGINX |
29 | 1 | Guillermo Zdanowicz | docker exec -ti autodocker bash |
30 | 1 | Guillermo Zdanowicz | |
31 | 1 | Guillermo Zdanowicz | INGRESO A LA CARPETA DEL SITIO |
32 | 1 | Guillermo Zdanowicz | /var/www/app |
33 | 1 | Guillermo Zdanowicz | |
34 | 1 | Guillermo Zdanowicz | |
35 | 1 | Guillermo Zdanowicz | ACTUALIZAMOS COMPOSER |
36 | 1 | Guillermo Zdanowicz | composer update |
37 | 1 | Guillermo Zdanowicz | |
38 | 1 | Guillermo Zdanowicz | CORRO SENTENCIA INICIAL DE LARAVEL |
39 | 1 | Guillermo Zdanowicz | php artisan key:generate |
40 | 1 | Guillermo Zdanowicz | |
41 | 3 | Guillermo Zdanowicz | CONFIGURAR LA CONEXION DE BASE DE DATOS EN EL RAIZ DEL PROYECTO BAJADO |
42 | 3 | Guillermo Zdanowicz | copiar .env.example con el nombre .env |
43 | 3 | Guillermo Zdanowicz | |
44 | 3 | Guillermo Zdanowicz | EDITAR EL ARCHIVO .ENV configurando la base de datos cuyo servidor de base de dato en este caso es automysql (tambien esta en docker) |
45 | 3 | Guillermo Zdanowicz | |
46 | 3 | Guillermo Zdanowicz | luego ingresar al servidor de base de datos y crear la base de datos segun el proyecto |
47 | 3 | Guillermo Zdanowicz | |
48 | 3 | Guillermo Zdanowicz | docker exec -ti automysql bash |
49 | 3 | Guillermo Zdanowicz | |
50 | 3 | Guillermo Zdanowicz | mysql -uroot -p(clave) |
51 | 3 | Guillermo Zdanowicz | |
52 | 3 | Guillermo Zdanowicz | creada la base de datos regresamos al docker del sistema y corroborando con mucho cuidado que se va a borrar toda la base de datos configurada se ejecuta desde el raiz del proyecto |
53 | 3 | Guillermo Zdanowicz | |
54 | 3 | Guillermo Zdanowicz | composer dump-autoload |
55 | 3 | Guillermo Zdanowicz | php artisan migrate:refresh |
56 | 3 | Guillermo Zdanowicz | php artisan db:seed |
57 | 3 | Guillermo Zdanowicz | |
58 | 3 | Guillermo Zdanowicz | ESTO EJECUTADO VA A GENERAR LAS TABLAS INICIALES Y LAS QUE TENGA EL PROYECTO EN LA BASE DE DATOS |
59 | 3 | Guillermo Zdanowicz | |
60 | 3 | Guillermo Zdanowicz | |
61 | 3 | Guillermo Zdanowicz | PARA VERIFICAR SI ESTA CONECTANDOSE EN LA BASE DE SATOS |
62 | 1 | Guillermo Zdanowicz | ---------------------------------------------- |
63 | 2 | Guillermo Zdanowicz | |
64 | 1 | Guillermo Zdanowicz | DENTRO DEL autodocker CONFIGURAR EL ARCHIVO /etc/nginx/conf.d/default.conf |
65 | 1 | Guillermo Zdanowicz | |
66 | 1 | Guillermo Zdanowicz | |
67 | 2 | Guillermo Zdanowicz | <pre> |
68 | 1 | Guillermo Zdanowicz | |
69 | 1 | Guillermo Zdanowicz | server { |
70 | 1 | Guillermo Zdanowicz | listen 80; |
71 | 1 | Guillermo Zdanowicz | server_name localhost; |
72 | 1 | Guillermo Zdanowicz | |
73 | 1 | Guillermo Zdanowicz | root /var/www/app/public; |
74 | 1 | Guillermo Zdanowicz | index index.php; |
75 | 1 | Guillermo Zdanowicz | charset utf8; |
76 | 1 | Guillermo Zdanowicz | |
77 | 1 | Guillermo Zdanowicz | location /assets/ |
78 | 1 | Guillermo Zdanowicz | { |
79 | 1 | Guillermo Zdanowicz | location ~ \.(?:js|json|ts|css|scss|woff(?:2)?|ttf|map|ico|html|xml|swf|flv|pdf|xls|htc|svg|gif|jpg|png|jpeg)$ { |
80 | 1 | Guillermo Zdanowicz | log_not_found off; |
81 | 1 | Guillermo Zdanowicz | expires 90d; |
82 | 1 | Guillermo Zdanowicz | gzip on; |
83 | 1 | Guillermo Zdanowicz | gzip_static on; |
84 | 1 | Guillermo Zdanowicz | gzip_http_version 1.1; |
85 | 1 | Guillermo Zdanowicz | gzip_comp_level 8; |
86 | 1 | Guillermo Zdanowicz | gzip_types text/plain text/css application/x-javascript text/javascript; |
87 | 1 | Guillermo Zdanowicz | } |
88 | 1 | Guillermo Zdanowicz | |
89 | 1 | Guillermo Zdanowicz | return 404; |
90 | 1 | Guillermo Zdanowicz | } |
91 | 1 | Guillermo Zdanowicz | |
92 | 1 | Guillermo Zdanowicz | error_page 500 502 503 504 /50x.html; |
93 | 1 | Guillermo Zdanowicz | location = /50x.html { |
94 | 1 | Guillermo Zdanowicz | root /usr/share/nginx/html; |
95 | 1 | Guillermo Zdanowicz | } |
96 | 1 | Guillermo Zdanowicz | |
97 | 1 | Guillermo Zdanowicz | location / |
98 | 1 | Guillermo Zdanowicz | { |
99 | 1 | Guillermo Zdanowicz | try_files $uri $uri/ /index.php?$args; |
100 | 1 | Guillermo Zdanowicz | } |
101 | 1 | Guillermo Zdanowicz | |
102 | 1 | Guillermo Zdanowicz | location ~ \.php$ |
103 | 1 | Guillermo Zdanowicz | { |
104 | 1 | Guillermo Zdanowicz | try_files $uri =404; |
105 | 1 | Guillermo Zdanowicz | include fastcgi_params; |
106 | 1 | Guillermo Zdanowicz | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
107 | 1 | Guillermo Zdanowicz | fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; |
108 | 1 | Guillermo Zdanowicz | } |
109 | 1 | Guillermo Zdanowicz | |
110 | 1 | Guillermo Zdanowicz | } |
111 | 2 | Guillermo Zdanowicz | </pre> |