How to setup PHP Laravel into Docker with NGINX and MariaDB/MySQL

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello there and welcome back my videos in this video i want to speak about how you can set up the level project into a doc container and i will show how i can set up the php fpm and the nginx as a proxy and then i will set up the mariadb as a database so you also all have everything together and you just can spin up and then just start to code of course if you don't need the maria debate then you can just skip that part but i'll show how you can starting from scratch and be ready to code a new project in larval thank you to have you here and i really hope you want to subscribe you can click on the link below in the right corner and i really hope you wanted to like and share this video too and don't forget the all the code i'm typing down here i'll make a complete setup file and you can find it on on git github so you can get all the commands pretty fast thank you so much and let's get some code so let's starting to clone the kit label kit project and i'll open the terminal and i'm going inside my folder where we want to clone and why i'm using this is because i have expect some weird errors when i'm going inside my terminal in my editor so we're just waiting till it's be done and when it's done you can see all the files here for larval it's it's completed then we need to go inside the lava project and we need to say darker run and then we need this one and i'm just installing the composer part inside a directory it could take a little little time so when it's done i think you can go out for grab some coffee and something like that so when it's finished we want to go back for the editor and then just go into the lava folder and create a new one and should be a docker compose dot jump on fine and inside that we can starting to say we want to use the version at this point i want to use 7 3.7 and in the services we have a bunch of services we want the php fpm service and that should be called app and inside that we need to build context docker files the docker file and that container name should be app and restart unleashed it stops and then you need gti it should be true and the working gear should be the folder you want to work with the volumes you see the main folder so the the label folder here would be the the amount and you want to mount it for the nbv then we need the configuration you want to create dockerfiles and php and local.ini then we want to point it for user local htc php conf d and then local.e and then we need network we wanted to bind for the app network we want to create that and we are a little longer in this video and the next one we want is a unix service and this should be the web server i think you can just yes that's correct and the web server should go in with the image nginx alpine yes and the container name should be web server restart unleashed stopped and to try true parts should be 80 80. if you have something running on your machine you can do it to another machine when i'm code i'm always use port 8000 so in this case because i know on my machine i have more running on 8 000 so let's call it 8100 and then we need [Music] 8143 that should be the 43 port that should be the ssl port if you want that for that we have a volume two going up here and again we want to bind the main folder here from level to the uv and then we need to bind dark of ions and your next conf d the folder we want to bind to utc nginx conf d so we have the same folder amount and again network should be able to work just yes and this last one should be maria db service and we call it db here and the image should be maria db 1056 and container name should be db and restart should be unleashed stopped and gi is true just need to see if i split this up a little bit yeah it's fine and the environment we take ports first and for this we need 3306 and three three zero six that's the default part number nine square and it's well marie the b2 and i have it here as you can see we share the same variables so mariadb and and mysql is almost the same as just some point back in time where mysql is get buying from oracle then a lot of people going from mysql and touching in the mario debate so the the fundament uh the fundamental of the base code and that's the same as mysql but it's over time it will be changed a little bit so i'm not 100 sure how it's working if you're taking export from mysql and import to maria to be in the same to make the that would be around then we need the root password i just say one two three four five six this is not a production uh password of course and then go down here and say db data area i'm not spilling anymore data and then we need the lib and march let me mount it to the internal one so if we destroy the container and upgrade it we don't miss all of the code data then we need docker files again and mysql my con should be the same as the egc mysql and this should be network should be the same again just seeing it works just not working and networks here scrolling down i don't know what i'm start with here but it's okay got a volume and networks and that's it so the volumes you need to define should be maria this one and driver should be local okay it just says to duplicate so then we go i'm just one level two to high so yeah that's fine and then we go into the networks and the driver should be bridge and then we are almost there with the composer file now we need to create the the docker the docker file we will want to build with here in the php fpm service so let's do this we want to create a new file call it a double file inside this one we will say from php 7 3 fpm i have tried with the 7 and it's i can use the same models here but when i'm going for testing the lava the something is going wrong so it's not working as i expect so if you know the the version of the of the php 74 some some point then let me know that in the comments fields below but from now we just use this so the next one should be copy composer luck composer json to the va uv that's what we're gonna do yes and the word here should be about the v and then you run f get update and app get installed view and then we and there's a lot of package we need here i just want to see what i have to install everything fine here from my documentation here i think so run up get installed no clean and remove everything we got in one lip extensions install video mysql ship include oh wait jpeg yeah should be gpg we want to say install just so you know what's going on clear cache dependencies now install the composer composer.org installer [Music] local bin file name composer i have to use a phone now and then you can just say run that g one thousand vb and then we say user add username and want to [Music] really and then we need to application folder copy inside tool so we can copy everything in and then we want to say copy copy there exist the permissions inside got me and then we say run see how oh recursive and then you want to say user ub chains change current user to ubb expose 9000 then we want to listen under port 9000 and the command should be php fpm so if i'm done everything correct here then we can just build it up for this container but before we undone this we need of course all the docker files so let's create a new folder here and say it said dockerfile.com files inside that we need a file called the php local ini and upload box file size is equal to 40 megabyte and post marks size is equal to 440 megabyte then we want the nginx gateway and this would be here nginx conf d and app.com and want to see the server and less than 40 80 sorry index should be index.php index.html eurolog if you want that you can just say my unlock genex euro block and then we need the excess lock and the road should be public and i can already see a mistake here and then we need the locations you want to see everything everything with php should be go inside here our location everything else should we go inside here tri-files keep restraining g-ship static on and i'm going to go in as i just said try fines [Music] 400 fast tgi info and then we've got this one plus php here we go this way pause cgi index touch php include fast cgi arms fast cgi params script file name is equal to document road rcgi script name rcgi perhaps path info is equal to classic jr path then we probably have the nginx folder and then we need to the the mysql so let's call one folder here mysql my gen f that's fine and inside this we just need particle d general log is one and uh time should be and then we are good to go before we can build the container we only need one thing now it should be inside dot enb here the example we only need to to rename so we have this one and scrolling down to the mask well and the host should be db and also we want the root and one two three four five six i think that's a connection we need and then we are ready to go back for the editor here and say docker compose build no cache so let's see how it's working must be a mapping so we have already error here let's see about that's the problem so on support environments that's what we're gonna do now just scroll up to my documentation here let's say e n v i r o n m nt environment [Music] and failed execute script toggle compose i have done some little changes so let's about see how it's working now it should work as it should be it should go for the php 73 and fpm and let's see about this building correct so if it's working correct like now then i can show you what i've done this is my docker and i'm going to the settings and downs below here in the docker engine.com and here normally i've switched to the vsl2 based engine it should be giving it better performance than vsn the hyper-v but i expect some issues with that and now i'm just reading on the from others about this could be an issue and it's not totally stable right now so i decided to switch it off and then just use my machine here and restart the engine and i want to remove the the window folder and then run the docker compose installed one more time after that it's look like it's everything is running like a chain so let's hope everything's going well i'll just see when we're finished yet to run this setup now we are done we can just say drug up whoops compose up uh and then d and then we should starting up everything and first let's want to download the image we need and then setting up everything correctly after that we have an error to creating the database so because i already have this image show that's going far away from this one very to be i have it's already running so containers running here we just need to stop it down and then we have the level up here and i will just try that again i'm about to see what happening and now the marietv is up there restarting here php fpm is not found so i need to investigate that and the web show we have a configuration inside here so i need to check my configuration file a little bit and then we should be good to go we almost there we can build it and that's what we wanted up so let's going back for the editor here and going on for the dockerfiles and that's the nginx here and yeah this one and we just say going to the web show and just remove it a little bit so doggo pose up the web server and let's see ah wrong i need to go inside here double compose up the web server [Music] it should connect up the website over here and it's running ready for warm-up and now it's crashed so it's because we don't have the app running so when we have the app running here the php fpm not found i need to see why it's not found so hang on so what i'm just covering in my configuration file i have a single blink and a double plane and that's probably something with that to do because what i'm done is remove the container be sure to stop and then remove it and then i rebuild it again and send it up again so now it's working and let's start up this web server and the database let's clean up the terminal here and docker compose execute app php archer when we use to generate a key inside the the level when this is done we want to build the configuration the cache the cache is so it's loading much faster and then we will be sure everything is running smooth so i will just call them great and see what going on inside and now it's saying we cannot we cannot connect to the database and that could be something because uh something with the data so i'm just going for the maria to be i will stop it and then remove it darker volume we have to this one volume remove remove it and talk about compose up db and then i'll be sure that everything is running first time as it should be if you get the same issue you can do the same as i'm done here and everything here should be running smooth so let's close this down stopping the database and say run in the background and then i should be enabled to be great if i'm not having an error and i probably have an error in my database now and that's the last thing we need to figure out what's going on here i think it's because we need to create the database so i need to see about my variable about the configuration for the database it's correct so just a second going up here and decompose database here and then i want to go inside here and that's the same route and that's about to see if i'm connecting with my own database here [Music] just see localhost 123456 i'm opening up we have it here but we don't have a database for love so let's create the lava database and uh i'll just see what you have here just even danish you can put on what you want and let's see about we can connect for the database now and now we can do it so it's only because the database is not exist so be sure the database exists when you do this and now you can see all the data we have here here we go and everything is running smooth so i can just click this down now we are ready to see about the website is working and remember we need to access the right url again so in the docker compose we have 8100 so that's the ip address we want to go for and see what happening we don't have any loading up so something is going wrong so let's see about what's going on now i have figure out what's happening and i discovered because we have the four w's and not only three so it took me a little time to investigate what happening because i'm so blind but that's what it is so let's go back and remove the web server go into the terminal and spin it up again and let's go in for the browser and reload and here we go now you are up and running with the level and your project is ready to be developed i really hope you enjoyed this video and i'm sorry about the mistakes i've done over the time but that's how it's working and you're now ready to to code the php framework level and i'm really happy to have you here today i really hope you want to subscribe and i really hope you press on the like and share button remember the code will be on the github profile and the link will be in the description of course and don't forget when you subscribe the thing is below on the video and you just click on it thank you so much and i hope to see you next time bye you
Info
Channel: Paris Nakita Kejser
Views: 23,326
Rating: undefined out of 5
Keywords: docker tutorial, docker container, container, docker container tutorial, docker networking, networking, deployment, devops, dev ops, tutorials, docker compose, docker compose tutorial, containers, docker, nginx docker container, php-fpm docker container, laravel docker, php docker, docker laravel nginx mysql, docker laravel, docker laravel windows 10, docker laravel windows, docker laravel development environment, docker tutorial for beginners
Id: 2exXt7XLPBQ
Channel Id: undefined
Length: 36min 13sec (2173 seconds)
Published: Sat Oct 17 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.