Adding new domain & WP-Site on Gutenberg
- Point the desec domain js to the gutenberg server with
GUTENBERG_HOMEPAGE(),(for a root domain, with bothwwwand@), orGUTENBERG_SITE()- wait until the DNS propagates (make sure to hit the "Apply" button on the "DNSControl push" pipeline job) - Add the domain to
/etc/haproxy/haproxy.cfginhublot, reload: - create the WP DB using
sudo mysqlon gutenberg:mysql create database ${unique_name}_wp character set utf8 collate utf8_unicode_ci; create user '${unique_name}_wp'@'localhost' identified by '${random_pw}'; grant all privileges on ${unique_name}_wp.* to '${unique_name}_wp'@'localhost'; - create the wp dirs and files, adjust ownership to www-data where needed. Webroot in
var/www/symlinking contents of wp-content as needed:/var/lib/wordpress/wp-content/, uploads are on/var/www/s3-wp-content/yourwpdomain/uploads: (as root) :bash SITE=test.example.com mkdir -p /var/www/$SITE/wp-content ln -sf /var/lib/wordpress/wp-content/languages /var/www/$SITE/wp-content/languages ln -sf /var/lib/wordpress/wp-content/plugins /var/www/$SITE/wp-content/plugins ln -sf /var/lib/wordpress/wp-content/themes /var/www/$SITE/wp-content/themes mkdir -p /var/www/s3-wp-content/$SITE/uploads ln -sf /var/www/s3-wp-content/$SITE/uploads /var/www/$SITE/wp-content/uploads - create the config-yourwpdoamin.php file in
/etc/wordpressfrom another one - Get a certificate using desec plugin
- Update the
desec_tokens.yamlfile in desec-zones to add the concerned domain(s) to the gutenberg desec token, - make sure the change is propagated
- Run
certbot-desec -d $DOMAIN -d www.$DOMAIN(nosudo, it's already in the alias) - finally create your apache conf file by copying another, test and enable it (
sudo apachectl configtest&sudo a2ensite) - Head to the wordpress interface and create a
raksha-adminuser withwordpress-${unique_name}$@raksha.chas email address
How to copy one wordpress to another
This is useful when someone wants to play with their DB for tests and laughs. We setup gutenberg.raksha.ch for that purpose.
From gutenberg:
- reset the destination DB
echo "drop database gutenberg_raksha_wp;" | sudo mysql echo "create database gutenberg_raksha_wp;" | sudo mysql echo "grant all privileges on gutenberg_raksha_wp.* to 'gutenberg_raksha_wp'@'localhost';" | sudo mysql - dump the source DB to the destination DB
sudo mysqldump ${source_db} | sudo mysql gutenberg_raksha_wp - Check if the table prefix is indeed
wp_:echo "show tables" | sudo mysql gutenberg_raksha_wp - if not, update /etc/wordpress/config-gutenberg.raksha.ch.php accordingly
- update the URLĀ in the whole database
WP_PREFIX=wp_ OLDSITE=example.com echo "UPDATE ${WP_PREFIX}options SET option_value = replace(option_value, '${OLDSITE}', 'gutenberg.raksha.ch') WHERE option_name = 'home' OR option_name = 'siteurl';UPDATE ${WP_PREFIX}posts SET guid = replace(guid, '${OLDSITE}','gutenberg.raksha.ch');UPDATE ${WP_PREFIX}posts SET post_content = replace(post_content, '${OLDSITE}', 'gutenberg.raksha.ch'); UPDATE ${WP_PREFIX}postmeta SET meta_value = replace(meta_value,'${OLDSITE}','gutenberg.raksha.ch');" | sudo mysql gutenberg_raksha_wp - copy the uploads
sudo rsync -avO /var/www/s3-wp-content/${OLDSITE}/ /var/www/s3-wp-content/gutenberg.raksha.ch/