[GUIDE] Setup WP on a VPS without cpanel

Noob question. What are the pros and cons of running the WP site on docker compared to cPanel, cloudpanel and the like?
Great question! Other than the obvious benefit of not having to pay for cpanel license per month (Even if your hosting provider says "free cpanel included", it is not actually free. They include the pricing, and you get worse hardware for the same price), it also helps in not having the cpanel service running. The cpanel service eats up anywhere from 300mb to a gig by itself.

Docker on the other hand is very lightweight, and you can easily run it in a 1gig ram vps as well.

The other big benefit of using docker is the fact that everything you install with docker is virtualised (and they don't physically get installed on the server...). For example, if your wp uses apache and mysql, it is not physically installed on the server. If you just do a
docker compose down
and a
docker system prune -a
Everything that was installed for the application stack would be purged from the server without leaving any trace.

Also you could for example have both python 2.x and 3.x installed at the same time, or have 5 separate mysql servers all installed on the same server. Which would be really tough to achieve with physically installing the softwares (with/without using cpanel).
 
Great guide, I'll definitely try this for my next blog.
Just have few questions regarding wp - vps
1. How to server resources are utilized with this.
2. How to access wp files.
3. How to install multiple wp.
4. How to work with subdomains.
 
Thanks for your valuable sharing. Great guide.
 
Great guide, I'll definitely try this for my next blog.
Just have few questions regarding wp - vps
1. How to server resources are utilized with this.
2. How to access wp files.
3. How to install multiple wp.
4. How to work with subdomains.
Great questions. Let me try answering them..

For point number 2, you have the wordpress installation in the "wordpress" folder under your project. This is the volume mapping that achieves that..
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/docker-compose.yaml#L23

Instead of persisting the whole wordpress folder, you could also persist only the wp-content, because that's what you need for 99.99% times. For achieving that, change the line to the following:

Code:
- ./wp-content:/var/www/html/wp-content

If you want to develop locally, don't use the docker-compose file on the server directly. Instead, install docker desktop and git on your dev machine, clone this repo to your dev machine:
Code:
https://github.com/noc2spam/wp-on-docker
remove the following line from the .gitignore:
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/.gitignore#L3
and start developing! As you removed the wordpress folder from ignored folders, the whole folder will now be part of the repo as well. You now can push the modified code to your own repository (git remote add downstream yourgiturl && git push downstream master) and use that instead of my example wp-on-docker repo.

For point number 3 & 4, you can follow the same tutorial and install the blogs on multiple folders (e.g. ~/sites/project1, ~/sites/project2 etc), but you will need to change the exposed ports:
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/docker-compose.yaml#L20
and
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/docker-compose.yaml#L33
Change the 2023 and 2024 to something else like 2025 and 2026.

Subdomains will also work in the exact same way. In the tutorial, I used @, www, pma as the sub domain host parts. You could follow that same pattern and add let's say add:
Code:
host: project2, ip: sameip, TTL: leave it default
host: pma2, ip: sameip, TTL: leave it default
Then use the same gist content:
Code:
https://gist.github.com/noc2spam/241b1a0e0b9083b8769c37937463775c
Here, change the host to project2.domain.com and pma2.domain.com. Also change the proxy_pass url to the new ports e.g. http://127.0.0.1:2025 and http://127.0.0.1:2026.

As for point number 1, you could see the logs by typing:
Code:
docker logs containername
You can find out the containername by issuing:
Code:
 docker ps
You can check RAM usage by issuing:
Code:
free -m
You could also go to the project folder and issue
Code:
docker compose up
That will connect you up with the current running stack and you will be able to see the live log from there. Just press ctrl + z to exit without stopping the containers.

If you are interested, I would recommend reading up on docker a little more. These are big topics and hard to explain everything in a post. :)

Also remember, all these things can be automated with something like Ansible. If you learn Ansible with Docker, you can make an ansible script which will do everything for you with just one command. You could even take backup etc with ansible. I did not explain that in the original post because I don't want to burdain you with more knowledge being a beginner. If you are interested, please feel free to read up. :)
 
Nice sharing .
Its so valuable for BHW community .
Thank you so much for sharing great tutorial mate .
 
Great questions. Let me try answering them..

For point number 2, you have the wordpress installation in the "wordpress" folder under your project. This is the volume mapping that achieves that..
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/docker-compose.yaml#L23

Instead of persisting the whole wordpress folder, you could also persist only the wp-content, because that's what you need for 99.99% times. For achieving that, change the line to the following:

Code:
- ./wp-content:/var/www/html/wp-content

If you want to develop locally, don't use the docker-compose file on the server directly. Instead, install docker desktop and git on your dev machine, clone this repo to your dev machine:
Code:
https://github.com/noc2spam/wp-on-docker
remove the following line from the .gitignore:
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/.gitignore#L3
and start developing! As you removed the wordpress folder from ignored folders, the whole folder will now be part of the repo as well. You now can push the modified code to your own repository (git remote add downstream yourgiturl && git push downstream master) and use that instead of my example wp-on-docker repo.

For point number 3 & 4, you can follow the same tutorial and install the blogs on multiple folders (e.g. ~/sites/project1, ~/sites/project2 etc), but you will need to change the exposed ports:
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/docker-compose.yaml#L20
and
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/docker-compose.yaml#L33
Change the 2023 and 2024 to something else like 2025 and 2026.

Subdomains will also work in the exact same way. In the tutorial, I used @, www, pma as the sub domain host parts. You could follow that same pattern and add let's say add:
Code:
host: project2, ip: sameip, TTL: leave it default
host: pma2, ip: sameip, TTL: leave it default
Then use the same gist content:
Code:
https://gist.github.com/noc2spam/241b1a0e0b9083b8769c37937463775c
Here, change the host to project2.domain.com and pma2.domain.com. Also change the proxy_pass url to the new ports e.g. http://127.0.0.1:2025 and http://127.0.0.1:2026.

As for point number 1, you could see the logs by typing:
Code:
docker logs containername
You can find out the containername by issuing:
Code:
 docker ps
You can check RAM usage by issuing:
Code:
free -m
You could also go to the project folder and issue
Code:
docker compose up
That will connect you up with the current running stack and you will be able to see the live log from there. Just press ctrl + z to exit without stopping the containers.

If you are interested, I would recommend reading up on docker a little more. These are big topics and hard to explain everything in a post. :)

Also remember, all these things can be automated with something like Ansible. If you learn Ansible with Docker, you can make an ansible script which will do everything for you with just one command. You could even take backup etc with ansible. I did not explain that in the original post because I don't want to burdain you with more knowledge being a beginner. If you are interested, please feel free to read up. :)
Really appreciated for your effort.
But this seems too much for me now, I do not have much technical knowledge. But I'll apply this steps as you mentioned and let you know.
Thanks.
 
On AWS, I usually install a LEMP server and after setting up the A records you just visit your domain and continue the WP installation.
 
On AWS, I usually install a LEMP server and after setting up the A records you just visit your domain and continue the WP installation.
Sure that’s a way to install as well. You don’t even have to install lemp/lamp manually. You could use a tool called ansible which would login to the vps by itself and install everything automatically (you have to write the script for once, then it automates the process every time. You could even have 100 servers getting installed at the same time by the script).

I still prefer docker (btw docker can be used in conjunction with ansible as well, but that is not explained in this tutorial for the sake of simplicity) because it is virtualised and easy to scale. Read more on docker may be. ;)
 
Last edited:
When you have SSH then it is more convenient to use any free web panel for managing everything.
 
Installation script for Ubuntu:
https://github.com/hestiacp/hestiacp/blob/main/install/hst-install-ubuntu.sh
 
Not sure why you would use docker unless you plan on moving it later or scaling it. Much simpler and easier to just run a bash script to install a stack. Ask chatgpt to do it for you even.
Well, I want the projects I make to be scalable. Not sure about yours. :)
 
A small vps can handle tens of thousands of traffic monthly. Maybe I'm not in your level.
And it's still scalable, just take a snapshot move it and rebuild. Or use a load balancer
 
A small vps can handle tens of thousands of traffic monthly. Maybe I'm not in your level.
And it's still scalable, just take a snapshot move it and rebuild. Or use a load balancer
Not sure what you are trying to achieve here. Sure, that would also work fine. You just can’t have load balancers without replicating the instances either manually or automatically. But I am sure you know how to replicate the instances.

Feel free to stick to what you know works well for you. This tutorial was meant to make people curious about docker and nginx. If that doesn’t work for you, just skip this tutorial.

Feel free to post a better one as well because the community could use your knowledge.
 
Last edited:
Maybe I mis understood it being about docker and nginx as the title was 'setup WordPress on a vps without cpanel'
 
Back
Top