I need to update a development environment which exists for multiple WordPress sites (existing and new ones) and which uses Plesk. Now Git should be used for version control.
Right now every change is done on the stage system, which is not good.
Description of the situation:
Themes which will be used are completely self developed and therefore Git should be used as version control.
The management of the sites is done with Plesk (Production and Stage version).
Sometimes (depending on the site owner) the most recent content is on the production site and sometimes on the stage site (site owner is updating content there) and must be transfered to production.
With the introduction of Git a local environment for every developers is needed (to locally develop and then push the changes to Git), to setup different sites from Plesk on a local environment I would choose MAMP?
Plesk offers a connection between Git (Gitlab in our case) and Plesk so commits will be automatically fetched by Plesk’s Stage and Production environments and are published depending on the settings.
So the Workflow (and included questions) may be the following:
- Setup new site on Plesk and download fresh stage state to local MAMP.
- Create a repository on Gitlab and connect stage branch to Plesk stage site and main branch to Plesk production site.
- Local Git folder will be the wordpress folder. Gitignore will ignore everything except the theme folder and the plugin folder (only plugins which have custom changes)
- Working locally on stage branch and commiting will result in automatically updating the stage system on plesk.
The production page will not be updated automatically, this has to be done manually because this scenario varies from site to site.
Problems:
- Migrating stuff to the production site will be only possible with a manual task I guess, because there is no possibility for customising the pipeline on gitlab as far as I know?
- Don’t know what to do with content images. Should they be ignored in the Git repo? Currently I would say yes if it’s not template related?
Does this sound as a proper way or do I oversee some obstacles here or is there something which can be done in an easier way like the local setup for a new developer on an existing site. As there is only part of the WordPress stuff in Git, the database and the rest of wordpress have to be copied from somewhere (e.g Plesk’ Stage site).
In general the dev setup, deployment and version control with wordpress sites seems a little bit odd for me compared to others like webapps, mobile apps or backend services.
2
Answers
I’ve used git as version control for the whole WP installation and individual themes/plugins. Under normal circumstances, I don’t see the point for the first option, unless you want to keep all the plugins and WP version in sync with the git repo. In that case, you should definitely gitingore the upload folder, otherwise uploading any attachment will cause a mess.
The automate the deploy, you can configure a webhook:
https://conetix.com.au/support/automatic-git-deployments-via-gitlab-to-plesk-based-hosting/
In general you won’t want to keep a complete WordPress install under SCM only the parts you or your team writes, that is your custom plugins and themes. Including everything WordPress and than .gitignore all the things you don’t need is certainly not the way to go, imo.
Nothing stops you from setting up multiple git deployments on one site one for your theme and one for the plugins you or you team creates. You could even reuse plugins on multiple sites, just set these up accordingly.
We’ve successfully deployed multiple wordpress installations like this. You might want to include a README.MD including the WordPress version/configuration and listing all third party plugins your site or sites require. In that way new developers are up to speed fast. What you use locally (MAMP, WampServer, or XAMPP) is not really relevant.
You will need to somehow synchronize and document the basic database setup to include your categories and other hierarchies that are not stored in files.