Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Matthias Andrasch
Matthias Andrasch

Posted on • Edited on

     

Deploy CraftCMS via ploi.io on Hetzner cloud (the fast way)

What is an easy way to get a CraftCMS site up and running? I found this to be a rather simple method with help ofploi.io, aHetzner CX11 virtual cloud server (max. € 4.51 / month) andDDEV for local development.

Beware: I'm a CraftCMS newbie! 🤓

Prerequisites

  1. InstallDDEV for local development
  2. Sign up for aHetzner Cloud account
  3. Sign up for aploi.io account
  4. Connect the Hetzner account via API key on ploi.io (as service provider)
  5. Create your first server via ploi dashboard

Screenshot ploi service provider

Screenshot ploi create server

Screenshot create server

Create GitHub repository, clone it locally

Create a new GitHub project (with README), clone it locally and run these commands for the CraftCMS installation:

DDEV quickstart for CraftCMS

# Set up the DDEV environment:ddev config--project-type=craftcms--docroot=web--create-docroot# Boot the project and install the starter project:ddev startddev composer create-y--no-scripts craftcms/craft# Run the Craft installer:ddev craftinstallddev launch
Enter fullscreen modeExit fullscreen mode

Push the new files to your GitHub repository.

Dump the local database

For the initial installation we need a dump of the database. This can be achieved viaddev export-db -f dump.sql.gz.

This database dump will be later imported into the live sites database.

But do not worry: After that initial DB import, changes to the data structure will be applied via files in git and by CLI migrate commands (for examplephp craft migrate/all --no-content --interactive=0).

Create a new database on ploi.io (server)

Databases are managed via Server

Image description

Install phpMyAdmin, connect via DB user and password

Image description

Import the database dump file

Image description

Create a new site via ploi

You don't have to connect the real domain immediately, you can also generate a test domain later. Therefore you can also use "mysite.example.com" e.g.

Image description

Install from git repository

We use a git repository,not the 1-click installer for CraftCMS.

Image description

If you use a public repository, you can just paste the URL:

Image description

Adjust the deploy script

These are commands which are executed when you hit the "deploy now" button.

Image description

# ploi standard commandscd /home/ploi/craft-playground.mandrasch.devgit pull origin main# NodeJS support, e.g. for vite# npm install# npm run buildcomposerinstall--no-dev--no-interaction--prefer-dist--optimize-autoloader# deployment best practices by craftcms docs:# https://craftcms.com/knowledge-base/deployment-best-practicesphp craft update/composer-install--interactive=0php craft migrate/all--no-content--interactive=0php craft project-config/applyphp craft migrate--track=content--interactive=0echo"" |sudo-S service php8.2-fpm reloadecho"🚀 Application deployed!"
Enter fullscreen modeExit fullscreen mode

Add .env values via "Edit environment"

Copy the .env values from.env.example.production, add a security key and adjust the database connection settings. For the security key you can use a generator likeBitwarden Generator.

Image description

Image description

Add a free "Let's encrypt" SSL certificate

Image description

Optional: Add a test domain

If you haven't connected a real domain yet, you can also use a test domain freely provided by ploi.io (for test usage / development).

Image description

gitignore the license.key

One last thing I would suggest is addingconfig/license.key to your.gitignore, otherwise you will end up with "Your local changes to the following files would be overwritten by merge: config/license.key" after the first deployment.

Ready for deployment! 🎉

Hit the "Deploy now" button and pull the craftcms installation from your GitHub repository:

Image description

That's it. Open your site and enjoy developing with Craft CMS! 🎉

Image description

If you want to trigger auto deployment when pushing to GitHub, check out this guide:ploi.io - How to trigger deployments via GitHub actions

If you're interested in integrating Vite, there is an awesome pluginnystudio107/vite for CraftCMS. Check out example code and tutorial here:https://github.com/mandrasch/ddev-craftcms-vite.

In future it would be cool to have a good and robustddev pull script to download media assets and live content into local development.

Also make sure to join theDDEV discord. 💚

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
martn_rodriguez_589fedb5 profile image
Martín Rodriguez
  • Joined

This looks really cool and straight forward!
Do you by any chance also know how to do that for NetCup?
And also are you still using CraftCMS nowadays?

CollapseExpand
 
mandrasch profile image
Matthias Andrasch
Keep it simple. Sustainable Web Design & Open Source for the win. https://sustainablewebdesign.org/
  • Location
    Vienna, Austria
  • Joined

hey!

yes, using CraftCMS is my current work as developer in a web agency :)

For NetCup: You would have to deploy via SSH/rsyncgithub.com/marketplace/actions/rsy... - or checkout the git repository on your server if git is available), or use Docker, another deployment option. Don't know what NetCup is offering.

For SSH/rsync deployment, see for example
webstoemp.com/blog/github-actions-...

(Just did a quick google search)

If you don't want to fiddle around yourself with GitHub Actions and such, platforms likebuddy.works/ are a bit easier to get started.

Or you could also check out Deployer (dev.to/mandrasch/deploy-craft-cms-...), but I found it a bit to complicated in the end.

Also joining Craft Discord could be a good option, maybe someone could assist you there as well if you have questions. Maybe someone already deploys on NetCup.

Have fun with CraftCMS!

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Keep it simple. Sustainable Web Design & Open Source for the win. https://sustainablewebdesign.org/
  • Location
    Vienna, Austria
  • Joined

More fromMatthias Andrasch

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp