Many times I've tried and failed to understand what docker is. Now I have a basic but solid idea of what it is thanks to a PHP guide. Wasn't expecting that but thank you very much ^^
Once you use docker (and get over the first headaches) you will never want go back to thing like XAMPP, docker, and specially docker-compose, are great for local development, even more for people who use Linux, in which docker runs at lightspeed. Thanks for the tutorial, great video, keep it up.
wow, It's been a while. I stopped watching you cause there were no more PHP videos. Tnx I will finish again today. Will wait for another 8-10 videos to watch. Thank you for this amazing course. I want to let you know that I got the job that I was telling you about. It's a PHP/Laravel Job. I have learnt so much from you about PHP. Thank you. I will be grateful forever :)
@@ProgramWithGio I have been able to solved it. i didnt type the codes well. Thank you very much. I am enjoy this course by the time i get to video 70 i will be able write a complete program. you are blessing me
I love how you explained Docker and its configuration. I've been trying to understand it for months but your content made me unify everything I read before and even get a project up and running within docker. I'm a seasoned PHP dev and I'm enjoying re-learning from your course coz its making me understand 'newer' concepts and expanding my thinking. Thanks Gio!
Thanks for the video, Gio! I had to take a lengthy Docker course before proceeding but I now see the utility of containerization, it's really cool. The only thing I still can't wrap my head around is data transfer between the server and PHP-FPM. So you've got 2 separate containers running, one with the PHP-FPM installed and the other with the server that doesn't automatically pass requests to .php files over to any interpreter. These containers essentially share one interface though, which is the src directory on the Docker host. Still I don't get the mechanics of this all. Suppose you initiate an HTTP request on your Docker host (via browser) and the destination is the loopback address with the 8000 port attached to it. The OS on the Docker host parses the request and since 8000 is the port one of our containers listens on, that container gets that request. This container is running Nginx and it sees that it's a request to a .php file. Okay, what next? In the config file it says "fastcgi_pass app:9000" so I understand that this is the part responsible for forwarding the request to the PHP interpreter. However, what does "app" stand for? Through deduction I conclude that's the reference to the container (service) running PHP-FPM but the name of that service is actually "programwith-gio" as indicated in the .yml file. So I'm confused. TL;DR: how does PHP-FPM communicate with Nginx when they're running in separate containers?
Glad you took the additional course for the Docker, it does come in handy. So the 'app' is not the container name but the service name, if you check the docker-compose programwithgio-app is the container name but the service name right under services is app.
@ProgramWithGio thank you, I'm almost finished with your truly awesome series, and I've also recommended it to my dev friends. Now I decided to backtrack some crucial things in your code that I still am not quite comfortable with in terms of understanding, however. Right now it's some of Nginx config blocks. I'd be grateful if you could point out the flaws in my logic here. So here goes. If you use an arbitrary endpoint to make a request to the app, e.g. localhost:8000/foo it's going to be handled by the second location block first. The request URI is /foo, and I assume that's what should be in the $query_string variable. However, the variable is empty as I checked it by sending a header with its contents back as a response via the add_header directive inside the second location block. So how does the request URI persist through to the point of being processed by index.php?
Even after 2 years of publishing the course, I managed to ask my questions and get my problems solved via twitter and discord. I mean it is not sth u get with ANY FREE COURSE out there. I just want to say Im rly grateful...
I know everyone already told you how good of a teacher you are. BUT i gonna say it again , YOU ARE A GREAT TEACHER , glad i found you. Thanks for theentire playlist.
PHP needs courses like this! PHP is the king of bad learning videos and low quality infos, and I don't know actually why. So many awful code practices everywhere, so many anti-patterns (with globals, without composer, without namespaces, with mixing buisness logic with presentation layer, with only one file functions.php "for everything", etc.). This is not my first language and I see that these code practices are really bad and smelling, but many-many newbies may find it helpful... Gio, really thank you for such quality course. Only suggestions - please, give us more practical exercises. Keep up your awesome work!
Just found you, and man i can say your way of teaching makes it very easy to follow whats going on. Thank you, I'll be following your tutorial and subscribed.
My advice would be to leave your folder structure in git for others to copy cause writing by hand can lead to typos :D I don't understand all of the things in your docker files but i think that is normal, cause I only used XAMPP and I didn't need to write anything there. Last question would be why are we writing /var/www directories in a lot of places?
My reply was removed by RUclips. Not sure if you had the chance to see it. /var/www contains your source code in docker container but if you don't mount the volume it will just be empty. So we map the local source directory to the /var/www. Not understanding everything is perfectly normal, you'll learn along the way. If you like Docker I would suggest watching some docker tutorial and then a lot of things will make sense. You can DM me on twitter in case my reply gets deleted again if you have follow up questions. Idk what's up with RUclips deleting my replies ☹️
Yess. Ahh thats headache.. Starts from installing docker on ubuntu and continues with attempts to force it work, changing configurations that was in the video, sending energy in space and stuff like this. But now it works somehow! Almost understand how exactly. Thanks for work.
Thank you, great lessons. I have a suggestion: In new videos. If you please, make the File/ Settings/ Appearance & Behavior/ Appearance: use custom font size: 16, so the menus look a bit clearer. Also, Editor/ Color Scheme/ Cobalt, has a clearer contrast than Darcula when presenting code to others. Thank you again, and please keep on.
Thank you and yes I agree. I'm going to increase the font, in later videos I started zooming in on important parts but increasing font should help. Will test the cobalt theme 👍
Like everyone else I'm also enjoying this series. I just had a couple of questions about the docker setup: (1) Why is the bind mount ("- ../src:/var/www") required for both the app and nginx services? Shouldn't it only be necessary for the app service? (2) Why is there a ".d" at the end of the nginx config path in the docker-compose.yml file? I've tried everything and it works great; I just don't understand how it works.
Thank you. That is correct, I just prefer to have it in both cases in case you only work with docker-compose.yml and abstract away the Dockerfile somewhere else. Just a habit I guess
Great. I need to watch it again so I can set docker up. I downloaded docker composer before but I don't know what went wrong. For one I didn't even know how to integrate with the any server and then I was also installing wsl2 and the whole thing made my computer so slow that I had to remove them all and technically re-install my OS. But from what you showed, it seems easy if I follow what you demonstrated (I hope).
Sir, can you teach me how to download and setup docker compose and nginx the right way. i am a begginer and have been struggling with this for 3 days, i looked at many tutorials but they did not help.
Hi Gio, you are a great teacher! In this video however I want to give my constructive mentions. While for most this kind of product information seems to be normal and just informative, my brain plays games with me in such "close-to-advertisement" features. I recognize that you prefer these products and you not only mention the benefits and features in you really fantastic way but give me and many others a clear idea of what we can expect from these. Thats great and please don't change this attitude! But would you mind to include some sort of advanced environment recommendation in general? However that might be because I am not a professional programmer but for me environment means feeling comfortable with a (one) solution. That has not to be all-in-one but a one(solution/combination)-for-all(long) time. I don't want to switch there and there and lose time to feel comfortable with the one and the other setting if you know what I mean. Of course and you tell this often in this video it depends on what you are working on. In my Idea a perfect environment would be to have the possibility to: - develop in the same way as I test (same IDE, same functionalities) - test with exactly same conditions as they run in production - ideally have at least one production setting on my own responsibility with the possibility to adjust this to fit to comparable production settings and to enable Closed Beta Testing. As I like to have the final app to have two different versions "test" and "production". I would like to have this "test" at least to have the same opportunities as full production and full development. Wouldn't it make sense then to have the development environment be the same as the production environment? And if so, why should I always use Environment for my development where everyone's clear this is for development, not for production? What would you recommend to me? Especially if I prefer to use free/open source products?
Thank you. Docker is the best way to achieve what you described. I just covered the basics for it since this course is not about docker but if you want to learn more you could watch some advanced Docker courses.
Awesome course so far. Sorry if you already mentioned but I can't find it. Do you have the source code posted somewhere? I find it specially useful to copypaste the configuration files and avoid typos.
Gio, I need your help. when i type docker-compose up in the terminal I get, "no configuration file provided: not found" I don't know what to do, I have tried everything I searched on Google except changing to linux. What should I do?
The latest and recommended version of the Compose file format is defined by the updated Compose Specification Those who might use this video, use “Docker compose up” And name your file “compose.yml” over "docker-compose.yml" even though backwards compatibility is kept And don’t pass a version header this is the updated way at time of writing
Sir, can you teach me how to download and setup docker compose and nginx the right way. i am a begginer and have been struggling with this for 3 days, i looked at many tutorials but they did not help.
I'm done. My docker is up and running with all the other hassles inbtwn. Local Host is running now. Thanks a lot Gio. But if I close my text editor after the container is up will it still run? And if it doesn't still run how do I get it up again?
That's great, good job. When you close the editor it doesn't stop containers. You need to run docker-compose down, if you want to start containers again just run docker-compose up -d
Hello Thank you for the great course. I've been learning for a month or so, but I could not get the docker working. Every parameter is working fine but when I reach localhost:8000 it doesnt work. Can you help me plz? ofc I have modified some addresses in your files including ../src/
Hello. For me to be able to help I need to see the code and some screenshots. Reach out to me on Twitter and send me your Dockerfile, docker-compose and screenshot of your code structure
HI there Gio. I have attempted to get nginx up and running with docker. But it's not worked for me somehow. It could just be a typo. Is there any chance of zipping up the docker directory and posting it to git hub. Many many many thanks for your great teaching.
You can just share your code repository that includes the Dockerfile & docker-compose as well as nginx configuration. Any specific errors you are facing? Try checking logs using docker logs command for nginx container
Hello and thanks for this tutorial. I am just learning Nginx. Do you have a video where laravel is used with docker and apache? Can you pls point me to it?
Thanks a lot sir. I have a question, where can we find the php.ini file or the services that we installed via docker-compose.yml file like server directory etc?
It's usually under: /usr/local/etc/php/conf.d directory within the container. You can create a custom php.ini within your docker folder where your docker-compose.yml is for example and then modify docker-compose.yml and add the following line: - ./local.ini:/usr/local/etc/php/conf.d/local.ini under the volumes section right under where you map the source directory to the /var/www Rebuild the containers and it should use your custom ini. Note that your custom ini does not have to be a full PHP.ini it can just contain the changes you want to make.
most likely a configuration issue. I would need to see your code & configuration to be able to assist. You can DM me on Twitter (X) your github repo link@@DavidKwadwoArthur
That was amazing , thanks. can't wait for the other videos. May I ask you to cover things like if we set .ini php config file for this docker container , how can we do that ? And also I would like to ask, is it possible to automatically get https certificates for these nginx php docker files for production, and the last question would be is it posdible to use docker for having multiple domains on the same nginx and php server ? If you cover any of these topics , I would appreciate it.
Thank you. I'll try to squeeze another lesson on these topics. Though it will probably be in third section of the course or towards the end of second section. I personally wouldn't have two sites on same nginx container, it's simpler to just have second site with different containers on different port, so one site on port 8000, another on port 8001 and so on.
@@ProgramWithGio that is indeed right. Honestly the last question was maybe just for my specific case. I have a saas service which is more like a shop maker. That users can set domains for their shops. So I've been thinking about solutions that can automate this process of having many domains on the same project.
@@peymanGhaderkurehpaz Got it, yea that makes sense. There are some services out there that let you do that and probably have API that you can integrate with to automate it.
I feel like installing extensions in official php images is a lot of pain. Had to install php-redis, imagick, mysql pdo and their dependencies from like 5 different places. What's the advantage of official images, comparing to apt-ing out all the stuff in a bare linux image?
@@ProgramWithGio Thank you for the answer. My main goal is to build a local dev environment quickly, and won't ship containers to production or testing yet, so that's not too bad. I think the configuration thing depends, the official image doesn't maintain extensions in one place or with one tool, and has permission issues sometime (too much security), both which I hardly encounter with an apt install
Hi Gio, first of all thank you for sharing knowledge in such a shining way! Can you please tell me (or redirect to other resources for me to understand) how to let nginx know what we usually tell to Apache through .htaccess in order to route any request to index.php? Thank you in advance for any explanation/suggestion and keep up the excellent job!
Hey, thank you. Check 10:06 time on this video. It's set to /var/www/public, so you place your index.php within /var/www/public & all requests go through there.
Hello, Teacher Geo, I hope you can help me. “I have Windows 7 and I cannot install Windows 10-11 because my device is weak. I downloaded and installed dockertoolbox and downloaded the container images nginx, alpine, php, redis, but when I do the docker-compose up command in vcod, an error appears even though I wrote The file docker-compose.yml & nginx.conf & dockerfile correctly, so I decided to move to larvel homestead. What do you think of it? Will I be able to create an online store with it and transfer it to Hostinger hosting without problems? If you have another suggestion, let me know.”
That is, when I upload the site to hosting, there will be no errors and it will work well. I plan to build an online store with Larvel and React. It will not crash and will work well if I built it with Laragon.
Not sure if Laragon is meant for production, its just a local development environment. For production you can use something like Digital Ocean & if you need help provisioning, you can use Laravel Forge.
I would like to use docker. But on windows it works too slow. I've got problems with installation already. It downloads very slow. So thank you for advicing laragon
Hi Gio How are you? Hope you are well. Just a question, I'm new in docker. I install docker desktop, pull php and nginx image in my docker desktop, download your source code Open it VS code and run docker-compose up. it says no configuration file provided: not found, please help me?
@@mdsirazul9231 how did it work with you? i did all of that and got into the docker directory and ran the command docker-compose up and i'm getting this error: failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory any help from you guys would be appreciated
Hello first of all, thank you for all this courses. My question is about the docker, with xamp you show how to configure but with docker I try since 2 days but I am so lost.
@@ProgramWithGio after 5:42 minutes I cannot follow because I dont know how did you put the docker and src on the code editor. What condiguration you do on the doxker logiciel?
@@veyspixelboy there are two ways you can do it. One is have your source code on your computer C drive or whatever drive, doesn't matter, and open it in editor that way. Another way is to put your source code to WSL distribution and you should be able to open that from editor as well. Having source files in WSL is better because it is faster due to less disk IO. You can try the other way first. Also I would recommend watching docker for beginners tutorial if you want to use Docker. If it's too much then I would just stick with XAMPP or Laragon, it doesn't matter what you use locally, use whatever makes you productive. Docker is not a requirement, I am just showing it as an alternative because we already covered XAMPP.
Would be cool to know how to use cdn with apache, everywhere I look for this there's "that's a topic for another video" but pretty much every server I work with have apache not nginx.
Whenever I say "that's topic for another video", I actually cover it in another video. I can't fit everything into one video, otherwise it would be a giant video. We used Apache in the beginning of the series & since this series is all about learning PHP "the right way" it was important to cover some alternatives to apache, so I decided to cover nginx in second section. We are going to work on a final project at the end of the series & deploy it. I plan on setting up CDN as well there and that's probably where I'll talk about CDN.
Hi, these days I am trying to configure Xdebug inside the php composer. I'm following several tutorials but none of these are exhaustive and above all working ... Do you intend to dedicate a video on Xdebug? (in my case I use vscode as ide)
Laragon is Better than XAMPP , WAMP or any other Server. You can also switch versions easily..Its most upgradable as you can always update PHP, SQL or Apache Version in Laragon. Whats your suggestion on that @GioDev
Laragon is certainly better than XAMPP. I personally prefer docker because I work on multiple projects at the same time & also like to have projects separated by their dependencies in separate containers. If I were not using docker I would be using Laragon for sure.
@@rxxt-sh1vj this video isn't about Laravel though 🙂. But using query builder will be faster than eloquent, though this depends on your query and how complex it is. Sometimes this speed gain with query builder is negligible. I haven't had any issues with eloquent in terms of performance, only few cases where I had to use query builder. So it depends on your case.
@@ProgramWithGio I am developing my own ORM...so wanted to know the difference..:D I will be using Joins using my custom query builder..My orm can insert 10,000 records in 1.2 seconds and 1000 records in 0.17ms in mysql database
Hi Gio, I''ve tripple checked the code and it seems to be the same as yours. Running docker-compose up in terminal was a success and now when I go to localhost:8000 I get a 404 not found /nginx message which is good I guess because I got the containers running but I can't execute anything from index.php. Any idea what might be the problem? (Just localhost doesn't work at all unless XAMP is on which makes sense to me..:D) I get this in my terminal everytime I try to connect: | 172.18.0.1 - - [10/Jan/2022:17:30:57 +0000] "GET / HTTP/1.1" 404 556 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gec ko) Chrome/97.0.4692.71 Safari/537.36"
SOLVED VIA TWITTER: My Index.php was located in the SRC folder only. I did not have it in the PUBLIC folder and the nginx config points to the PUBLIC folder.
I hope I can finish you php tutorial at some point and then your hopefully finished laravel tutorial. Atm I do a lot of python, data science / AI stuff, I just can't find the time :'(
Good video... thanks for your work. have you looked at the dddev project on this topic? For local projects I love ddev because it is Docker based and comes with some nice options and great features. This project is made for php developers like us…maybe another interesting idea for a short video?
I did not quite understand why there are two seperate containers for the application and for the apache daemon. If i understand the .yml file correctly, the whole project will be mounted into the nginx container and the nginx deamon will process all the requests. And also the whole project will be mounted in the app container. Since the nginx container will not access files from the nginx container, I don't understand whats the purpose of the app container in the first place. Thanks in advance ! :)
@@ProgramWithGio yes I meant hotreload, smashing F5 is not elegant :D btw your response time is awesome. A rough workaround could be adding header("Refresh:1"), so the page refreshes itself. Can be problematic at some point I guess.
@@drgregoryhouse1470 Vite has that built in I think for front-end, so you could give it a try. Yea adding refresh every second isn't that good, will become annoying very fast 😁
Hi, can you explain how to run code from GitHub and connect everything to Docker in Windows? I tried docker-compose up in terminal, but all I get is error "no configuration file found". I'm thinking that maybe workdir isn't correct, but I don't know to what I need to change it to work. Thanks in advance!
Wow so far i only played with Xamp, when i run on this tutorial i feel like i receive a Rock on my Face.. hahaha impossible to graps that in 15min hahahha... will go over tutorial and tutorial later about it since docker is not essential to keep going in the course i hope lol ;)
was my comment deleted? with me comes an error and was after I enter docker-compose up comes the error ERROR: The Compose file '.\docker-compose.yml' is invalid because: 'nginx' does not match any of the regexes: '^x-'
I had this problem too - make sure the nginx.conf root and docker-compose volumes use the same location, they should both be /var/www. The nginx.conf was incorrectly set to var/www/public
You will need to create php.ini in docker directory for example & copy it over from either Dockerfile or docker-compose. Google "custom php.ini docker-compose"
It was such a story... I was using Windows 8.1 while going through the first section of the course until now. But Docker require Windows 10 (now i know why). I tried to get it upgrading Window 8.1 to Windows 10, but it not worked out because of some error i dunno how to handle. So i got Windows 10 and install it to another disk section of my notebook. Than i installed Docker and it asked me to go through some Microsoft instraction first. While he needed only part of that instruction to be completed, i didn't know this those time, so i passed through all instruction and get fully upgraded Ubuntu 22.04, ha-ha-ha.
@@ProgramWithGio it's alright! I have more of that story but youtube delete it, i don't know why. Finally i get it to the lesson, made all the stuff and met the error. Checked everything, didn't find anything wrong, so i created REPOSITORY account to put all the files and images into it and to show it to you. Doing this i found the error, so my Docker started working. However he did it wrong so i continued with REPOSITORY and found the error again. Now all is working as intended!
@@ProgramWithGio Amazing! RUclips bans name of the you know what repository! Epilogue: now i have Windows 10, WSL2, Linux, Docker, REPOSITORY, all relevant extensions for VS Code! Nothing can get me off my course - once i become great IT-specialist and leave Russia for good! Thx u master Gio! You not only teach us the php, you teach us much much more! Now i done with that comment =)))
HI, great tutorial. I followed it 99%. Only change it to pick alpine version. But I onnly can get nginx welcome page there's no way index.php can be reached by nginx...
@@ProgramWithGio Hi thank for your quick answer. my Dockerfile, nginx config & docker-compose file are same to your tutorial. I'm using an ubuntu distro that I had installed from Microsoft store, could it be that the reason? note: sure you'll find my "english" very bad, sorry in advance here some screenshot prnt.sc/14dtwgx prnt.sc/14dty8k
@@int21 where is your index.php located, since you are seeing nginx welcome page it means nginx is running, so issue most likely is with your source not being mapped to proper directory. Make sure you adjust the docker-compose file on the volume section to map to your source code. You can DM me on twitter and we can continue there to troubleshoot it. I'm sure it's just the confirmation issue. P.S. your English is good, don't worry 🙂
@@ProgramWithGio Hi my friend, my index.php is inside /src/public. I'm suspecting that nginx is reading default.conf file and not my nginx.conf file. about docker-compose file this is app volumens definition: - ../src:/var/www and nginx volumens definition: - ../src:/var/www - ./nginx/:/etc/nginx/config.d here screenshot of my folder structure prnt.sc/14dx4ei thanks for taking the time for this
@@int21 try removing the last slash from ./nginx/ and just leave as ./nginx, if still doesn't work try mapping file directly instead of folder. I'll try to reproduce your issue on my PC and see what the issue is. Make sure to run docker-compose up --build to rebuild image after making changes
Great tutorial, however after 15 hours trying to simply run apache with database through docker I've realized that docker is such pain in the a$$ encountering errors all the time.
Hi Gio how are you? just a question, is it necessary to have a dockerfile for each image before using docker compose? because i tried, i have a dockerfile for php, nginx and mysql, but the nginx container keeps restarting all the time, and now i saw that you didn't create the nginx dockerfile. Thanks in advance! and sorry if i hadn't smashed the like button on all your videos, they're like drugs and i don't even realize when i'm in a new one :( lol
Hey, I'm good, thank you. How are you? You need some sort of base image, you dont need to have separate Dockerfiles, can just use the existing images for MySQL for example. If you share your code I can help troubleshoot it. Put it up in GitHub and send me the link in Twitter as well as screenshot of the issue.
This is considered intermediate, Section 1 is basic, Section 2 OOP (intermediate), Section 3 Advanced. Docker is not a requirement, its just an alternative to XAMPP, feel free to keep using XAMPP or Laragon depending on what you are currently using. You can come back to Docker later.
I tried to replicate this but fail :(. My app has a button which call a bash script. I set "everything right", however when I click this button my container log says """"sh: 1: path/to/script.sh: not found"""" eventhough the path is correct... 😵. Do I have to set special permission to Nginx ?
@@ProgramWithGio it is a button on the frontend that call a php function to do some backend validation and then execute a script that do a "git clone" in order to bring an excel file from a repo on gitlab. However everything in the function called does well except executing the script. Thanks in advance!
HI! i am new and learning PHP from your chanel I have tried but couldn't run docker container properly i am using Windows 10 and installed docker successfully. and i can't understand the error also i have googled the error but couldn't solve it. The error is, nginx: [emerg] unknown "documnet_root" variable
Gio, you are an awesome teacher. This whole course is GOLD. Thank you.
Thank you so much 🙏
@Samir Ibrahim Couldn't say it better!🤙
@@ProgramWithGio hi! I use devilbox how to alternative xammp
Many times I've tried and failed to understand what docker is. Now I have a basic but solid idea of what it is thanks to a PHP guide. Wasn't expecting that but thank you very much ^^
That is super awesome, really happy to hear that
That 's a proper course.Every learning program should be like that.Learning the right syntaxe, the right architecture and the right way ;)
Thank you 💙
Once you use docker (and get over the first headaches) you will never want go back to thing like XAMPP, docker, and specially docker-compose, are great for local development, even more for people who use Linux, in which docker runs at lightspeed.
Thanks for the tutorial, great video, keep it up.
Thank you. I agree 💯. I haven't used anything else since I started using Docker.
wow, It's been a while. I stopped watching you cause there were no more PHP videos. Tnx I will finish again today. Will wait for another 8-10 videos to watch. Thank you for this amazing course. I want to let you know that I got the job that I was telling you about. It's a PHP/Laravel Job. I have learnt so much from you about PHP. Thank you. I will be grateful forever :)
That's amazing. Im happy to hear that my videos were & are helpful. Thank you 🙏
@@ProgramWithGio This is an error i get got when i did docker-compose up, kindly assist services.app.build must be a string
@@omegajunior8963 DM me on Twitter and I'll help you troubleshoot it. If you can share your Dockerfile & docker-compose that will be better
@@ProgramWithGio I have been able to solved it. i didnt type the codes well. Thank you very much. I am enjoy this course by the time i get to video 70 i will be able write a complete program. you are blessing me
I love how you explained Docker and its configuration. I've been trying to understand it for months but your content made me unify everything I read before and even get a project up and running within docker. I'm a seasoned PHP dev and I'm enjoying re-learning from your course coz its making me understand 'newer' concepts and expanding my thinking. Thanks Gio!
Super happy to hear this, thank you & good job
Many times I've tried and failed to understand what docker is. Now I have a basic but solid idea of what it is thanks to a PHP guide.
That's awesome, happy to hear
Thanks for the video, Gio! I had to take a lengthy Docker course before proceeding but I now see the utility of containerization, it's really cool.
The only thing I still can't wrap my head around is data transfer between the server and PHP-FPM. So you've got 2 separate containers running, one with the PHP-FPM installed and the other with the server that doesn't automatically pass requests to .php files over to any interpreter. These containers essentially share one interface though, which is the src directory on the Docker host. Still I don't get the mechanics of this all. Suppose you initiate an HTTP request on your Docker host (via browser) and the destination is the loopback address with the 8000 port attached to it. The OS on the Docker host parses the request and since 8000 is the port one of our containers listens on, that container gets that request. This container is running Nginx and it sees that it's a request to a .php file. Okay, what next? In the config file it says "fastcgi_pass app:9000" so I understand that this is the part responsible for forwarding the request to the PHP interpreter. However, what does "app" stand for? Through deduction I conclude that's the reference to the container (service) running PHP-FPM but the name of that service is actually "programwith-gio" as indicated in the .yml file. So I'm confused.
TL;DR: how does PHP-FPM communicate with Nginx when they're running in separate containers?
Glad you took the additional course for the Docker, it does come in handy. So the 'app' is not the container name but the service name, if you check the docker-compose programwithgio-app is the container name but the service name right under services is app.
@ProgramWithGio thank you, I'm almost finished with your truly awesome series, and I've also recommended it to my dev friends. Now I decided to backtrack some crucial things in your code that I still am not quite comfortable with in terms of understanding, however. Right now it's some of Nginx config blocks. I'd be grateful if you could point out the flaws in my logic here. So here goes.
If you use an arbitrary endpoint to make a request to the app, e.g. localhost:8000/foo it's going to be handled by the second location block first. The request URI is /foo, and I assume that's what should be in the $query_string variable. However, the variable is empty as I checked it by sending a header with its contents back as a response via the add_header directive inside the second location block. So how does the request URI persist through to the point of being processed by index.php?
Even after 2 years of publishing the course, I managed to ask my questions and get my problems solved via twitter and discord. I mean it is not sth u get with ANY FREE COURSE out there. I just want to say Im rly grateful...
You're welcome 💙
I know everyone already told you how good of a teacher you are. BUT i gonna say it again , YOU ARE A GREAT TEACHER , glad i found you. Thanks for theentire playlist.
Thank you very much
PHP needs courses like this!
PHP is the king of bad learning videos and low quality infos, and I don't know actually why. So many awful code practices everywhere, so many anti-patterns (with globals, without composer, without namespaces, with mixing buisness logic with presentation layer, with only one file functions.php "for everything", etc.). This is not my first language and I see that these code practices are really bad and smelling, but many-many newbies may find it helpful...
Gio, really thank you for such quality course. Only suggestions - please, give us more practical exercises.
Keep up your awesome work!
Thank you & thank you for the suggestion 🙌🙌
Just found you, and man i can say your way of teaching makes it very easy to follow whats going on. Thank you, I'll be following your tutorial and subscribed.
Thank you 🙏
شكرا لك جيو لقد كان الفصل الاول صعبا لكني سأواصل وسأقوم بأكمال جميع الفصول الى نهايتها انت الافضل
Thank you & good luck
Yay, I got Docker set up thanks to Mr. Gio!
Glad to hear that. You're welcome Miguel
Loved the way you showed the way to configure docker & php ... just clear the missing information
👍👍
really not a friend of php. Mostly writing in NodeJs. But this series is just amazing. Love it
Thank you
Awesome video as always, I wish all tutorials was this good.
Thank you 🙌
I like working with Docker as I use Windows. Thanks a lot!
Great to hear
OMG, u r the GOAT, so helpful, loving Docker now
Happy to hear that, thank you 💙
So useful videos with a friendly and one step up perspective! Thanks so much
Thank you, glad you like it 💙
Best course I've ever seen and learned from. Thank you for that GOLD
You're welcome and thank you 🙌
@ 12:31 "Now the cool thing about whatever we did" 🤣🤣 so general, I love it
🤣🤣
My advice would be to leave your folder structure in git for others to copy cause writing by hand can lead to typos :D I don't understand all of the things in your docker files but i think that is normal, cause I only used XAMPP and I didn't need to write anything there. Last question would be why are we writing /var/www directories in a lot of places?
My reply was removed by RUclips. Not sure if you had the chance to see it. /var/www contains your source code in docker container but if you don't mount the volume it will just be empty. So we map the local source directory to the /var/www. Not understanding everything is perfectly normal, you'll learn along the way. If you like Docker I would suggest watching some docker tutorial and then a lot of things will make sense. You can DM me on twitter in case my reply gets deleted again if you have follow up questions. Idk what's up with RUclips deleting my replies ☹️
Yess. Ahh thats headache.. Starts from installing docker on ubuntu and continues with attempts to force it work, changing configurations that was in the video, sending energy in space and stuff like this. But now it works somehow! Almost understand how exactly. Thanks for work.
Congrats on making it work
Thank you, great lessons.
I have a suggestion:
In new videos. If you please, make the File/ Settings/ Appearance & Behavior/ Appearance: use custom font size: 16, so the menus look a bit clearer. Also, Editor/ Color Scheme/ Cobalt, has a clearer contrast than Darcula when presenting code to others.
Thank you again, and please keep on.
Thank you and yes I agree. I'm going to increase the font, in later videos I started zooming in on important parts but increasing font should help. Will test the cobalt theme 👍
Like everyone else I'm also enjoying this series. I just had a couple of questions about the docker setup: (1) Why is the bind mount ("- ../src:/var/www") required for both the app and nginx services? Shouldn't it only be necessary for the app service? (2) Why is there a ".d" at the end of the nginx config path in the docker-compose.yml file? I've tried everything and it works great; I just don't understand how it works.
Thank you.
1. nginx might need access to the source as well to serve static assets etc
2. Its more like a convention
Liked before watching
Thank you 😏
Great tutorial, thank you so much.
The working_dir doesn't need to be redefined in docker-compose file for app container.
Thank you. That is correct, I just prefer to have it in both cases in case you only work with docker-compose.yml and abstract away the Dockerfile somewhere else. Just a habit I guess
Great tutorial! Gio be making me feel like a pro👍
You are a pro! Thank you 🙌
Great. I need to watch it again so I can set docker up. I downloaded docker composer before but I don't know what went wrong. For one I didn't even know how to integrate with the any server and then I was also installing wsl2 and the whole thing made my computer so slow that I had to remove them all and technically re-install my OS. But from what you showed, it seems easy if I follow what you demonstrated (I hope).
Fingers crossed, hopefully it works out this time 🤞
Really appreciate the course. This video in particular helped me a lot.
Thank you very much Gio!
Sir, can you teach me how to download and setup docker compose and nginx the right way. i am a begginer and have been struggling with this for 3 days, i looked at many tutorials but they did not help.
What problems are you having?
@@rafaelmsalescom i am trying to setup and download the dockerfile, docker-compose.yml and nginx but i cannot figure it out
your help would be so greatly appreciated, as i have been trying to solve this for days
@@abduabdu7404 Following the video steps didn't work?
Hi Gio, you are a great teacher!
In this video however I want to give my constructive mentions. While for most this kind of product information seems to be normal and just informative, my brain plays games with me in such "close-to-advertisement" features. I recognize that you prefer these products and you not only mention the benefits and features in you really fantastic way but give me and many others a clear idea of what we can expect from these. Thats great and please don't change this attitude! But would you mind to include some sort of advanced environment recommendation in general?
However that might be because I am not a professional programmer but for me environment means feeling comfortable with a (one) solution. That has not to be all-in-one but a one(solution/combination)-for-all(long) time. I don't want to switch there and there and lose time to feel comfortable with the one and the other setting if you know what I mean. Of course and you tell this often in this video it depends on what you are working on.
In my Idea a perfect environment would be to have the possibility to:
- develop in the same way as I test (same IDE, same functionalities)
- test with exactly same conditions as they run in production
- ideally have at least one production setting on my own responsibility with the possibility to adjust this to fit to comparable production settings and to enable Closed Beta Testing.
As I like to have the final app to have two different versions "test" and "production". I would like to have this "test" at least to have the same opportunities as full production and full development. Wouldn't it make sense then to have the development environment be the same as the production environment? And if so, why should I always use Environment for my development where everyone's clear this is for development, not for production?
What would you recommend to me? Especially if I prefer to use free/open source products?
Thank you. Docker is the best way to achieve what you described. I just covered the basics for it since this course is not about docker but if you want to learn more you could watch some advanced Docker courses.
@@ProgramWithGio Thanks!
Thanks for your good teaching.
This video was useful for me.
Happy to hear that, thank you 🙌
That pucture on 0:22 made my day))
😄😄
Awesome course so far. Sorry if you already mentioned but I can't find it. Do you have the source code posted somewhere? I find it specially useful to copypaste the configuration files and avoid typos.
Thank you. Check description of the video, link to the source should be there
Thanks a lot for the wonderful video!
I can see that I need to become good with Docker fast!
You're welcome. It's not that bad once you play around with it.
Gio, I need your help. when i type docker-compose up in the terminal I get, "no configuration file provided: not found" I don't know what to do, I have tried everything I searched on Google except changing to linux. What should I do?
cd into the directory that has the docker-compose.yml file and run the command from there
@@ProgramWithGio Thank you so much man ❤you're undoubtely the best php teacher I've seen
The latest and recommended version of the Compose file format is defined by the updated Compose Specification
Those who might use this video,
use “Docker compose up”
And name your file “compose.yml” over "docker-compose.yml" even though backwards compatibility is kept
And don’t pass a version header
this is the updated way at time of writing
Sir, can you teach me how to download and setup docker compose and nginx the right way. i am a begginer and have been struggling with this for 3 days, i looked at many tutorials but they did not help.
I'm done. My docker is up and running with all the other hassles inbtwn. Local Host is running now. Thanks a lot Gio. But if I close my text editor after the container is up will it still run? And if it doesn't still run how do I get it up again?
That's great, good job. When you close the editor it doesn't stop containers. You need to run docker-compose down, if you want to start containers again just run docker-compose up -d
When i run docker-compose up it gives me an error that says : no configuration file provided: not found
cd into the directory that has the docker-compose file & run it there
Hello
Thank you for the great course. I've been learning for a month or so, but I could not get the docker working. Every parameter is working fine but when I reach localhost:8000 it doesnt work. Can you help me plz? ofc I have modified some addresses in your files including ../src/
Hello. For me to be able to help I need to see the code and some screenshots. Reach out to me on Twitter and send me your Dockerfile, docker-compose and screenshot of your code structure
Great video, thanks! I was wondering why we connect the src folder to both containers?
One is for nginx & other is for php & php-fpm
HI there Gio. I have attempted to get nginx up and running with docker. But it's not worked for me somehow. It could just be a typo. Is there any chance of zipping up the docker directory and posting it to git hub. Many many many thanks for your great teaching.
You can just share your code repository that includes the Dockerfile & docker-compose as well as nginx configuration.
Any specific errors you are facing? Try checking logs using docker logs command for nginx container
Will do@@ProgramWithGio
best tutorial ever
Thank you 🙌
Hello and thanks for this tutorial. I am just learning Nginx. Do you have a video where laravel is used with docker and apache? Can you pls point me to it?
Hey, not really, I have a video about Laravel Sail but that does not include apache.
best php course
Thank you 🙌
great vid! what settings are needed for deploying php in production using docker/docker-compose?
Thank you. That is a topic that would need it's own video. I would not recommend using development settings in production.
Thanks a lot sir. I have a question, where can we find the php.ini file or the services that we installed via docker-compose.yml file like server directory etc?
It's usually under: /usr/local/etc/php/conf.d directory within the container. You can create a custom php.ini within your docker folder where your docker-compose.yml is for example and then modify docker-compose.yml and add the following line:
- ./local.ini:/usr/local/etc/php/conf.d/local.ini
under the volumes section right under where you map the source directory to the /var/www
Rebuild the containers and it should use your custom ini. Note that your custom ini does not have to be a full PHP.ini it can just contain the changes you want to make.
Laracon is great but I normally use Devilbox which comes with lots of images ready to use and a nice dashboard to manage your containers projects
Nice. I haven't used Devilbox, but it sounds cool. Looks like devilbox uses docker.
@@ProgramWithGio give it a try.
How did you get the files in the docker and the src directories? What command would you run?
Not sure what you mean, I have all my source files on WSL & then open the directory from the code editor.
@@ProgramWithGio I got it figured out. The only problem is when I run localhost:8000, I get 502. Bad Gateway. How do I fix this, please?
most likely a configuration issue. I would need to see your code & configuration to be able to assist. You can DM me on Twitter (X) your github repo link@@DavidKwadwoArthur
Sure. On it@@ProgramWithGio
That was amazing , thanks. can't wait for the other videos. May I ask you to cover things like if we set .ini php config file for this docker container , how can we do that ? And also I would like to ask, is it possible to automatically get https certificates for these nginx php docker files for production, and the last question would be is it posdible to use docker for having multiple domains on the same nginx and php server ? If you cover any of these topics , I would appreciate it.
Thank you. I'll try to squeeze another lesson on these topics. Though it will probably be in third section of the course or towards the end of second section. I personally wouldn't have two sites on same nginx container, it's simpler to just have second site with different containers on different port, so one site on port 8000, another on port 8001 and so on.
@@ProgramWithGio that is indeed right. Honestly the last question was maybe just for my specific case. I have a saas service which is more like a shop maker. That users can set domains for their shops. So I've been thinking about solutions that can automate this process of having many domains on the same project.
@@peymanGhaderkurehpaz Got it, yea that makes sense. There are some services out there that let you do that and probably have API that you can integrate with to automate it.
Thanks a lot , I will definitely look for it ❤👌
I feel like installing extensions in official php images is a lot of pain. Had to install php-redis, imagick, mysql pdo and their dependencies from like 5 different places. What's the advantage of official images, comparing to apt-ing out all the stuff in a bare linux image?
Main advantages are security, consistency & most of the stuff are pre-configured. Going manual means you may need to do the configuration.
@@ProgramWithGio Thank you for the answer. My main goal is to build a local dev environment quickly, and won't ship containers to production or testing yet, so that's not too bad. I think the configuration thing depends, the official image doesn't maintain extensions in one place or with one tool, and has permission issues sometime (too much security), both which I hardly encounter with an apt install
Hi Gio, first of all thank you for sharing knowledge in such a shining way!
Can you please tell me (or redirect to other resources for me to understand) how to let nginx know what we usually tell to Apache through .htaccess in order to route any request to index.php?
Thank you in advance for any explanation/suggestion and keep up the excellent job!
Hey, thank you. Check 10:06 time on this video. It's set to /var/www/public, so you place your index.php within /var/www/public & all requests go through there.
@@ProgramWithGio many thanks for your prompt reply! Sorry for having missed the point while watching the video, previously 👌🙏
@@pasqualealfano6652 no worries 👍
Hello, Teacher Geo, I hope you can help me. “I have Windows 7 and I cannot install Windows 10-11 because my device is weak. I downloaded and installed dockertoolbox and downloaded the container images nginx, alpine, php, redis, but when I do the docker-compose up command in vcod, an error appears even though I wrote The file docker-compose.yml & nginx.conf & dockerfile correctly, so I decided to move to larvel homestead. What do you think of it? Will I be able to create an online store with it and transfer it to Hostinger hosting without problems? If you have another suggestion, let me know.”
For local development it's fine, you can try Laragon as well
That is, when I upload the site to hosting, there will be no errors and it will work well. I plan to build an online store with Larvel and React. It will not crash and will work well if I built it with Laragon.
Not sure if Laragon is meant for production, its just a local development environment. For production you can use something like Digital Ocean & if you need help provisioning, you can use Laravel Forge.
ok, thank you
I would like to use docker. But on windows it works too slow. I've got problems with installation already. It downloads very slow. So thank you for advicing laragon
Yup, use whatever works best for your environment
Hi Gio How are you? Hope you are well. Just a question, I'm new in docker. I install docker desktop, pull php and nginx image in my docker desktop, download your source code Open it VS code and run docker-compose up. it says no configuration file provided: not found, please help me?
Hello. Where are you running docker compose up from? Cd into docker directory cause that's where the docker compose file is
@@ProgramWithGio Thank you so much Sir, you just save my day.
@@mdsirazul9231 how did it work with you? i did all of that and got into the docker directory and ran the command docker-compose up and i'm getting this error: failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory
any help from you guys would be appreciated
Hello first of all, thank you for all this courses.
My question is about the docker, with xamp you show how to configure but with docker I try since 2 days but I am so lost.
Hello. I also show how to configure with Docker. Any specific errors/issues you are having?
@@ProgramWithGio after 5:42 minutes I cannot follow because I dont know how did you put the docker and src on the code editor.
What condiguration you do on the doxker logiciel?
@@veyspixelboy there are two ways you can do it. One is have your source code on your computer C drive or whatever drive, doesn't matter, and open it in editor that way. Another way is to put your source code to WSL distribution and you should be able to open that from editor as well. Having source files in WSL is better because it is faster due to less disk IO. You can try the other way first.
Also I would recommend watching docker for beginners tutorial if you want to use Docker. If it's too much then I would just stick with XAMPP or Laragon, it doesn't matter what you use locally, use whatever makes you productive. Docker is not a requirement, I am just showing it as an alternative because we already covered XAMPP.
@@ProgramWithGio okei thank you so much, I wanted just follow like 100%, I am so happy of your work Thank you again
@@veyspixelboy no problem, good luck & thank you for following along 🙏💙
Thanks for the video man ✨
You're welcome
Would be cool to know how to use cdn with apache, everywhere I look for this there's "that's a topic for another video" but pretty much every server I work with have apache not nginx.
Whenever I say "that's topic for another video", I actually cover it in another video. I can't fit everything into one video, otherwise it would be a giant video. We used Apache in the beginning of the series & since this series is all about learning PHP "the right way" it was important to cover some alternatives to apache, so I decided to cover nginx in second section.
We are going to work on a final project at the end of the series & deploy it. I plan on setting up CDN as well there and that's probably where I'll talk about CDN.
Hi, these days I am trying to configure Xdebug inside the php composer. I'm following several tutorials but none of these are exhaustive and above all working ... Do you intend to dedicate a video on Xdebug? (in my case I use vscode as ide)
That's in my list, hopefully I'll be able to get to it. We'll see.
Laragon is Better than XAMPP , WAMP or any other Server. You can also switch versions easily..Its most upgradable as you can always update PHP, SQL or Apache Version in Laragon. Whats your suggestion on that @GioDev
Laragon is certainly better than XAMPP. I personally prefer docker because I work on multiple projects at the same time & also like to have projects separated by their dependencies in separate containers. If I were not using docker I would be using Laragon for sure.
@@ProgramWithGio :D
Bro I also wanna know what's the difference between using Laravel Relationship like hasMany....belongsTo etc versus using a raw SQL join statement.
@@rxxt-sh1vj this video isn't about Laravel though 🙂. But using query builder will be faster than eloquent, though this depends on your query and how complex it is. Sometimes this speed gain with query builder is negligible. I haven't had any issues with eloquent in terms of performance, only few cases where I had to use query builder. So it depends on your case.
@@ProgramWithGio I am developing my own ORM...so wanted to know the difference..:D I will be using Joins using my custom query builder..My orm can insert 10,000 records in 1.2 seconds and 1000 records in 0.17ms in mysql database
Great video Gio! Could you do a short one with xdebug capability inside the container some time please?
Thank you. I have xdebug video planned, hopefully I'll get to it soon
Thanks for the video
You're welcome
great lesson!
Thank you 💙
Hi Gio, can you recommend a good docker course for beginners? (short and synthesized like yours)
Hello. Techworld with Nana is a good channel. She has a 3hr course on Docker I believe.
Hi, Jio. I'm using Xampp. Is there any need for using Docker to complete this series?
You can keep using XAMPP if that's what you are comfortable with
Hi Gio, I''ve tripple checked the code and it seems to be the same as yours. Running docker-compose up in terminal was a success and now when I go to localhost:8000 I get a 404 not found /nginx message which is good I guess because I got the containers running but I can't execute anything from index.php.
Any idea what might be the problem?
(Just localhost doesn't work at all unless XAMP is on which makes sense to me..:D)
I get this in my terminal everytime I try to connect:
| 172.18.0.1 - - [10/Jan/2022:17:30:57 +0000] "GET / HTTP/1.1" 404 556 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gec
ko) Chrome/97.0.4692.71 Safari/537.36"
Can you share the nginx.conf & docker-compose as well as Docker file screenshots? You can send them on Twitter if you want and I can take a look.
@@ProgramWithGio Sent!
SOLVED VIA TWITTER: My Index.php was located in the SRC folder only. I did not have it in the PUBLIC folder and the nginx config points to the PUBLIC folder.
@@Sasha-li2bn Same issue, add a public folder. src/public/index.php 🌸
wow ty aloot Gio u are t best ,i hope u make a video nginx enable https with dockerfile and php
Thank you
Thank you for your job!
I hope I can finish you php tutorial at some point and then your hopefully finished laravel tutorial.
Atm I do a lot of python, data science / AI stuff, I just can't find the time :'(
Take your time 💙
Good video... thanks for your work. have you looked at the dddev project on this topic? For local projects I love ddev because it is Docker based and comes with some nice options and great features. This project is made for php developers like us…maybe another interesting idea for a short video?
Thank you. No, I have not looked at ddev project, thanks for the suggestion
I did not quite understand why there are two seperate containers for the application and for the apache daemon. If i understand the .yml file correctly, the whole project will be mounted into the nginx container and the nginx deamon will process all the requests. And also the whole project will be mounted in the app container. Since the nginx container will not access files from the nginx container, I don't understand whats the purpose of the app container in the first place.
Thanks in advance ! :)
Don't forget about fpm, nginx is just webserver
really good course!!
Thank you 💙
When developing in docker, how do you autoreload your browser on filechanges ?
You mean hot reload? I have not set that up with Docker, so I'm not sure to be honest.
@@ProgramWithGio yes I meant hotreload, smashing F5 is not elegant :D
btw your response time is awesome.
A rough workaround could be adding header("Refresh:1"), so the page refreshes itself. Can be problematic at some point I guess.
@@drgregoryhouse1470 Vite has that built in I think for front-end, so you could give it a try. Yea adding refresh every second isn't that good, will become annoying very fast 😁
In traditional way if your nginx config file have error you must uninstall it sometime will raise error.But in docker you can delete it easily.
Thanks for the tip
Hi, can you explain how to run code from GitHub and connect everything to Docker in Windows? I tried docker-compose up in terminal, but all I get is error "no configuration file found".
I'm thinking that maybe workdir isn't correct, but I don't know to what I need to change it to work.
Thanks in advance!
You need to execute docker-compose command where the docker-compose.yml is in. So cd in that directory and the run docker compose command
@@ProgramWithGio Thank you! That was really helpful, now I can proceed following this amazing tutorial.
Wow so far i only played with Xamp, when i run on this tutorial i feel like i receive a Rock on my Face.. hahaha impossible to graps that in 15min hahahha... will go over tutorial and tutorial later about it since docker is not essential to keep going in the course i hope lol ;)
That's understandable and it's ok. Docker is not a requirement, keep using XAMPP or whatever makes your more productive 🙌
was my comment deleted?
with me comes an error and was after I enter docker-compose up comes the error
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
'nginx' does not match any of the regexes: '^x-'
RUclips sometimes removes comments if it thinks it's a spam. Looks like an error in docker-compose. Compare it to my file and see the difference.
What are the technologies needed to build microservice with php
That is a broad question :). Depends on the application & goals/needs
Sir, I have a problem, Docker is running fine but unable to access localhost:8000, please advice.
Check docker logs and confirm both nginx & fpm container are running
I had this problem too - make sure the nginx.conf root and docker-compose volumes use the same location, they should both be /var/www. The nginx.conf was incorrectly set to var/www/public
why nginx service not have a build context like app services?
Not sure
0:27... "And that's how docker was born" 😂
😁😁
Can I use php in-built server on php-fpm in docker without using Nginx as server?
I'm not sure to be honest, I have not used php's built-in server.
any idea how to increate the memory limit of this ?. because I cannot find the php.ini in your tutorial...how to set that in docker?
You will need to create php.ini in docker directory for example & copy it over from either Dockerfile or docker-compose. Google "custom php.ini docker-compose"
It was such a story... I was using Windows 8.1 while going through the first section of the course until now. But Docker require Windows 10 (now i know why). I tried to get it upgrading Window 8.1 to Windows 10, but it not worked out because of some error i dunno how to handle. So i got Windows 10 and install it to another disk section of my notebook. Than i installed Docker and it asked me to go through some Microsoft instraction first. While he needed only part of that instruction to be completed, i didn't know this those time, so i passed through all instruction and get fully upgraded Ubuntu 22.04, ha-ha-ha.
Wow what a journey heh. Sorry you had to go through all that, hope it's all good now 🙏
@@ProgramWithGio it's alright! I have more of that story but youtube delete it, i don't know why.
Finally i get it to the lesson, made all the stuff and met the error. Checked everything, didn't find anything wrong, so i created REPOSITORY account to put all the files and images into it and to show it to you. Doing this i found the error, so my Docker started working. However he did it wrong so i continued with REPOSITORY and found the error again. Now all is working as intended!
@@ProgramWithGio Amazing! RUclips bans name of the you know what repository!
Epilogue: now i have Windows 10, WSL2, Linux, Docker, REPOSITORY, all relevant extensions for VS Code! Nothing can get me off my course - once i become great IT-specialist and leave Russia for good!
Thx u master Gio! You not only teach us the php, you teach us much much more!
Now i done with that comment =)))
@@ZeppGoesPro RUclips sometimes removes comments, probably thought it was a "spam" or something. Glad it's all working now, awesome job 👍
@@ProgramWithGio he bans Git*** name 😂
I've downloaded github repo, but not working... 502 bad gateway error... can you help me?
Sure, ping me on Twitter and I can help troubleshoot the issue
I often hear about vanilla javascript, vanilla php, vanilla linux. what does the term vanilla mean ??
Means without frameworks/libraries, vanilla PHP is just plain PHP
Should we always redirect all requests to index file
Its up to you, though its good practice to have a single entry to the application.
HI, great tutorial. I followed it 99%. Only change it to pick alpine version. But I onnly can get nginx welcome page there's no way index.php can be reached by nginx...
Thank you. Can you share your Dockerfile, nginx config & docker-compose? I can take a look and help you. Did you set document root correctly?
@@ProgramWithGio Hi thank for your quick answer. my Dockerfile, nginx config & docker-compose file are same to your tutorial. I'm using an ubuntu distro that I had installed from Microsoft store, could it be that the reason?
note: sure you'll find my "english" very bad, sorry in advance
here some screenshot
prnt.sc/14dtwgx
prnt.sc/14dty8k
@@int21 where is your index.php located, since you are seeing nginx welcome page it means nginx is running, so issue most likely is with your source not being mapped to proper directory. Make sure you adjust the docker-compose file on the volume section to map to your source code. You can DM me on twitter and we can continue there to troubleshoot it. I'm sure it's just the confirmation issue.
P.S. your English is good, don't worry 🙂
@@ProgramWithGio Hi my friend, my index.php is inside /src/public. I'm suspecting that nginx is reading default.conf file and not my nginx.conf file.
about docker-compose file
this is app volumens definition:
- ../src:/var/www
and nginx volumens definition:
- ../src:/var/www
- ./nginx/:/etc/nginx/config.d
here screenshot of my folder structure
prnt.sc/14dx4ei
thanks for taking the time for this
@@int21 try removing the last slash from ./nginx/ and just leave as ./nginx, if still doesn't work try mapping file directly instead of folder. I'll try to reproduce your issue on my PC and see what the issue is. Make sure to run docker-compose up --build to rebuild image after making changes
Sir, can we follow the course on XAMPP, by not using Docker ?
Yes, you should be able to
Great tutorial, however after 15 hours trying to simply run apache with database through docker I've realized that docker is such pain in the a$$ encountering errors all the time.
I know Docker can be a pain, especially on windows
How can i create a docker image with Microsoft sql server, with exensions enabled php8, nginx? some one help please.
Through a command & some configuration most likely. Do research in google on "install microsoft sql server in docker" & try few options
I have tried several commands on Google but non works . I thought you could share a working command
Hi Gio how are you? just a question, is it necessary to have a dockerfile for each image before using docker compose? because i tried, i have a dockerfile for php, nginx and mysql, but the nginx container keeps restarting all the time, and now i saw that you didn't create the nginx dockerfile. Thanks in advance! and sorry if i hadn't smashed the like button on all your videos, they're like drugs and i don't even realize when i'm in a new one :( lol
Hey, I'm good, thank you. How are you?
You need some sort of base image, you dont need to have separate Dockerfiles, can just use the existing images for MySQL for example.
If you share your code I can help troubleshoot it. Put it up in GitHub and send me the link in Twitter as well as screenshot of the issue.
Awesome can you show one how to in stall Laravel with docker without sail
Maybe 😏
¡Gracias!
You're welcome 👍
Sir how can we install php nginx with docker in windows 10 as you did in Linux?
Use wsl, I'm using windows in the video with wsl2
@@ProgramWithGio ok sir.
Is this episode considered advanced level ? I do not understand most of it , Should I watch it more than one?
This is considered intermediate, Section 1 is basic, Section 2 OOP (intermediate), Section 3 Advanced. Docker is not a requirement, its just an alternative to XAMPP, feel free to keep using XAMPP or Laragon depending on what you are currently using. You can come back to Docker later.
@@ProgramWithGio got it 😁
What if i want to use apache2 as my web server how should i edit my docker file can someone help? hew to using docker, thanks!
It should be pretty similar to the way I did it in this video. Google docker with PHP & apache and you will find many articles.
I tried to replicate this but fail :(. My app has a button which call a bash script. I set "everything right", however when I click this button my container log says """"sh: 1: path/to/script.sh: not found"""" eventhough the path is correct... 😵. Do I have to set special permission to Nginx ?
Not sure I understand what you mean by a button. Why do you need a button in your app to run a bash script? Is your docker set up properly?
@@ProgramWithGio it is a button on the frontend that call a php function to do some backend validation and then execute a script that do a "git clone" in order to bring an excel file from a repo on gitlab. However everything in the function called does well except executing the script. Thanks in advance!
It's hard to know what the problem is without looking at the code. It doesn't sound like a docker issue.
HI! i am new and learning PHP from your chanel I have tried but couldn't run docker container properly i am using Windows 10 and installed docker successfully. and i can't understand the error also i have googled the error but couldn't solve it. The error is, nginx: [emerg] unknown "documnet_root" variable
Hey, looks like it might be an issue with your nginx configuration. Can you share your nginx config file?
@@ProgramWithGio
#nginx.conf file
#---------------
server {
listen 80;
index index.php;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
error_page 404 /index.php;
root /var/www/public;
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $documnet_root$fastcgi_script_name;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}
#docker-compose.yml file:
#------------------------
version: '3.8'
services:
app:
build:
context: ./
dockerfile: Dockerfile
container_name: docker-app
restart: always
working_dir: /var/www
volumes:
- ../src:/var/www
nginx:
image: nginx:alpine
container_name: docker-nginx
restart: always
ports:
- "8080:80"
links:
- app
volumes:
- ../src:/var/www
- ./nginx:/etc/nginx/conf.d
#Dockerfile
#----------
FROM php:8.0.3-fpm
MAINTAINER Saimor
RUN apt-get update && apt-get install -y \
git \
curl \
zip \
unzip
WORKDIR /var/www