舊年係GCP用”WordPress Certified by Bitnami”,原來佢地個個Base Image 係Debian 8. 上兩個月收到通知要更新,今個weekend趁住有時間順便一次過upgrade。今次會試下”Nginx WordPress with NGINX and SSL Certified by Bitnami“,睇下用Nginx會唔會快過Apache。 1. New VM 首先登入GCP,左上角Menu > MarketPlace,然後搜尋 WordPress,再揀Nginx WordPress with NGINX and SSL Certified by Bitnami,按Launch on Compute Engine button。 因為Free Tier 嘅關係,記住要揀係美國嘅region,同 f1-micro instance. Disk size 30GB 以下就得, 我自己用15GB. info: https://cloud.google.com/compute/pricing#freeusage 2. Backup 等緊個VM create嘅時候,可以就係用緊嘅WordPress 做 Backup。Install “All-in-One WP Migration” plugin, Export everything. 詳細資料:https://docs.bitnami.com/aws/how-to/migrate-wordpress/,Backup 完然後power off 3. Migrate 個新VM 起好之後,In VPC network > External IP address,這個舊嘅static IP 轉去新 VM 到,然後ssh to new VM, restart all services
1 |
sudo /opt/bitnami/ctlscript.sh restart |
再登入新WordPress,check 返site setting同user email address ,如果係 IP address 就改番做Domain name。 終於係時候Import返 data: All-in-One WP Migration > Import,upload the backup file. Disable bitnami logo:
1 2 |
sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1 sudo /opt/bitnami/ctlscript.sh restart nginx |
搞掂。 當一切安好之後,就可以Delete 舊VM & snapshot。 (Optional 1) 用Let’s encrypt & Cloudflare SSL strict mode: 一直用開 Cloudflare 免費CDN & FleixSSL,而家用 Lets encrtpy 其實可以唔使用 Cloudflare SSL, 不過費事大搞, 轉做strict mode 算. in ssh shell:
1 |
sudo /opt/bitnami/letsencrypt/scripts/generate-certificate.sh -m YOURMAIL -d YOURDOMAIN -d www.YOURDOMAIN |
我揀左 Yes 但係個crontab 都係冇野,要手動加返上去。
1 2 3 |
crontab -e 0 0 1 * * sudo /opt/bitnami/letsencrypt/lego --path="/opt/bitnami/letsencrypt" --email="YOURMAIL" --domains="YOURDOMAIN" renew && sudo /opt/bitnami/nginx/sbin/nginx -s reload |
(Optional 2) redirect HTTP to HTTPS in nginx 如果唔用 Cloudflare redirect,可以係Nginx 做,改 server_name 同埋加 301 :
1 2 3 4 5 6 7 |
server_name hang321.net www.hang321.net if ($http_x_forwarded_proto = "http") { return 301 https://$server_name$request_uri; } ..... server_name hang321.net www.hang321.net |
Reference: https://docs.bitnami.com/aws/how-to/migrate-wordpress/ https://docs.bitnami.com/general/apps/wordpress-pro https://support.cloudflare.com/hc/en-us/articles/200170416-What-do-the-SSL-options-mean-
昨天是澳洲的父親節,九月第一個星期日。與大部份國家不同,不是在六月的第三個星期日。選擇在九月慶祝父親節,或多或少是因為九月是南半球的春天開始,一般澳洲家庭都會以BBQ 方式慶祝,六月的日照時間太短,天氣比較凍又早天黑。而且九月又可以避免與母親節的時間相距太近,減少家庭開支,小朋友又不需要在短時間內做兩次手工 😛
原本諗住加個WordPress Plugin 呃吓like coin,等將來可以用黎派like。點知原來個website係會俾人登出嚟 😛 咁唯有整番個website靚仔小小啦。 呢個site 係GCP free tier (每個月$0.x egress only, 爽啊),原本個Base image 係 Debian 8,上個月discontinue support, 所以要更新到 Debian 9. 今次就試下由Apache轉去Nginx,睇下Performance 會唔會有改善。技術文下次再寫。 更新完 Compute Engine VM, WordPress, Themes, Plugin … etc, 奇怪個主頁顯示唔到LikeCoin Widget, 最後發現原來係個Theme Home Page setting 嘅問題,唔係page又唔係post type。然後就去睇下個widget 其實係 iframe, 咁我自己加返條Link就會出到。 https://button.like.co/in/embed/<YOUR_USERNAME>/button?referrer=https%3A%2F%2F<YOUR_DOMAINNAME>
1 2 3 |
[blog count="3" imageType="left" full="true" nopaging="false"] [iframe src="https://button.like.co/in/embed/hang321/button?referrer=https%3A%2F%2Fwww.hang321.net" width="100%" height="212"] |