Skip to content

Instantly share code, notes, and snippets.

@nunomorgadinho
Last active September 27, 2019 13:48
Show Gist options
  • Save nunomorgadinho/ab2e68c32f06420082b642742f40ee2b to your computer and use it in GitHub Desktop.
Save nunomorgadinho/ab2e68c32f06420082b642742f40ee2b to your computer and use it in GitHub Desktop.
setup new country
#create db user
CREATE USER 'idealbiz_za'@'localhost' IDENTIFIED BY '<PASSWORD>';
GRANT ALL PRIVILEGES ON idealbiz_za.* TO 'idealbiz_za'@'localhost' WITH GRANT OPTION;
flush privileges;
#mysql db import
mysql -u idealbiz_za -p'<PASSWORD>' idealbiz_za < idealbiz_fr_dump.sql
# to allow login and recover pass by the tech user
update wp_users set user_login="<EMAIL>" where user_login="<EMAIL>";
DELETE from wp_posts where post_type="wanted";
DELETE from wp_posts where post_type="franchise";
DELETE from wp_posts where post_type="service_message";
DELETE from wp_posts where post_type="service_contract";
DELETE from wp_posts where post_type="service_request";
delete from wp_users where ID>8 AND ID!=36;
DELETE from wp_posts where post_type="listing";
update wp_users set user_login="EMAIL" where user_login="support@idealbiz.pt";
#copy from the base country
cp -r idealbiz.fr idealbiz.co.za
#create db
mysqladmin -u root -p create idealbiz_za
#dump fr db
mysqldump -u idealbiz_fr -p'<PASSWORD>' idealbiz_fr > idealbiz_fr_dump.sql
#create db user
#update wp-config-production.php with the mysql connection details
#import fr db
mysql -u idealbiz_za -p'<PASSWORD>' idealbiz_za < idealbiz_fr_dump.sql
#include /usr/local/bin to have wp-cli
export PATH=$PATH:/usr/local/bin
#search replace the fr url from the db
wp search-replace 'https://idealbiz.fr' 'https://idealbiz.co.za' --skip-columns=guid --allow-root
#clean up
rm idealbiz_fr_dump.sql
#fix permissions
cd /srv/
chown -R nginx.nginx idealbiz.co.za/
#
#nginx
#
cd /etc/nginx/sites-available
cp idealbiz.es idealbiz.co.za
vim idealbiz.co.za (search replace idealbiz.es idealbiz.co.za and comment with ## the SSL part)
/etc/nginx/sites-enabled
ln -s ../sites-available/idealbiz.co.za idealbiz.co.za
/etc/init.d/nginx configtest (should give syntax is ok - if NOT go back and make sure you commented all the SSL part)
#restart or reload
/etc/init.d/nginx restart
#add an entry in your local /etc/hosts to be able to test the website
#
# create DNS in Amazon's Route 53
#
#
# After domain is pointing to server generate the letsencrypt certificate
#
#
#letsencrypt
#
cd /opt/letsencrypt/
export PATH=$PATH:/opt/letsencrypt/venv27/bin
#make sure the root is correctly set in the nginx config file for this domain before running this
./letsencrypt-auto certonly -a webroot --agree-tos --renew-by-default --webroot-path=/srv/idealbiz.co.za --debug -d idealbiz.co.za -d www.idealbiz.co.za
#if you get ImportError: No module named cryptography
rm -rf ~/.local/share/letsencrypt
rm -rf /opt/eff.org/certbot/
./hacky.sh
cd /opt/eff.org/certbot/venv/lib64/python2.7
## drwxr-xr-x 9 root root 4096 Jul 18 14:14 dist-packages
## lrwxrwxrwx 1 root root 13 Jul 18 14:26 site-packages -> dist-packages (NAO ESQUECER ISTO)
##this seemed to work in the end
##rm -rf /opt/eff.org
#
# Request logo + flag and also individual flag images
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment