L
L
Lucius Mooning2017-11-03 22:37:36
Software Deployment
Lucius Mooning, 2017-11-03 22:37:36

What's the recipe for automatically deploying a wordpress site with Deployer?

Greetings!
There is a wordpress site. Task: set up automatic deployment.
As a deployment operator, I still see Deployer. This page describes the basic recipe. But it seems that there is not enough: creating / updating the database, etc.
Which script would be more suitable?
Or is there a better way to do this?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zorca, 2017-11-04
@zorca

The database is best updated via WP-CLI.
Installation:

$ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
$ chmod +x wp-cli.phar
$ sudo mv wp-cli.phar /usr/local/bin/wp

The task for export-import and domain substitution in the database is written in a minute:
desc('Export-import database');
task('database', function () {
runLocally('wp db export wp.sql');
upload('wp.sql', "{$deploy_path}/wp.sql");
run('wp db import wp.sql');
run('wp search-replace //example.dev //example.com');
});

The code was thrown in a hurry, of course, you need to add path variables, set substituted domains, and so on. It is assumed that WP-CLI is installed on the server and on the local machine and responds to the wp abbreviation from the command line. Well, we must not forget that WP-CLI only works from the root folder of the site with Wordpress. You can set a different folder by putting a file in the root of the site: wp-cli.yml . For automatic deployment of the database, you need to upload fresh wp.sql to the turnip. Then the export command disappears as unnecessary.
The problem is actually only in downloading the folders with the apload. Automation assumes that the deployment works when a certain event occurs in the project repository, and the deployment process itself takes place on a virtual machine that does not have access to the upload, since it is not in the repository. If you send directly from the local area, which we will call a semi-automatic device (an example of a task above), then the task is simplified at times, but on Windows you will have to suffer with the download.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question