Easy Local WordPress Setup in 5 Minutes with Docker!
ฝัง
- เผยแพร่เมื่อ 5 ก.ค. 2024
- Are you sick of working with complicated WordPress setups? In this video, I'm going to show you an easy way to set up a local WordPress development environment using Docker.
Whether you're a beginner or an experienced WordPress developer, this video is definitely for you! By the end of the video, you'll be able to set up a local WordPress development environment in 5 minutes, without any headache!
Grab the Gist! gist.github.com/erikyuzwa/741...
🔗 Grab My Other Available Product(s):
- Build Your First Web Service API Using Java Spring Boot wazoowebbytes.gumroad.com/l/x...
👋🏻Connect with me:
Twitter: / eyuzwa
🔗References:
- Docker Desktop Client - www.docker.com/
- XAMPP - www.apachefriends.org/
- WordPress Download - wordpress.org/download/
===---=== Chapters ===---===
00:00 - Introduction
02:04 - Install Docker Desktop
02:20 - Create docker-compose.yml
06:01 - Create .env variables
14:56 - WordPress Install
17:01 - Checking out PHPMyAdmin
19:00 - Optimizing Docker for just wp-content
#wordpress #docker #tutorial - วิทยาศาสตร์และเทคโนโลยี
If you're experiencing issues with Docker or connecting TO Docker, I would recommend make sure you're using Docker Desktop v4.26.1 - that seems to be the most stable version on my machine compared to v4.28+
Your presentation is concised, clear and so useful for beginner like I am. Thank you very much. Would like to encourage you to continue doing. Thank you very very very much from Bangkok, Thailand. 👍
Best tutorial on wordpress, everything worked right out of the box.
awesome thank you so much! Glad it helped you out
Perfect tutorial for the beginners who wants to install wordpress with docker. Thanks
thank you so much! So happy it helped!
An absolute gem of a tutorial for setting up WP + Docker. Thank you :)
thank you so much for saying so. I appreciate it, and happy that it helped!
Great vid man! Many thanks. Stay blessed.
thanks you so much! the same blessings for you!
Great job, many thanks!
thank you so much! I hope it helped!
Great stuff. Thx for sharing!
thanks so much! I appreciate it a lot
Awesome. 5 Stars! *****
really good tutorial, for beginners like me :D
thank you! happy it helped!
it seems like you have just started this channel, I encourage you to keep up the great work, thank you, this was useful
thank you so much for the encouraging feedback!
This is very usefull and nicely explained. Thank you very much. (From Sri Lanka)
thank you so much - I appreciate the feedback and happy it helped!
Great tutorial wordpress with docker.
Thank you
thank you so much! I'm glad it helped!
Thank you very much!!! now i can start to learn wordpress!
awesome! Happy to try and help!
great tutorial, very helpful
thanks so much! I appreciate the feedback!
I have a question, I want to to set the WP_ENVIRONMENT_TYPE with " define( 'WP_ENVIRONMENT_TYPE', 'staging' ); " but can't get it to work. I am adding it to my dockerfile as
WORDPRESS_CONFIG_EXTRA: define('WP_ENVIRONMENT_TYPE','staging');
then deleting all the files in the folder and the docker objects but it does not seem to pick it up.@@wazoowebbytes
Thank you man.
no thank YOU! Appreciate the comment!
amazing love docker!
I'm enjoying it too! Thanks for stopping by, and appreciate the comment!
Great tutorial. Thanks.
One piece of feedback - you do great job explaining what to do but a less good job explaining why you do it. There are a lot of commands used in the docker compose file that it would help to understand what they do and why they are needed.
thank you so much! And yes, I can see where you're coming from with that. I'm trying not to get bogged down into minutae, but I can't stay too high level either. Appreciate the comment!
Thanks a lot BRO🔥
no problem at all - thanks for stopping by and happy it helped!
Thank you!
you're welcome! Glad it helped!
Amazing! For the existing wp-content folder for an existing wordpress website, should I import also the db?
thanks! yeah you would have to. Maybe it would be helpful to look around for a sample WordPress dataset that I can use to show that...
Fantastic! Do you have anything for adding SSL (Traefik or Let's Encrypt) or anything about connecting to the container with PHPStorm?
Not yet, but those are great ideas! Thanks for asking / mention it!
hey @wazoowebbytes thanks for this...few questions, (1) you might need to edit the .htaccess file right sometimes, how do you manage it, (2) any videos that you have made on going from this docker setup to production ? (3) in site health there are some errors on REST API and loopback request, did you face it too ?
yeah - I've been wanting to do a followup to this video for quite a while based on lots of great feedback like yours. This video answered a few questions, but seemed to create a few more that need addressing. :)
Thank you very much for this video, it helped me save ~100$ for paying for Mamp PRO. Liked and subscribed!
whoa - didn't know it was priced at that level. No problem at all, just glad it helped you out.
what is the most fast performance for wordpress localy xamp,wamp, localwp, docker wordpress? thx in advance!
Thank you! What you will use now to have hot reload feature for your development setup? Browser Sync? Or something more efficient or maybe docker have something to offer in this matter? I just would like to see a real changes to css and php files. I'm currently using flywheel and Browser sync but tried docker fallowing your video and all works beautifully. I just need to get hot reload working. Many thanks for any hints... Great video I was waiting for it for a long time!
oh nice! Thanks so much. Yeah that's interesting...I agree that there's a piece missing that might be served by some kind of Node tooling to watch for file changes and reload. Good things for me to think about!
@@wazoowebbytes Thanks. Is there any way of creating this development environment without creating WordPress from scratch? I have an existing websites that I develop so is there any way I can move them to some local folder and hook docker to this existing wp installation?
bawss! only recent vid covering this topic
thanks!
Thank you
No problem! Happy to try and help - thanks so much for stopping by!
i love you 🍀 thank you so much
whoa - glad it really helped! Thank YOU so much!
it took me a hot minute since this is the first time i am doing this. but, i got it working at the end. my .env wasn't saved in the folder 😅 thanks for the tutorial!
oh man! I'm happy you got it working and figured it out. Yeah I've been meaning to come back to more WordPress stuff here.
When did he create that DB?
One question. I have several Wordpress website that I am working. If I wanted to setup a second Wordpress site what would I need to change? I assume I create a new folder with duplicate yml and env files. I also guess I need to change port 8080 to something else like 8081. What else would I need to change?
If you wanted to keep a single database per wordpress site (which I imagine would be easiest?) then yeah a different folder with the same setup would probably work ok. If you want to run them all concurrently, then yes you'd have to change the external port value from 8080 to anything else. Good luck!
Wow, excellent explanation. Just one thing, IMO I dont think its good to optimize to use wp-content folder only, because in development time editor will not suggest wp functions properly if we dont have wp-admin and wp-includes folder in our editor (I use VSCode). Whats your thoughts about that?
yeah that's a really good point. When I set out to setup this experiment, I was approaching it from an angle where you might be working on 10 wordpress sites. So I would only want to commit to git the actual different data between each of the 10 vs. also committing 10 copies of the same wp-admin and wp-includes. But maybe I'm wrong to think this way? Good points to think about, appreciate the feedback!!
Thankyou
you're welcome! ❤
What exactly is in the .dockerignore file? Great video btw!
hey - thanks a lot! Hmm pretty much anything you don't want copied from your project folder into the Docker container. So things like the ".git" folder, or "log" folders, etc.
Any chance you could do a Wordpress deployment video?
Thanks for leaving a comment - that's a great idea. I'll get some thoughts together on that.
Excellent tutorial, thank you. One issue I am having is I am not able to sign in to phpMyAdmin with wp_user and wp_password. Any thoughts what I did wrong?
Thanks so much! Hmm maybe double check caps lock (I know...but I had to mention it), and the credentials you're defining in the .env file. So I'm assuming that you have the correct port for phpMyAdmin, you just can't login?
@@wazoowebbytes must have been a typo. I used - instead of an underscore. Thank you for your quick reply. You have a new subscriber.
no problem - I'm happy you got it resolved! Thanks!
You saved my day! I really appreciate your work, thank you very much! This video hasn't the quantity of likes than deserve!
You're so welcome! Wow thanks for a comment like that - it's really appreciated.
thank you for the video. and also for a verse from the bible!
amen! Thanks for stopping by and hope the video helped out
Hey. When I try to run the docker compose up command, I get this error: validating [path-to-file]: services.wordpress must be a mapping. How can I fix this ?
you have to save the file before running the command docker compose up
Thanks - hopefully that's the issue here!
If you create a custom theme, install plugins or upload images, will the files persist after shutting down or restarting?
I think I need to create a followup video here - the actual plugin / theme development wasn't as straight forward as I hoped using this setup. Thanks for asking about it!
@@wazoowebbytes Looking forward to it! Thanks for the current tutorial. Your presentation and explanations of each step were very helpful.
thank you very very much. I appreciate that!
what if i want to host on AWS this?
yeah - I'll have to come up with a followup video to put this on AWS. Thanks!
How does WP run without it's core directories?
hey! When you download the image in Docker, it will be created with its own internal file structure that will have all of WP's files within it. Hope that made some sense.
whats the difference of this wp on docker vs just installing the wp on local pc, this seems to have many more steps too
a few more steps, but that you only have to do once. Then you can run this Docker image wherever you want. You don't need to litter up your server with all the bits you need just to get WP up and running - just a single Docker command. It can save you a ton of time if you're juggling a few WP sites using different versions.
@@wazoowebbytes thanks for replying, appreciate it💜
no problem at all - hope that helps! And it's also 1000% ok if you prefer it your own way :)
Can anybody help me?
Win10
I use
docker compose up -d
and on localhost:8080 i Can install WP
but when I drop existing database and import my database from file
I have "This site is unreachableThe localhost server rejected the connection."
so I use
docker compose down
and delete the volume in docker desktop
and try again use
docker compose up -d
but still: "This site is unreachableThe localhost server rejected the connection."
This is no sense for me
Why this happened? I assume that this not working due to import new database but when I use docker compose down and manually delete the volumine in docker desktop I will be able to running clean docker containers, and it should behave as it did the first time (WordPress installation)
Hmm I'd have to try that out locally to replicate that. Maybe there's a missing line needed in the volumes...? I'll try to run some tests on that.
Money sign
running [docker compose up] returned a no configuration file provided: not found error in terminal. I'm probably doing something wrong here. Not sure what. Mine isn't a fresh install pre se, but I have removed all previous containers and no old containers are running. Looking for some directions.
hmm sorry for the stupid question, but you're running "docker compose up" from the same directory as the docker-compose.yml file?
@@wazoowebbytes I think so. I created the file in the working directory with VS code. then executed from the zsh terminal in vs code. The first time around it worked but I was unable to configure the ngnix conf file. So started over from scratch and now the compose doesn't work anymore.
@@wazoowebbytes never mind. It worked after recreating the yml files. Thanks though!
oh awesome -- but also weird! Maybe a strange hidden character in the file? At any rate, happy to hear it's working!
I don't know what happen, I try the same config, but always wordpress throw "Error establishing a database connection", I try everything :(
do you happen to know the version number of the Docker desktop app you're using by any chance? I've had a lot of difficulty with anything newer than v4.26.1
you can write without
env_file: .env
example:
wp_db_host: ${wp_db_host}
interesting - I'll take a look. Thanks!
i am gettings connection was reset on the browser for some reason
strange. Every once in a while when weird things happen, I just end up needing to reboot. Sometimes things seem to get "stuck" in Docker-land...at least, that's been my experience.
First time using docker,
Docker compose up
Didn't create any files In vs code but they must be somewhere since the WordPress site works...
welcome to the Docker party! That's a great question / observation. The way this docker compose file is structured in the video, all the Wordpress files will just remain within the docker container, so you won't actually see anything "new" show up in VS Code. I'm planning a followup video for some actual WP development work. Thanks for leaving a comment and hope that helps!
@@wazoowebbytes i see, but at 20:42 i see that your vs code installation has files inside of vs code?
Nevermind, im stupid.
i spelt html as hmtl...
./:/var/www/hmtl/wp-content
ahhh that would explain that! Good catch on your end though!
Does not work for me either. I have get an error when I want to reach the localhost:8080: "Error establishing a database connection". In console I have an error: "You need to specify one of MARIADB_ROOT_PASSWORD, MARIADB_ALLOW_EMPTY_ROOT_PASSWORD and MARIADB_RANDOM_ROOT_PASSWORD"
Maybe I made some typo or something, but if I you that provided code from the description, than it works. Thanks :)
good to hear! Hope that alleviates your issues with the setup!
Works like charm . 1010101. Thanks!
heeh awesome - thanks so much, and glad it helped!
Not working: when calling localhost:8080 in browser I get error establishing a database connection.
Seems I set everything like your tutorial. containers are there and running, message in console look also the same. But it's not working.
Seems you missed some information.
hmm sorry to hear it's not working for you. I re-ran a fresh setup and everything came up ok. All you should need is a .env and docker-compose.yml files. Hope that helps!
I have the exact same issue. Likely related to the failure of the phpmyadmin container. No idea how to fix that. I've verified to the best of my ability to make 100% sure the .yml file is exactly like described in the video. Same results on three different boxes (2 Mint, one 64-bit raspberry pi bullseye)
Would love to figure this out...
@@fatbikejamie In my case it was the mysql user which was not created. After creating a valid mysql user with the necessary rights it finally worked.
Hmmm... will check that on my next attempt
@@fatbikejamie I have the same problem, I checking it, but I dunno whether the problem is about docker. My Coworker told me that I need a local domain. I'll try to seek a little bit more.
[+] Running 3/0
✘ wordpress Error 0.1s
✘ database Error 0.1s
✘ phpmyadmin Error 0.1s
Error response from daemon: error creating temporary lease: read-only file system: unknown
D:\docker-wordpress>... help me
could be a few things there. Are you sure you have the Docker desktop app running? If it running, maybe double check in task manager that there's only one instance of Docker. Perhaps there's a previous stuck instance of the app running in the background...?
Is this easier than LocalWP
haven't heard of LocalWP - I'll give it a look. Thanks for mentioning it!
i prefer laragon if you run in windows11
I use both. They are very similar. However when running the same site on both systems I found LocalWp to have a few (solvable) problems. However the Docker version that followed Mr Bytes installation instructions installed and ran perfectly.
wordpress is so slow how can that be fixed
Depending on your system, it could just be the fact that it's running in Docker - while Docker's super handy for setting up environments, it's still a virtual container that uses your system resources
Good information, but why say it's 5 minutes for a 24 minute video 😂
hahah yeah - true. You never know with TH-cam - technically if you just come to the video, and grab the gist -- it's even less then 5 minutes. Good point!
I grabbed the gist and it took me five minutes to set up. Keep up the good work Mr Bytes. I subscribed.
thanks so much! Glad it helped!
Technically, Its 5min if you watch it at 5x speed
Why do you lie that settng up XAMP is hard and complex?
I don't think it's a lie - IMHO. It's time consuming and prone to lots of troubleshooting steps that are bypassed via trying out the Docker approach.
in my case, my local dir is /var/www/wp-docker, but after pulling files using docker compose up, files are pulled, but no file is copied to my local dir.
why is that?
If I understand you correctly, then I think all of the files are showing up in the actual Docker container vs. your local local. Through the Docker desktop, you can navigate into the file structure of your container -- so it *should* be visible there