Create a Symfony 5 project with Docker PHP MySQL Nginx and Node - Part1 (2021)

  Рет қаралды 38,885

Gary Clarke

Gary Clarke

Күн бұрын

ℹ In this video I show you how to create a Symfony 5 project with Docker PHP, MySQL, Nginx, and Node using Docker and Docker Compose. This is the first of two parts in which I will create separate containers for Nginx, PHP, MySQL8, and Node. I'll connect the containers using a Docker Compose network so that everything just works in perfect harmony.
💻Link to the repo on github:
github.com/Gar...
🆓 Join garyclarke.tech for course DISCOUNTS and a FREE Docker + PHP course (worth $49)
www.garyclarke...
👇Follow me on Social Media:
Twitter: / garyclarketech
Linkedin: / garyclarketech
💕Show support:
www.paypal.com...

Пікірлер: 91
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
If you encounter any breaks with webpack encore when using node v15, try changing docker-compose.yaml to specify node:14
@almerinobuce7878
@almerinobuce7878 2 жыл бұрын
I was looking for something like this for a while, here i found everything. Great tutorial.
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Awesome, thank you!
@jahoopyjaheepu497
@jahoopyjaheepu497 3 жыл бұрын
Thank you for making this video. I've watched many hours of Docker tutorials this week after learning the basics, and this has been the only tutorial where things were explained very clearly. The bit about how to set up an nginx config file was invaluable.
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Hey Jahoopy that's great. I'm glad I was able to help 🤝
@jahoopyjaheepu497
@jahoopyjaheepu497 3 жыл бұрын
@@GaryClarkeTech Thank you! I do have one question though (if you don't mind taking a moment to answer). I'm fairly new to Docker, and I'm having an issue using the setup in this video where every other PHP page in the public folder returns a 404, except the index page. For example, localhost:8080/example.php returns a 404. I changed some things in the nginx config file to possibly remedy this (like the part at the bottom that forces a 404 on everything but index.php), but that just makes me download my script when I go to that script's page. Do you know why this is still happening, and how to fix it?
@jahoopyjaheepu497
@jahoopyjaheepu497 3 жыл бұрын
Actually, I solved this by doing some trial and error with my config script. Stack Overflow helped a lot too, but ultimately I just had to put the things from the location index.php brackets into a new "location" that looks like this: location ~ \.php$ (I suppose this is for any file/page that ends in .php).
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
@@jahoopyjaheepu497 Glad you figured it out!
@nordicnoirmusic
@nordicnoirmusic 2 жыл бұрын
Thanks for the effort, Gary. I was able to get it running in no time!
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Great news..nice work!
@goncalosardinha5020
@goncalosardinha5020 4 жыл бұрын
Great explanation with a very relaxed and easy to understand vibe! Thank you and keep the excelent work.
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
Thanks Gonçalo...appreciate it!
@dirkkuijer8440
@dirkkuijer8440 10 ай бұрын
Great teachter is mister Clarke!
@lexerquine3008
@lexerquine3008 2 жыл бұрын
thank you so much for this guide, few guides work right away and are modifiable for other projects. you have nailed it. keep up the great work my friend.
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Awesome, thank you!
@lexerquine3008
@lexerquine3008 2 жыл бұрын
@@GaryClarkeTech no my friend thank you!
@phoenlx_3
@phoenlx_3 2 жыл бұрын
This should help me! I've been trying to do this on my own for all day (except the node part, but I'll keep it on mind, it'll maybe be useful for a future project) switching between apache and nginx, both resulting in the same error : fcgi returning error. Gonna try ur solution tomorrow, I hope it works this time! Your tutorial is really good anyway, you explain well with a very comprehensive English for a French student like me. Thanks a lot for that!
@phoenlx_3
@phoenlx_3 2 жыл бұрын
Update : it worked ! thank you so much for this vid. I just had to make a few changes, like choosing a more recent version of php and edit the Dockerfile for the php container (the mv instruction is returning an error since now it's not /root/.symfony/(...) but /root/.symfony5/(...)
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
@@phoenlx_3 Hey that's awesome..so glad it worked! This video is over 2 years old now so I am currently working on a new PHP + Docker tutorial which will use PHP MySQL Nginx and Redis and I'm also gonna show how to push the app to production on AWS. You'll really like it.
@shurbioto1034
@shurbioto1034 2 жыл бұрын
Thsnk you very much, you are my hero. I was traying to init a symfony app with docker and i was having a lot of problem to serve the statics files. Thansk to you I have succeeded :))))))
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Glad I could help...I'll probably release an updated Symfony + Docker video in the next few months
@PrincessSarahjayne11
@PrincessSarahjayne11 3 жыл бұрын
Great video - it worked first time for me so I was super happy .... I hate configurating things, but this made it easy. Thank you for saving me a headache :)
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Glad to save you a headache 🤯
@d.k.353
@d.k.353 4 жыл бұрын
Hey Gary, this is a great tutorial, thanks for that!
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
Thanks buddy, I appreciate that. There'll be more to come so be sure to subscribe!
@domasdragunas2954
@domasdragunas2954 2 жыл бұрын
Could not be better. Thank you so much
@Zoddxyz
@Zoddxyz 4 жыл бұрын
Thank you very much for your video. Very easy to understand the base concept!
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
You're welcome, David..and thank you!
@flashbangstudio9102
@flashbangstudio9102 4 жыл бұрын
Exactly what i need to set up ! i'm excited, Thanks you so much.
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
You're welcome, friend. Glad I could help!
@michaelbrauner
@michaelbrauner 2 жыл бұрын
Hello Gary. Is there any reason for you not to use the unix socket for connecting php-fpm and nginx?
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Only that I don't know a lot about it 😂 It's not my area of expertise. But I'm gonna do more Docker in about 3 months so I'll upskill before then. Feel free to share any links on the subject!
@muzika5001
@muzika5001 2 жыл бұрын
Amazing tutorial! Thank you very much!
@arjan127
@arjan127 2 жыл бұрын
This is such a good video, thanks!
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Glad it helped!
@adm-frg
@adm-frg 2 жыл бұрын
Thanks for this awesome tutorial !
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
My pleasure!
@katerynaiaroshenko4057
@katerynaiaroshenko4057 3 жыл бұрын
Thank you so much!!! Everything works at once! 🥰
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Amazing! The video is nearly a year old now, so I'm glad to hear everything still works!
@waltermg117
@waltermg117 3 жыл бұрын
very clear, thanks man!
@tomatomov9061
@tomatomov9061 2 жыл бұрын
Why do we need node for symfony ?
@RdozeTV
@RdozeTV 2 жыл бұрын
What if you need to change something does it take effect immediately or its like you need to restart the docker again
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
You won't need to restart for things that are volume-mounted like your src code. For some other things you may have to
@yongzhang2983
@yongzhang2983 3 жыл бұрын
Thank you for sharing, it is a great video. What if I have multiple sites under Nginx, and want to keep each host conf in separate file?
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Thank you, you're welcome. You mean multiple sites on one nginx service? I've always stuck to one site per service.
@therealwalim
@therealwalim 2 жыл бұрын
Hello, thanks for the tutorial but I have some questions, my app is verly slow (loading on browser taking long time and also running commands on CLI) does the fact that Im using volumes that slows everything ? (Im using docker desktop on windows)
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
php + docker can be slow on windows but I hear that the latest version of Docker is much quicker.
@VinodPal16
@VinodPal16 2 жыл бұрын
Hi Sir, I am getting error "502 Bad Gateway / nginx/1.22.0" can you help me on this please?
@valentindobrica9584
@valentindobrica9584 3 жыл бұрын
Hi brother, my node container doesn't run at all, the rest are fine. thanks for tutorial
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
It could possibly be a compatibility issue with a later version of node than the one used in the video.
@MohammadArifRahim
@MohammadArifRahim 3 жыл бұрын
Hi Gary, thanks, it is a great tutorial. I learned a lot. However, I ran into problem with php installation. While trying to figure out what went wrong, I realized, you were installing the docker on macOS so your dependencies are different then mine. I am using docker on windows 10 with WSL2 is "Debian10" for my port. So the requirements must be different. I did not however follow the recommended Debian way of installing PHP. I did trial and error. Here is what I did.... FROM php:7.4-fpm RUN apt-get update && apt-get install -y zlib1g-dev git libicu-dev zip libzip-dev zip \ && docker-php-ext-install intl opcache pdo pdo_mysql \ && pecl install apcu \ && docker-php-ext-enable apcu \ && docker-php-ext-install zip
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Thanks Mohammad. I hope you managed to get it to work for you.
@MohammadArifRahim
@MohammadArifRahim 3 жыл бұрын
@@GaryClarkeTech it seems lot of it has changed after your tutorial. Windows, WSL selection, Symphony everywhere there are lot of update. Maybe you can do a new tutorial on windows, to catch all the changes. However, do a Symphony tutorial. From basic to advance. I like your style. Thank you.
@BelkinJr
@BelkinJr 4 жыл бұрын
just letting you know, on windows if I establish nginx volume conf like this "- ./nginx/default.conf:/etc/nginx/conf.d/default.conf" then it complains that I'm trying to mount a directory onto a file, this is the solution stackoverflow.com/questions/59018610/docker-error-cannot-start-service-nginx-oci-runtime-create-failed
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
Thanks for the heads up Belkin..appreciated. I'll check it out.
@BelkinJr
@BelkinJr 4 жыл бұрын
@@GaryClarkeTech Or better yet map it like this "- ./nginx/conf.d:/etc/nginx/conf.d" because otherwise it makes a separate config folder and doesn't use default.conf that you provide. At least that's how I made it work, I'm open to suggestions :)
@d_sportello
@d_sportello 3 жыл бұрын
Thank you for great explanation! I've done it all, but the localhost page didn;t show me that echo from index. It says that "Welcome to nginx! Nginx installed and working, but needs to be configured". Do you have any ideas where I could've made a mistake? One thing if it's matters: I've typed php80 sign everywhere, not php74
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
I'm not sure...it could be a number of things. The best solution will be to pull my files from github and try those first. Then figure out what the difference is between them and yours.
@d_sportello
@d_sportello 3 жыл бұрын
​@@GaryClarkeTech I tried it, now I'm getting "File not found" on that localhost page. Maybe I need to add the path in nano /etc/hosts? but it seems like localhost is already there. Anyway, thanks for the reply and advice Gary!
@derzskyi1
@derzskyi1 4 жыл бұрын
What is the meaning of node container?
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
It's just a container which is built using a node image. the name node-container is a custom name which I gave to it...it's not essential. The main reason that I included it in the project was for frontend asset compilation...which you can learn all about in part 2. Enjoy!
@derzskyi1
@derzskyi1 4 жыл бұрын
@@GaryClarkeTech thanks for the quick response!
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
@@derzskyi1 Welcome buddy
@v.kondratjevs
@v.kondratjevs 3 жыл бұрын
Nice!
@jeromepatron7909
@jeromepatron7909 3 жыл бұрын
Hy Gary, great tutorial. However, I meet an error when I run the first docker-compose command: [...]:~/project$ docker-compose up -d --build Creating network "project_nginx-php74-mysql8-node" with the default driver Building php74-service [+] Building 7.7s (3/3) FINISHED => [internal] load build definition from Dockerfile 0.9s => => transferring dockerfile: 596B 0.0s => [internal] load .dockerignore 1.2s => => transferring context: 2B 0.0s => ERROR [internal] load metadata for docker.io/library/php:7.4-fpm Do you have any idea where this might come from? Thanks a lot.
@ahmedhelal174
@ahmedhelal174 2 жыл бұрын
Thank you
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
You're welcome
@catalinmanea2151
@catalinmanea2151 3 жыл бұрын
Thanks bro!
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
You're welcome!
@catalinmanea2151
@catalinmanea2151 3 жыл бұрын
​@@GaryClarkeTech Short and clear info
@hellamaxine
@hellamaxine 4 жыл бұрын
My nginx container immediately exits?
@hellamaxine
@hellamaxine 4 жыл бұрын
never mind, i missed a semicolon when setting the fastcgi_pass . also, mounting those logs is useful, they helped me debug this
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
Definitely...server config is never straight forward for me! I'm glad you got it working.
@urbanofilho74
@urbanofilho74 3 жыл бұрын
show!, fantastical
@abdulmobeen2477
@abdulmobeen2477 4 жыл бұрын
Hi Gary, I am getting this "File not found." on localhost:8080/ , can you please help me.
@GaryClarkeTech
@GaryClarkeTech 4 жыл бұрын
Hey Abdul...I wanna help you but can you give me a bit more info? e.g. At what point is it happening? What steps have you taken to fix it so far? What results did you get from your debugging?
@abdulmobeen2477
@abdulmobeen2477 4 жыл бұрын
@@GaryClarkeTech I didn't create the app folder that's working now, but now if I have a sub dir inside /app like /app/mydir/abc.html, I can't view that file from localhost:8080/app/mydir/abc.html, and nginx show the same file i.e index.php like you showed in the tutorial.
@yanndeo9501
@yanndeo9501 4 жыл бұрын
hi abdul , how do you solve his. i have a same error
@abdulmobeen2477
@abdulmobeen2477 4 жыл бұрын
@@yanndeo9501 you need to create app folder then create the index files inside that so that server can serve it.
@yanndeo9501
@yanndeo9501 4 жыл бұрын
@@abdulmobeen2477 yes i have a app folder like this : app/public/index.php ; i'am getting file not found and node-container not run
@0xgeorgegoldman
@0xgeorgegoldman 2 жыл бұрын
Not working for me... 🥵
@MrKenano99
@MrKenano99 3 жыл бұрын
thanks a lot that was easy and great. But I had problem when run mysql it kept restarting with error message : " [ERROR] [Entrypoint]: MYSQL_USER="root", MYSQL PASSWORD cannot be used for the root user Use one of the following to control the root user password: - MYSQL_ROOT_PASSWORD - MYSQL_ALLOW_EMPTY_PASSWORD - MYSQL_RANDOM_ROOT_PASSWORD " But when I commented MYSQL_USER: root and MYSQL_PASSWORD: secret it worked. I did not understand why but it works lol
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
MYSQL_ALLOW_EMPTY_PASSWORD is quite a common setting in dev so you could use that Not knowing why something works is scarier than not knowing why it doesn't 😂
@MrKenano99
@MrKenano99 3 жыл бұрын
Lol! I don't like the say: if it's works don't touch it also. Thanks again 😊
@Kolarian666
@Kolarian666 2 жыл бұрын
+
Inside the V3 Nazi Super Gun
19:52
Blue Paw Print
Рет қаралды 3 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Docker and PHP Complete Tutorial
2:00:04
Gary Clarke
Рет қаралды 42 М.
Why is Laravel NOT used in Big Development Projects?
11:53
Stefan Mischook
Рет қаралды 185 М.
18 Weird and Wonderful ways I use Docker
26:18
NetworkChuck
Рет қаралды 506 М.
Top 8 Docker Best Practices for using Docker in Production
18:27
TechWorld with Nana
Рет қаралды 317 М.
Docker Crash Course for Absolute Beginners [NEW]
1:07:39
TechWorld with Nana
Рет қаралды 2 МЛН
PHP Docker Tutorial - Nginx - PHPFPM VS Apache - Full PHP 8 Tutorial
14:39
Symfony Messenger plus RabbitMQ
11:32
Gary Clarke
Рет қаралды 17 М.
Build a Full Stack Web App in PHP and MySQL with Docker from scratch!
26:09
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН