setup https for wordpress with docker

1. install docker-ce

https://docs.docker.com/install/linux/docker-ce/debian/

2. install docker-compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

3. setup domain name, and link it to the node you are setting up your web server; install letsencrypt on the webserver

git clone https://github.com/certbot/certbot.git
cd certbot
sudo -H ./letsencrypt-auto certonly --standalone -d jianping-lai.com -d www.jianping-lai.com --email tbjc1magic@gmail.com
https://www.linode.com/docs/security/ssl/install-lets-encrypt-to-create-ssl-certificates/

4. install wordpress using docker with the docker-compose.yml below
https://docs.docker.com/compose/wordpress/; and do “sudo docker-compose up -d”

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "80:80"
       - "443:443"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}

5. after start the wordpress docker container,

mkdir -p blog/etc sudo docker cp wordpress_wordpress_1:/etc/apache2 ~/blog/etc/

6. login to the wordpress docker container and do following

a2enmod ssl
service apache2 restart

7. shutdown the container and put the letsencrypt key and certificate combo to the ~/blog/etc/apache2 folder

cd ~/blog/etc/apache2/sites-enabled
sudo cp /etc/letsencrypt/live/jianping-lai.com/*.pem .
sudo ln -s ../sites-available/default-ssl.conf .
# modify the following two lines of default-ssl.conf
SSLCertificateFile      /etc/apache2/sites-enable/fullchain.pem
SSLCertificateKeyFile /etc/apache2/sites-enabled/privkey.pem
cd ~/blog/etc/apache2/mods-enabled
sudo ln -s ../mods-available/socache_shmcb.load .

8. modify the docker-compose.yml file add the following two lines

volumes:
    - /home/tbjc1magic/blog/etc/apache2:/etc/apache2

9. start docker containers again and turn on the ssl redirect plugin

sudo docker-compose up -d


Multiprocessing 1

I have been using python multiprocessing for quite a bit time, but it was all simple pool and I would like to understand deeper than just blindly using the multiprocessing package.

  1. given a list of word and start two process to print out the list in sequence

The same functionality can also be achieved using pipe

Google Compute Engine enable ssh using password

Find Nearest K points

Efficiently find nearest points KD tree

The basic idea is illustrated here

k-d Tree and Nearest Neighbor Search

though I don’t think the pruned areas are plotted correctly.

This algorithms are used for KNN

Similar tree structure quad-tree/octree are explained here

https://www.quora.com/What-is-the-difference-between-kd-tree-and-octree-Which-one-is-advantageous