Hosting a PHP-based CMS on Digital Ocean

Any idea how to set up a CraftCMS site in Digital Ocean? It's a PHP-based CMS and I think they use MariaDB. Never did any hosting more complicated than Netlify and I have some experience with cPanel but that's about it, and I can't find any good articles specific for CraftCMS. Would appreciate some guidance!
94 Replies
vince
vinceOPโ€ข7d ago
I have the project locally running inside a docker container, can I just upload the docker container to the server and run docker that way?
b1mind
b1mindโ€ข6d ago
what kinda container (hosting) do you have on DO? err dropplet xD
vince
vinceOPโ€ข6d ago
I rebuilt the droplet using the Docker setup if that's what you mean
b1mind
b1mindโ€ข6d ago
so you just have a ssh into a unbuntu box?
vince
vinceOPโ€ข6d ago
Yea
b1mind
b1mindโ€ข6d ago
or w/e you picked
vince
vinceOPโ€ข6d ago
With docker set up
b1mind
b1mindโ€ข6d ago
so you can copy your docker img up and run it yea I would setup some nginx/apache though certbot etc too >.>;; my lazy ass just uses CapRover as I've mentioned Coolify is another good option CapRover is simple and slender, Coolify is a bit heavy but lots of options and tools.
vince
vinceOPโ€ข6d ago
See the thing is I'm using DDEV for local development, which is a wrapper for docker So I don't have any of the docker files and need to make them myself for the remote hosting and I have no idea what I'm doing ๐Ÿ˜‚ This is so much harder than using Netlify
b1mind
b1mindโ€ข6d ago
I mean if its not helping why use it I mean Netlify is one way lol Again I'd use Caprover
b1mind
b1mindโ€ข6d ago
If you want something like Netfliy that you run ๐Ÿ˜‰ Then you would just do w/e 6 ways to deploy you want too. hell lets you drop a .rar on it ๐Ÿคฃ But you will still use dockerfiles for build steps and what not, so not all easy ig.
vince
vinceOPโ€ข6d ago
Checking out that now. Have you ever used ploi? Some of the CraftCMS devs over in their discord are recommending it
b1mind
b1mindโ€ข6d ago
No but I wouldn't either Looks like a money grab >.>;;
vince
vinceOPโ€ข6d ago
Yea I saw the free tier has only 5 deployments a month...
b1mind
b1mindโ€ข6d ago
yea fuk all that Use Cap or Coolify
vince
vinceOPโ€ข6d ago
But the 8$ tier is unlimited deployments (its in pounds / euros?) so honeslty what's that like 10$ a month or something? I'd be willing to try that
b1mind
b1mindโ€ข6d ago
na fuk that You already pay for hosting why pay for deployment
vince
vinceOPโ€ข6d ago
Cause u said with Cap I still need to set up a docker container right? And I have no idea how to do that through my setup now
b1mind
b1mindโ€ข6d ago
Bruh No I said you would need a dockerfile its basically a set of commands man simple shit for someone like you build commands like npm run dev and shit lol
vince
vinceOPโ€ข6d ago
Oh I thought I needed a docker-compose file too sorry I have no idea wtf any of this is lol
b1mind
b1mindโ€ข6d ago
I mean you could yes CapRover is just a helper GUI for nginx/certbot/docker so you don't have to lift so heavy
vince
vinceOPโ€ข6d ago
honestly getting a dockerfile up might be hard too because ddev literally sets it all up for me so I have no idea what it actually ran. I literally just run a command like ddev config --project=craftcms and it installs everything needed to get the cms up and running locally
b1mind
b1mindโ€ข6d ago
but ya you will need to learn a little bit then that is what you would run in the dockerfile prob but pprod all docker is .. is isolation Think of it as a micro box in your box Craft has to have docs on it too if not just learn how to run prod If the dev command is that easy I'm sure the prod one is too
vince
vinceOPโ€ข6d ago
I know they have a docker hub thing Idk if that is any use
b1mind
b1mindโ€ข6d ago
Like I would imagine you are talking about two different things too One hosting Craft... other hosting a website that uses craft? Or does it all just tie into the one ?
vince
vinceOPโ€ข6d ago
Dude I literally have no idea ๐Ÿ˜‚
b1mind
b1mindโ€ข6d ago
You have used it yes? (thought you said you had)
vince
vinceOPโ€ข6d ago
Yea but I just don't know how any of this stuff works, I'm purely frontend CraftCMS is just a php-based CMS that uses twig files to build out html templates, and it lets you login and edit stuff in the dashboard, and runs MySQL That's all I know of how it works lol
vince
vinceOPโ€ข6d ago
It does make this /web folder so I guess that's where all the actual files are built?
No description
b1mind
b1mindโ€ข6d ago
yea so if you are just hosting the CMS locally then keep doing that and just upload the output ๐Ÿ˜„ but you will need a php server nginx/apache to host it with*
vince
vinceOPโ€ข6d ago
Okay that explanation just made things sound 200x easier, I'd still be able to go into the actual site then and go into the dashboard and change stuff around right? I guess since it just is all .php files at the end
b1mind
b1mindโ€ข6d ago
ummm if its local? idk lol I mean yes to local to their site idk actual site*
vince
vinceOPโ€ข6d ago
Got it, since I already pay for DO I'll just try to set it up on there. Just set up something like a LAMP template and upload the /web/ files under /var/html/web?
b1mind
b1mindโ€ข6d ago
sure or use what I suggested xD
vince
vinceOPโ€ข6d ago
thank you i'll see what i can figure out from both i dont know why this stuff just doesnt make sense to me it seems so complicated
b1mind
b1mindโ€ข6d ago
yea I just checked CapRover nor Coolify have one click installs but... looking it does not seem to hard to setup with docker files follow docs like everything https://hub.docker.com/r/craftcms/nginx yea so they do have it on hub too so thats where I would start if I was using CapRover
vince
vinceOPโ€ข6d ago
yea i was gonna link that earlier i saw that, so just try following that and use caprover?
b1mind
b1mindโ€ข6d ago
yup You can still use what you use locally since its easy Then setup something that works on hosting too nothing wrong with that. I'd be shocked if that local tool does not have a prod option too though. I personally would just use the local and upload php files with ci/cd like normal though Just make sure it does not need anything special for hosting the php files Idk though i'd think if it worked like that it would be static so not like Netlify works Maybe it does need itself or atleast the db they are not real clear about this. but I'm out of it and probably can't read.
vince
vinceOPโ€ข6d ago
Yea it definitely needs the DB, on prod you have the frontend site and then you can do something like https://site.com/admin and log into the admin dashboard, and make changes to the components and things that gets rendered to the frotnend if thats what u meant idk im out of it too lol
b1mind
b1mindโ€ข6d ago
Note: We purposely do not provide a web server image because that choice depends on your project needs. We do, however, provide examples illustrating how to use Nginx or Caddy with the php-fpm images.
So ya you would use one these imgs and config Cap or something with it
b1mind
b1mindโ€ข6d ago
Sux there is not a one click for it. You get this working you should submit one ๐Ÿคฃ
vince
vinceOPโ€ข6d ago
oh god if i ever get this working it'll be a frankenstein lmao
b1mind
b1mindโ€ข6d ago
I mean having something like Cap and Coolify is a great exp though, its good to know a little. It would allow you to host anything you want too
vince
vinceOPโ€ข6d ago
God I hope so, man. I've been so stuck on this hosting stuff for legitimately years
b1mind
b1mindโ€ข6d ago
well within reason xD
vince
vinceOPโ€ข6d ago
I have hope though now ๐Ÿ™‚ thank you I'm just gonna start with the getting started docs in CapRover and go from there
b1mind
b1mindโ€ข6d ago
Yea I mean other stuffs really easy too, it gets a bit more complicated when you need to have all the containers talking like this will need but I have faith in you. Its really just configs of commands xD (its insanity really but trying to make you feel better) Nice part once its up its up lol just make notes of any footguns (like nginx wants trailing slash urls/ for static paths without extensions so you need to make sure you don't pull your hair out trying to reverse this... just tell your framework to add them lol) Like hosting JS stuff is stupid easy cause well .. its got that going for it (I have multiple github hooks setup for deployment, so it works just like vercel/netlify) But I have actual node servers and actual static sites >.>;; not "serverless" thats still servers lol
vince
vinceOPโ€ข6d ago
damn man you know all this stuff ๐Ÿ˜‚
b1mind
b1mindโ€ข6d ago
kinda not really I just abuse CapRover and learn as I go since its just a GUI layer I found Coolify too much and too heavy for my servers (little 2cpu 2gigs) but its a good option as mentioned too takes the pain out of a lot of this It favors Caddy over Nginx (is another factor)
vince
vinceOPโ€ข6d ago
progress ๐Ÿ™
No description
vince
vinceOPโ€ข6d ago
Okay so I uploaded a .tar and added a Dockerfile, now I think I need to make that docker-compose / captain-compose file and it should work?
vince
vinceOPโ€ข6d ago
(ignore the name lol)
No description
vince
vinceOPโ€ข6d ago
So yea I guess the Dockerfile installs the dependencies to build the image and then builds the container image on the host, and then we need the docker-compose to tell it how to run the image? Am I understanding that correctly? The more I use CraftCMS for anything outside the recommended default the worse it gets ๐Ÿ˜‚ It's really nice when it works well, not so much when it doesn't Following their guide for getting Docker setup and the steps in the documentation just don't work Because they recommend DDEV, but I'd rather just set up the Docker container directly (rather than using DDEV as a wrapper) so I can push the container & dockerfiles to CapRover
b1mind
b1mindโ€ข6d ago
A hate systems like this
vince
vinceOPโ€ข6d ago
I'm literally going into the Docker container and setting chgrp and perms to the www-data user lmao
b1mind
b1mindโ€ข6d ago
This would deter me from using craft CMS personally I don't like things with such limits ๐Ÿ˜ž
vince
vinceOPโ€ข6d ago
I used it at my old company and I thought the development process was suuuuuuuper smooth which is what's keeping me trying at this point it's just a PITA rn The admin dashboard and the ability to create custom fields was really really easy
b1mind
b1mindโ€ข6d ago
But have you tried anything else ๐Ÿ˜‚ ignorance is bliss as they say
vince
vinceOPโ€ข6d ago
Nope not really xD I mean I did WP but it wasn't anything custom I don't really want to use WP since it seems kinda monolithic when I used it I'm sure headless WP is a lot better but eh
b1mind
b1mindโ€ข6d ago
Na it's not really I was looking into headless WP for awhile but it's just not great way The API is lack luster and the control is nill Really depends on how you want things rendered to ig though
vince
vinceOPโ€ข6d ago
What cms do you recommend that'll be easy to get hosted on caprover? I just want something I can build a frontend in and I can have people go in and add videos / change some text around if I configure it
b1mind
b1mindโ€ข6d ago
I didn't really have one I like self hosted yet I was going to look at KirbyCms Maybe tinaCms PagesCMS
vince
vinceOPโ€ข6d ago
I've used Tina but it was really barebones, I guess it could work for what I need too but wanted something a bit more robust
b1mind
b1mindโ€ข6d ago
I'm using free tier of Prismic now
vince
vinceOPโ€ข6d ago
Might try prismic then, u said u haven't self hosted it tho?
b1mind
b1mindโ€ข6d ago
Which I just love how they do things You can't self host Prismic
vince
vinceOPโ€ข6d ago
Oof
b1mind
b1mindโ€ข6d ago
I mean you self host the websites But the CMS is on their servers ๐Ÿฅฒ You get imigx cdn with it which is killer, but yea is a vendor lockin They do things like no other though which is really nice imo I love slices and the control as a developer I have over what the CMS can and can't use for the content creator
vince
vinceOPโ€ข6d ago
I've spent so much time at this point I want to try to get something self hosted up (because I hate myself ๐Ÿ˜‚) prismic does look easy though Yea thats why I love craftcms You build out what fields a content type has in the dashboard and then just call the fields out in the twig files to render them It's super nice
b1mind
b1mindโ€ข6d ago
Yea again this is very dependant on how you want things to render and what language you want to use. I am talking about the other direction, where a person wants to edit a page or slice content, as a developer I am defining what slices can be put on a page type and what elements can be used.
vince
vinceOPโ€ข6d ago
ooo yea that's way too heavy for what i need
b1mind
b1mindโ€ข6d ago
This for me is killer cause I've had almost every WP website I've built be destroyed by some "WP admin" lol But also allows me to be the one that controls if a slice can use the correct heading levels I.e.
vince
vinceOPโ€ข6d ago
That is really nice tbh just not what I need :( maybe I'll try Tina, last time I used it it was really easy because whenever someone made changes in the admin dashboard it would commit it to git That way I didn't even need a DO droplet or anything I could just host the frontend on netlify and it would update But I'm being stubborn now and want to learn docker and how to self host a container Too tired of feeling vendor locked or not understanding how to selfhost something
b1mind
b1mindโ€ข6d ago
Cap Rover you can do that too like I mentioned
vince
vinceOPโ€ข6d ago
Ye I really like caprover's dashboard and I feel all techy using it lol so I want to keep using it if possible brb driving to gym
b1mind
b1mindโ€ข6d ago
Kk drive safe get swol
vince
vinceOPโ€ข6d ago
It's just for maintenance at this point lmao asked again on some new advice for getting regular docker setup in the CraftCMS discord and one of the guys messaged me privately trying to sell me Ploi again ๐Ÿ™„ If I have to pay a third party just to deploy my code then maybe the cms isn't mature enough... And I know I'm definitely a devops noob so that's where a lot of the issues are coming from but also there's just like... no documentation on how to get something up and running? It seems like the whole local dev ecosystem is tied to a build tool and if I try to deviate and follow the docs directly I get errors? Like what is that Might look into using Astro + Strapi, Strapi actually has great documentation and I'm decently familiar with Astro And it's in the one-click apps for CapRover too
b1mind
b1mindโ€ข6d ago
This is after I've finished contracts. Managers have full rights
vince
vinceOPโ€ข6d ago
Guys... I did it. Legitimately took me all weekend. I caved and bought Ploi for the third-party deployment service. idc anymore it's like 15$ a month to host this site but it saved me my sanity
No description
vince
vinceOPโ€ข6d ago
I was going to go the Astro + Strapi route and then after a couple hours saw that the one click deployment for Strapi in CapRover was outdated and not working...
b1mind
b1mindโ€ข6d ago
Sounds worse than Vercel and nextjs lol That kinda lockin sux but I'm happy your happy
vince
vinceOPโ€ข6d ago
I agree but I could have probably spent another weekend trying to get it to work 15/month is not breaking the bank at all
b1mind
b1mindโ€ข6d ago
Free is nicer
vince
vinceOPโ€ข6d ago
I agree I wish I could have gotten it to work but just wasn't happening
b1mind
b1mindโ€ข6d ago
So you pay for deployment and your vps still or that includes the hosting? I didn't look that hard
vince
vinceOPโ€ข6d ago
It's just for deployment, so it's 6$ a month for the DO droplet and then 8 (pounds? euros?) for the deployment service, so that's what like 10$ usd? so 16 usd a month This is a hobby stupid fun project too so sucks im spending almost 20 a month out of my pocket to host it but its whatever
b1mind
b1mindโ€ข6d ago
At that point isn't it better to just use crafts hosting? Or same boat?
vince
vinceOPโ€ข6d ago
I didn't look tbh I was so focused on getting it to work on DO but just checked the prices lol
No description
b1mind
b1mindโ€ข6d ago
Holy bawls
vince
vinceOPโ€ข6d ago
Yea which is probably one of the reasons why it was so hard to find anything good documentation-wise on hosting it Lowkey they probably do it on purpose
b1mind
b1mindโ€ข6d ago
Yea kinda jank they make deployment so hard too like self hosting is not really self hosting at that point ๐Ÿคฃ
vince
vinceOPโ€ข4d ago
fr lol I'll look into them but I'm just happy I got something hosted at this point ๐Ÿ˜‚ I think I spent like 12 hours over the weekend trying to host it lol

Did you find this page helpful?