Thanks for leaving those errors in the video, it's the biggest struggle I have with docker is finding solutions to little errors like that.
@alivenumber5 Жыл бұрын
I'm blown away. This is great stuff. The "aha!" moment for me was when the php container image didn't have the proper mysql data access functions and you just changed the image to one that had that installed and ready to go already. This changes deployment completely.
@musickmannАй бұрын
Watching the troubleshooting process is so helpful, thanks for the extra effort!
@alphamadioubah6169 Жыл бұрын
Very good pace, good tone and a true step-by-step guide
@pikadroo Жыл бұрын
My friend. I want to thank you with all my heart for making this video. I am not sure if I will be using docker but you presented the best argument for using it then any video I have tried to watch. I appreciate you! Keep up the great content!
@Aryan21able2 жыл бұрын
Best thing is, he never cut the video, if there is a bug the he shows it. This is what we mostly face in real life
@vincentstevenson22002 жыл бұрын
I really appreciate your thoroughness on this tutorial. You are a great teacher Adam!
@MarcMcRae Жыл бұрын
Brilliant! Video paints a thousand words to actually see the real life process flow. VERY very cool docker stuff & thanks for sharing.
@codeadamca Жыл бұрын
Thanks!!
@patafrom Жыл бұрын
First , many thanks for this great work. it helped me A LOT ! my contirnution to all who are stuck with some connecticty issues from php to the mysql db. I used to use the IP adress (of the host ) in my php code to join the db. as many of you it was not working. Now i switch the servername in my php code from ip to docker alias. this alias is known from the apache part as all containers are in the same network. now it works and goodbye mysqli_connect errors !
@zedolok4508 Жыл бұрын
this help me a lot understand each thing inside of docker compose, thank u very much, now i can create my own docker compose for my projects :)
@adryelgainza16862 жыл бұрын
Hey man im getting into cybersecurity and so im trying to learn how to create web applications so i have a further understanding of how to break them and your content man has been a blessing. This is a great in depth video and you provide awesome explanations. Def gonna recommend you to anyone who asks how i learned to create LAMP stacks.
@codeadamca2 жыл бұрын
Great! Thanks!
@sparkdogy2k2 жыл бұрын
awesome video man! really helped me with my first time with docker :)
@codeadamca2 жыл бұрын
Glad I could help!
@lalaland16702 жыл бұрын
Thank you so much for the video. Really helped me get started with Docker.
@thanasister Жыл бұрын
Some notes: 1. This is for the v1 of docker Compose (EOL June 2023). The commands are slightly different in v2. Also the `docker-compose.yml` is suggested to be named `compose.yaml` 2. You can set a simple volume in mysql instead of entry point stuff, to persist the db data. The volume will store all the db data in a location outside the container.
@jeffrowe60049 ай бұрын
Thanks, that's probably why my mailcow didn't work as well. Guess it's time for a newer video
@pw5687 Жыл бұрын
This was a big help, thanks!
@viewerck4 ай бұрын
thanks, so patient and clear!
@alexsilkin52222 жыл бұрын
Great video and instructions! Thank you for making this.
@codeadamca2 жыл бұрын
You are so welcome!
@marcoseduardosantoshenke51842 ай бұрын
excelent video man, help me a lot!
@shizo_n01z32 жыл бұрын
Great video, very nice to follow
@StewartCambridge-iu5sw2 ай бұрын
Would have been nice to see you do the Dockerfile version of the fix, even though you had an image ready to go :)
@saidbakr2 жыл бұрын
Wonderful, it is the first time I got an idea about how could I transfer or migrate my code and data from an host to another and running the docker with all configs by just one command.
@codeadamca2 жыл бұрын
Great! Docker is awesome!
@al8xandros3 ай бұрын
Hi, thx for the video, in the part you specify ports, is there any syntax that would let me redirect an incoming connection to a specific container based on the domain the user has used ? Similar to Apache's domain based virtual hosts but instead of having apache using a specific /html path depending on the domain used, Docker would redirect the user to the right container instead.
@olegfare4625 Жыл бұрын
amazing explanation!
@b4rt1j12 жыл бұрын
After watching like 15 tutorials how to run lamp stack using docker, this is the first time i get it, very simply explained thank you so much! One little question, if I want to use composer - should i run it in container? I thought its the matter of local system, but composer images on docker hub dissapointed me. Have a great day!
@codeadamca2 жыл бұрын
As long as you are running composer on a connected volume, Docker should sync the files.
@b4rt1j12 жыл бұрын
@@codeadamca Sorry for my annoying questions, I still can't get composer woking, I have composer in my windows PATH so I can initialize it locally, but what if I want composer to be installed with all dependecies that my project needs (based on composer.json) when someone pulls my project from GitHub repository, i think vendor folder should'nt be commited to github due to its size. I would appreciate your advice sir, have a great day!
@Sorna-vp5jz2 күн бұрын
I have a question. How did phpmyadmin was able to connect to mysql even before you setup the network between them? Could you please clarify if possible?
@isaacambi191410 ай бұрын
Great content.
@twodogsandstuff Жыл бұрын
Excellent tutorial. I have been playing around with docker and wondered what it would take to have self-hosted environment through there as opposed to mamp pro. so this was helpful to see the initial setup. But I am confused about dumping the db, when you mention restarting the service it db would disappear (thus needing to dump the db). Is that correct for in unexpected scenarios such as a power outage? Once everything boots back up all content not in the dumped database would be gone?
@emveeoh Жыл бұрын
Hello Adam! Thank you for this tutorial. I used your Github repo, ran it without any edits and I get this error (as others have reported): Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/index.php:3 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 3 Apparently, the php image ( image: php:8.1.1-apache) from Dockerhub does not have mysqli enabled for PHP. Can you please advise us on the proper way to enable it?
@rabbit.it.slabikovsky Жыл бұрын
I had the same problem and I solved it this way: Firstly I created folder (in my case I named it "php_custom"), then inside it I made Dockerfile with following content: FROM php:8.1.1-apache RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli Next, in docker-compose.yml below "www" I added "build" prop with value linked to folder with Dockerfile, like this: www: depends_on: - db image: php:8.1.1-apache build: ./php_custom volumes: - "./:/var/www/html" ports: - 80:80 - 443:443 networks: - lamp-docker This should work with "--build" flag in "docker-compose up" command. The flag is needed only once unless you want to rebuild docker again
@queshafiq8952 Жыл бұрын
Hi Sir How about if the PHP file is a form and dynamically use to key in data into db.? Is data will be gone too after down the container? How to make data persistent?
@Olliewiener10 ай бұрын
Is there a way to do it in a single container instead of multiple pls and thanks
@WilliamKim Жыл бұрын
Thank you!
@ronaldjoytengco700011 ай бұрын
I had a sqlyog and mysql workbench how can i connect to the database using that software? Thank you
@Salamaleikum80 Жыл бұрын
How does docker populate the database with data? Where is that data saved? and why does docker miss the data if you don't define volume?😅
@davidlepold Жыл бұрын
I s there such a video with Nginx, fpm-php, sql ...?
@rajarajan88697 ай бұрын
How to php.ini file update in the local machine and how it is mount
@mkannanmsc2 жыл бұрын
You may also create a Tutorial with all the best practices for a LAMP stack production azure k8s cluster, including CI/CD pipe line from Docker..
@codeadamca2 жыл бұрын
I don't even know what half those terms mean!! :)
@mkannanmsc2 жыл бұрын
Very Good Adam.👍 Wondering as per best practices, we won't allow empty passwords to connect mysql
@codeadamca2 жыл бұрын
Yes, good advice!
@addohm Жыл бұрын
Why would you architect anlamp server with your db inside of yhe container rather than outside - with this method you're using writing start data back into the db every restart? It seems like simply storing the actual db file outside the docker container would be better.
@alloesibanda2 жыл бұрын
Thank you for the video and excellent teaching but I am having a problem trying to retain the new records in the db. the new records don't show when I restart the containers. Do I have to export the dump.sql everytime I shut down ?
@codeadamca2 жыл бұрын
Each time you fire up the server, you will need to run the migrations script.
@mertcaldag75892 жыл бұрын
Hello, thank you for the video. After I changed image value of www to php:8.1.1-apache and execute docker-compose up, I get the same error "connection refused". Any recommendations?
@codeadamca2 жыл бұрын
I would need to see your docker-compose.yml to know for sure. You can view mine from here: github.com/codeadamca/php-docker Try using my file and see if that fixes it. If it does, look for the type in yours.
@dannymason39702 жыл бұрын
This really helped a lot, thanks Adam. I am very new to Docker (having always used XAMPP) for local PHP dev. The only issue I have is when trying to use .htaccess overwrites. Not sure if there is a way to set apache config to allow .htaccess using some env variable in the docker-compose file?
@codeadamca2 жыл бұрын
Here is a good link to adding custom configuration to your apache setup: www.cloudreach.com/en/technical-blog/containerize-this-how-to-use-php-apache-mysql-within-docker-containers/
@Happinessisalwaysthere Жыл бұрын
Not working the same way for me. still receiving the error: atal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/index.php:3 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 3
2 жыл бұрын
I tried connecting to the database in three different ways: new mysqli, mysqli_connect and new PDO, and all ways didn't work for me. It's very frustrating. 🤥🤥
@mertcaldag75892 жыл бұрын
Same for me.
@codeadamca2 жыл бұрын
A few others have had a similar issue. But I can't duplicate it.
@emreekmekcioglu3057 Жыл бұрын
I have also same problem and tried all of them everytime it throw an exception , could find drive for pdo or mysqli. Did anyone find a soluyion?
@krstech1269 Жыл бұрын
thank you...
@sams16692 жыл бұрын
I tried to migrate my existing Laravel application that used xamp to docker. How do I run the migrations that I had in my application to the new lam_docker db ? if that makes sense ?
@sams16692 жыл бұрын
When I run 'php artisan migrate' , in the terminal, I get this error: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: nodename nor servname provided, or not known (SQL: select * from information_schema.tables where table_schema = lamp_docker and table_name = migrations and table_type = 'BASE TABLE')
@codeadamca2 жыл бұрын
It's a hard one to debug when I can't see it. But it sounds like the PHP server is not able to connect to the MySQ server. In this video we use separate servers for PHP, MySQ
@berndseifert69662 жыл бұрын
Thank you for this video. I had the same problem the mysqli_connect error disappeared not. My solution is a combination between your video and the video of arthur man Part 8
@berndseifert69662 жыл бұрын
If somebody is interested in my Docker File please write. 😉
@zygmacode2 жыл бұрын
@@berndseifert6966 Hello, I'm trying to solve it, I like the base of this tutorial, but I can't find the error, could you show me your docker-compose?
@codeadamca2 жыл бұрын
Thanks for adding this! Can you add a link to this video? I think others have had the same issue.
@cellarer60112 жыл бұрын
Hello, when creating the database i'm getting an error saying no privileges!
@codeadamca2 жыл бұрын
I would have to see your docker-compose.yml to know for sure. But I would guess you need to make sure your mysql:latest image (named db) is referenced from your phpmyadmin/phpmyadmin image properly (depends_on: - db and - PMA_HOST=db). If you want, a copy of my files are available here: github.com/codeadamca/php-docker
@ashique120092 жыл бұрын
From my side still mysqli_connect is undefined where my image is this: image: php:8.1.1-apache
@SacrumImperiumRomanum517 Жыл бұрын
same
@codeadamca Жыл бұрын
You may have to enable php_mysqli. Check out this StackOverflow question: stackoverflow.com/questions/46879196/mysqli-not-found-dockerized-php
@b4rt1j12 жыл бұрын
Sir, would you please help me, phpmyadmin throwing connection refused every time i provide username and password
@codeadamca2 жыл бұрын
Make sure you are using the service name from your docker-compose.yml file as the host in your PHP MySQL connection. In my example, the host should be "db". And make sure the username, password, and database name in your PHP MySQL connection are the same as your MySQL environment variables defined in the docker-compose.yml file. In my example they are lamp_demo, password, and lamp_demo. Hope that helps!
@codeadamca2 жыл бұрын
Also make sure the environment variables in the MySQL portion of the docker-compose.yml match the PHPMyAdmin environment variables, also in the docker-compose.yml file. You could also try using some different ports in case your computer is already using one of the specified ports.
@b4rt1j12 жыл бұрын
Finally checked some other video and it magically worked, now I'm wondering how to configure apache so the server goes to the public folder where is the entry point index.php I've tried using volumes for that, but failed because when making PROJECT_ROOT constant - my project name is replaced by var/www/html Would you have any suggestions sir?
@codeadamca2 жыл бұрын
I believe I found the same question on Stack Overflow, maybe this will help: stackoverflow.com/questions/51393494/how-to-change-the-document-root-in-php7-1-apache-from-docker-compose-yml
@b4rt1j12 жыл бұрын
@@codeadamca Thanks!!
@drastically_bad2 жыл бұрын
it's getting to my nerves plz help me out with this error
@codeadamca2 жыл бұрын
What is the error you are receiving?
@drastically_bad2 жыл бұрын
@@codeadamca Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/index.php:3 Stack trace: #0 {main} thrown in /var/www/html/index.php on line
@drastically_bad2 жыл бұрын
@@codeadamca i am running the same application from your git hub account it giving me error
@c3cris2 Жыл бұрын
Amazing video, but 720p in 2022? Squinted the whole video to read the text.
@CyJobes8 ай бұрын
Shouldn't it be setup so you don't have to dump from MySQL, but rather it does it by default. Sure would suck to shutdown and lose all the data. I'm told that doing it the way you are means it is not setup correctly, and you could lose valuable data because of it.
@nothingtoseehere57602 жыл бұрын
This is a very long video.
@codeadamca2 жыл бұрын
Sorry... It is right from scratch! :)
@snorky45062 жыл бұрын
Excellent, just excellent! I kept getting this error at localhost:80 even after changing the php image: Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/index.php:3 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 3 I'm running it on ubuntu 20.04, and after a whole lotta googling, changing to this image instead fixed my problem: thecodingmachine/php:8.1.1-v4-apache
@codeadamca2 жыл бұрын
There are many different way to connect to a database and execute a query. You can use a series of mysql functions (mostly deprecated), mysqli functions (i stands for improved), or PDO. Here is a good page describing the difference and the syntax for each: www.w3schools.com/php/php_mysql_connect.asp
@danielunyu2 жыл бұрын
Good job!! Thanks
2 жыл бұрын
@@codeadamca I tried connecting in three different ways: new mysqli, mysqli_connect and new PDO, and all ways didn't work for me.
@marcoverheul2 жыл бұрын
I finally got it working thanks to another tutorial. In the root of the project, add file "php.Dockerfile" with this content: FROM php:8.1.10-apache RUN docker-php-ext-install mysqli pdo pdo_mysql In docker-compose.yml replace "image: php:8.1.10-apache" with build: dockerfile: php.Dockerfile context: . This install mysqli when running the container.
@ZamriRosliGooglePlus2 жыл бұрын
thanks bro, it works! got the same error as above back then.
@stinkybuttonmasher2 жыл бұрын
Thank you! Helped me a ton :)
@YCode_ Жыл бұрын
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/index.php:3 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 3 ?
@nickhomboy-ks3it Жыл бұрын
Check out my fix I just posted above.
@samuelosoba2 жыл бұрын
Finding it hard getting my version of docker after installation. I use the docker version and docker info, I only see the 19.xx.xx and 20.xx.xx, nothing related to 2, or 3 or 4 anywhere, Any ideas the command you used to obtain the version: 3 you used in the video.? Thanks in anticipation.
@codeadamca2 жыл бұрын
The version in the docker-compose.yml is the schema version, not the version of the Docker program. You should be safe using version 3. It's kind of comparable to using VSCode and PHP. VSCode is at version 1.69.1. But I'm using it to write PHP 8. The are unrelated. For more info check out: docs.docker.com/get-started/08_using_compose/
@samuelosoba2 жыл бұрын
@@codeadamca Sorry, I'm using Ubuntu, VSCode and I'm trying to setup php with LAMP.
@samuelosoba2 жыл бұрын
@@codeadamca oh I get it. Thanks
@inteliconn995 Жыл бұрын
Adam please - $connect = mysqli_connect - in 2023?
@codeadamca Жыл бұрын
I tend to use the mysqli series of functions when teaching PHP as they are easier for new programmers to grasp.