Setup for Wordpress + Plesk + Git + Local Environment - wordpress

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.

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/

Related

Developing on plesk

Trying to figure the best way to develop on plesk.
I would like to develop my wordpress website on a temporary url, and attach the production domain only when I am done developing.
From some reason I'm getting various dns errors, saw a guide referring to change of hosts file but it dosent seem like the perfect solution to me.
Any tips?
You may create the clone of your WP instance (staging) and use Plesk Git extension for developing this staging WP site. After making all necessary changes on staging non-public clone you can publish it to a production domain to make it publicly available.

VersionPress database sync not working

I'm trying to setup a dev+dev/staging/prod environment with Wordpress. I'm developing local on two Mac workstations (2 local developers) with MAMP. And I have a production server on Cloud. I installed the Wordpress site on my MAMP and cloned it on the other workstation and on cloud. I set GIT to not sync wp-config.php and I made it so that the two workstation and the prod site have the proper DB connection. All 3 site works. I can sync files with Bitbucket with no problem. I setup the VersionPress plugin on all 3 sites assigning the proper name: dev1, dev2 and production. On the Wordpress control panel I see that VersionPress is working, each clone can rollback changes. When I commit things in SourceTree/Bitbucket I see the database changes made by the other dev and the prod site, i.e. [VP] Published post "Test1".
The problem is that the artcle made by Dev1 is not visible on Dev2 or Prod and vice versa. So if from my local MAMP, I log into Wordpress and go to Articles, I can't see the Test article made on the other cloned Wordpress site on our other workstation.
I should be 100% VersionPress compliant, and by the way in the VersionPress setup screen I had all check marked as good with the grey "V" icon.
Am I missing something?
Note: after installing VersionPress a lot of new .git and .gitignore were automatically populated, I guess that's okay, but I haven't touch them.
Other nore: VersionPress is amazing, for those who don't know it I strongly recommend it: https://versionpress.net/ I can't wait to have it 100% functional...
You should clone the sites using VersionPress, specifically its wp vp clone command. Then, you need to push and pull between environments using the other WP-CLI commands, wp vp push and wp vp pull.
The syncing will not work if you installed VersionPress separately on three already existing clones of a site.

Using git with Wordpress and multiple people: access all files locally but only edit a subset?

git n00b here. My boss and I are developing a wordpress workflow with git. We'd like to have a copy of all the files on our local machines, but 95% of time we only want to edit a certain theme folder. But our efforts so far haven't yielded a working solution yet. Here's what I've tried:
I originally set my repository to include all wordpress files, so I could always get latest core files from server. Then I discovered files on server were getting overwritten by local copies even if I didn't edit them (eg i do a wordpress update on server and next time I push from local, the old files overwrite the newer ones on server)
So I used git ignore to drill all the way down to my theme folder. Git was still tracking them, so I used rm to stop tracking. But then git deleted all the other files.
How do people here use git with multiple people to update Wordpress? Any perspectives much appreciated - thanks!
You should keep all the files in your git repository, but you should avoid doing any modifications directlry on the server.
Your wordpress update should be done on any of your local checkout of the repository and then pushed on the server via git.
Another possibility will be to commit / push the update changes once they have been done on the server, but I would prefer working locally and then deploying the update.

Using git with a PHPFog Wordpress app

I have cloned a copy of my PHPFog Wordpress app to my local machine. I then have a few themes im working on with there own sperate repository. So I copy and paste a theme into my Wordpress repository and then sync it back up with PHPFog.
This works all well and good.
However If I update my Wordpress app in the admin panel, and later on sync up some changes I have made I lose the update, and go back to the version of Wordpress I started with.
How are you supposed to correctly work with git and PHPFOG if every change you make on your Wordpress admin panel gets overwritten with every sync from your local machine.
Am I supposed to update Wordpress and then do another clone in order to have the correct version on my local machine before making new changes, and if that is the case how do clone the updated Wordpress app to my local machine.
Thanks
Your right, file system changes, that are made from the Wordpress admin, do not get added to your PHP Fog repo, and can get blown away on the next push.
A better way to handle this issue is to run your Wordpress installation locally on your development system like you hintted to. I use mamp for mac or wamp or xampp for windows to make changes in the Wordpress admin locally then check in and push those changes. This will let you see the results of your changes without effecting your production site. I think the time invested setting this up is well worth it.
To get this running you should install either mamp or wamp and install a fresh copy of wordpress in order to make sure mysql is running locally and the wordpress installation is able to connect. Then in a new folder clone a fresh copy of your repo and load that up in the browser. The url will be something like localhost:8888. It should fail to find the database but that is expected. You will need to configure your local environment variables (listed below) to point to the locally running mysql server. Look in the wp-config.php file of the fresh install for the database settings. Do not use the wp-config.php settings of your cloned repo. You do not want to make changes to wp-config.php file because those changes will get checked into the repo and it will break your production site after the push.
MYSQL_DB_HOST
MYSQL_DB_NAME
MYSQL_USERNAME
MYSQL_PASSWORD
Here is a great link that explains this process in more detail: http://docs.phpfog.com/getting-started/development

Wordpress second install in subdomain?

I am having a website redesigned. The designers plan to use Wordpress as the CMS and want a development copy to work with. Thing is, I now have Wordpress installed to run a blog (only) on a subdirectory of my current site.
Soooo...question is: Can I create a subdomain, install Wordpress on there, point it at a separate (new) schema on MySQL and have them use that for the development work? I know I can physically do this, but will anything about running the the WP install scripts on the subdomain screw up the existing production install on the main domain?
The install itself should not create any problems. Personally, I always develop WP sites in their own subdomain, allowing me to do away with the wordpress/ subdirectory.
The most significant hurdle will come when you are ready to move the development site to a new domain and/or place in the directory hierarchy. Although the theme files and their associated CSS, JS, etc., files should be using relative-path references, the database itself may contain hundreds of fully qualified URLs that reference the development domain and/or directory.
There are a number of WordPress plugins that address this problems. The one I am most familiar with is BackupBuddy from ithemes.com. (I'm not a shill, just a satisfied customer.) BB is useful both for performing scheduled backups (full or database-only), but it is also very useful during development and during deployment. There is an included script, importbuddy.php, than can not only take a .zip of a full backup and restore the site, it can also move the site from one directory and/or domain to another.
Note: BackupBuddy is not free, but it is released under GPLv2. You are paying for the support necessary to keep it tracking changes in the WP ecosystem. If you are doing any serious WP work then it is money well-spent. You might suggest this to your designers.
Yes you can do it. It doesn't matter. You can install your new blogs to any directory or subdomain (actually they're directories, too). Also you can use new MySQL databases for them, or you can use same database for your all WP installations (by editing wp-config.php manually), thereby you'll have same content for your all WP blogs.
Technically, yes you can do it.
However, if you have a live domain with public people using it, you are best not developing on either the same domain or server, because:
Mistakes happen. You can break the database or other code.
While you develop, you can affect performance of the server.
Develop on a local machine, or a completely different server, and when you are happy with it, push the code live onto the production server.
if you are planning to make a test copy of the current install on a subdomain which includes separate source code and database the answer is NO it will not affect your current installation.

Resources