Skip to content

Adding new domain & WP-Site on Gutenberg

  • Point the desec domain js to the gutenberg server with GUTENBERG_HOMEPAGE(), (for a root domain, with both www and @), or GUTENBERG_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.cfg in hublot, reload:
  • create the WP DB using sudo mysql on 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/wordpress from another one
  • Get a certificate using desec plugin
  • Update the desec_tokens.yaml file 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 (no sudo, 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-admin user with wordpress-${unique_name}$@raksha.ch as 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:

  1. 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
  2. dump the source DB to the destination DB sudo mysqldump ${source_db} | sudo mysql gutenberg_raksha_wp
  3. Check if the table prefix is indeed wp_: echo "show tables" | sudo mysql gutenberg_raksha_wp
  4. if not, update /etc/wordpress/config-gutenberg.raksha.ch.php accordingly
  5. 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
  6. copy the uploads sudo rsync -avO /var/www/s3-wp-content/${OLDSITE}/ /var/www/s3-wp-content/gutenberg.raksha.ch/