HanG321 Blog
Be Shine, Be Smile, Be Wild
  • Home
  • Blog
    • 好文閱讀 readings
    • 生活記事 diary
    • 時事評論 commentary
    • 科技資訊 technology
    • 電腦編程 programming
    • 金融財經 finance
    • 音樂電影 music/movie
  • About
Google Cloud Platform Compute Engine send email

Google Cloud Platform Compute Engine send email

October 8, 2017|GCP, wordpress|電腦編程

recently migrated wordpress to GCP, using cloud launcher – wordpress by bitnami.  That pretty easy, google other tutorials and follow it. e.g.

  • https://console.cloud.google.com/launcher/details/bitnami-launchpad/wordpress
  • http://www.compoundtheory.com/migrating-my-blog-to-google-cloud-platform/

 

Set up

here is some highlighted procedures

1. create compute engine via clound launcher

2. create cloud SQL
– db username and password

3. mysqldump old wordpress database

4. load into cloud SQL

5. change wordpress setting.
$ cd apps/wordpress/htdocs/

6. turn off mysql in bitnami image

1
2
sudo /opt/bitnami/ctlscript.sh stop mysql
sudo mv /opt/bitnami/mysql/scripts/ctl.sh /opt/bitnami/mysql/scripts/ctl.sh.disable

7. turn off banner

1
sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1

8. setup static IP for compute engine instance & cloud SQL
in cloud SQL, allow CE’s IP

9. change DNS, point to GCP

Issues

outgoing email

a bit weird, quite trouble to setup mailjet https://cloud.google.com/compute/docs/tutorials/sending-mail/
https://cloud.google.com/compute/docs/tutorials/sending-mail/using-mailjet

followed the instructions, yet those postfix setup, from fields is <username>@<hostname>, which MailJet will send a verification email to, and apparently it won’t be verified.
https://app.mailjet.com/account/sender

additional steps to modified the email address, so it passes the verification.
https://www.cyberciti.biz/tips/howto-postfix-masquerade-change-email-mail-address.html

Then, setup wordpress plug-in

https://docs.bitnami.com/google/apps/wordpress/#how-to-configure-outbound-email-settings

php-fpm CPU loading

unknown reason on high CPU usage. To restart php-fpm, or the HTTP server.

1
2
sudo /opt/bitnami/ctlscript.sh restart php-fpm
sudo /opt/bitnami/ctlscript.sh restart apache

 

Install macOS High Sierra on VMware

Install macOS High Sierra on VMware

July 24, 2017|High Sierra, macOS, VMware|科技資訊

more complicated than I thought, VMware Workstation patch and difficult to create ISO image.

1. macOS High Sierra 10.13 Beta 3

If you don’t have mac, you need to spend some time to find the source. check out  https://betas.cmacapps.com/ to find a suitable one.

Unzip the dmg file by 7zip, InstallESD.img & BaseSystem.dmg located in “macOS High Sierra Beta\Install macOS High Sierra Beta.app\Contents\SharedSupport”

In PowerShell, compare their SHA-1 checksum to https://github.com/notpeter/apple-installer-checksums

PowerShell
1
2
Get-FileHash -Algorithm SHA1 InstallESD.dmg
Get-FileHash -Algorithm SHA1 BaseSystem.dmg

2. convert DMG to ISO

unfortunately dmg2iso does not work, boot up failure. I only find people repack it on Mac OS. At the same time, I don’t like using third party vmdk image. So the work around is using 3rd party image to repack dmg to iso for vmware installation.

2.1 High Sierra vmdk image

follow the instructions and download vmdk from Google drive only. https://techsviewer.com/install-macos-high-sierra-vmware-windows/

next, download the tools to unlock vmware from https://github.com/DrDonk/unlocker. It provides python script to patch, yet unfortunately it does not work well in python3, after converted by 2to3.py, still have modules missing, print sytax and str on buffer API …etc

so just open command prompt with Admin right, then run win-install.cmd & win-update-tools.cmd , it will patch VMWare workstation for appleSMCTable about smc.version = 0 and smc.version = 1

After vmdk file downloaded, follow the installation instruction from the link above.

2.2 Bootable ISO image

After installation completed, upload InstallESD.img & BaseSystem.dmg to macOS vm. I had upload the whole SharedSupport folder.

Run the following script to create ISO file

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
## Create bootable ISO from HighSierra 10.13db3 (17A306f)
 
# Generate a BaseSystem.dmg with High Sierra Beta Installer Packages
hdiutil attach ~/SharedSupport/InstallESD.dmg -noverify -mountpoint /Volumes/highsierra
hdiutil create -o /tmp/HighSierraBase.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach /tmp/HighSierraBase.cdr.dmg -noverify -mountpoint /Volumes/install_build
asr restore -source ~/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
cp -R /Volumes/highsierra/Packages /Volumes/OS\ X\ Base\ System/System/Installation
hdiutil detach /Volumes/OS\ X\ Base\ System/
hdiutil detach /Volumes/highsierra/
mv /tmp/HighSierraBase.cdr.dmg /tmp/BaseSystem.dmg
 
# Restore the High Sierra Beta Installer's BaseSystem.dmg into file system and place custom BaseSystem.dmg into the root
hdiutil create -o /tmp/HighSierra.cdr -size 8965m -layout SPUD -fs HFS+J
hdiutil attach /tmp/HighSierra.cdr.dmg -noverify -mountpoint /Volumes/install_build
asr restore -source ~/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
cp /tmp/BaseSystem.dmg /Volumes/OS\ X\ Base\ System
rm /tmp/BaseSystem.dmg
 
hdiutil detach /Volumes/OS\ X\ Base\ System/
hdiutil convert /tmp/HighSierra.cdr.dmg -format UDTO -o /tmp/HighSierra.iso
mv /tmp/HighSierra.iso.cdr ~/HighSierraPublicBeta3.iso
rm /tmp/HighSierra.cdr.dmg

3. Configure another new VM

Just ordinary VM creation. After finish config, don’t start vm yet. edit the vmx file,
add smc.version = "0"  to the file. Then now start the VM.

select the ISO file created in step 2.2 as CD/DVD in virtual machine setting.

Once boot up, open Disk Utility, Erase the hard disk, format as “Mac OS Extended (Journaled)“. Although High Sierra has new APFS, I am unsure how well it goes with vmware at this stage.

macOS-Utilities

Finally, quit Disk Utility, and select “Reinstall macOS”, and follow the installation prompt.

After installation completed, dismount the CD-rom, and mount the darwin.iso which get from win-update-tools.cmd, to install VM-tools.

4. reference

Shell
1
2
3
4
5
https://github.com/notpeter/apple-installer-checksums#mac-osx-installers-sha1-checksums
https://github.com/DrDonk/unlocker
https://techsviewer.com/install-macos-high-sierra-vmware-windows/
https://gist.github.com/agentsim/00cc38c693e7d0e1b36a2080870d955b
http://www.wikigain.com/download-macos-high-sierra-free/
 

 

upload file on nginx – part 2: MySQL PAM and nginx config

upload file on nginx – part 2: MySQL PAM and nginx config

June 21, 2017|CentOS, Linux, nginx|科技資訊, 金融財經

MySQL PAM Config

set up database table and column name for username and password

# vim /etc/pam.d/nginx

Shell
1
2
3
4
5
6
7
8
9
10
11
12
auth required pam_mysql.so user=USERNAME_HERE \
  passwd=PASSWORD_HERE \
  host=HOSTNAME_HERE \
  db=DATABASE_HERE \
  table=TABLE_OR_VIEW_NAME_HERE \
  usercolumn=USERNAME_COLUMN \
  passwdcolumn=PASSWORD_COLUMN \
  crypt=0 sqllog=0
# repeat .... with config above
account required pam_mysql.so user=USERNAME_HERE \  ........    crypt=0 sqllog=0
# alternatively, to external config file
# account required pam_mysql.so config_file=/etc/pam_mysql.conf

 

in nginx config (/etc/nginx/nginx or /etc/nginx/conf.d/)

context.conf
Shell
1
2
3
4
location /restricted {
  auth_pam              "Restricted Zone"
  auth_pam_service_name "nginx"
}

 

Upload module config

in nginx config (/etc/nginx/nginx or /etc/nginx/conf.d/)

context.conf
Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
location /upload{
  auth_pam              "Restricted Zone"
  auth_pam_service_name "nginx"
 
  upload_pass  /uploadHandler.php;
  # the location where the files are uploaded
  upload_store  /var/tmp/fuploads;
  upload_store_access user:rw group:rw all:r;
  upload_resumable on;
  upload_state_store /var/tmp/fuploads/state ;
 
  # Set specified fields in request body
  # the field data will be available through the superglobal $_POST[]
  upload_set_form_field "${upload_field_name}_name" $upload_file_name;
  upload_set_form_field "${upload_field_name}_content_type" $upload_content_type;
  upload_set_form_field "${upload_field_name}_path" $upload_tmp_path;
 
  upload_cleanup 400 404 499 500-505;
}
 
# pass the PHP scripts to FastCGI server
location ~ \.php$ {
  try_files $uri =404;
  fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;
}

php file upload handler example can be found on https://github.com/blueimp/jQuery-File-Upload/wiki/Uploading-to-nginx-using-the-nginx-upload-module-with-php_handler and https://github.com/blueimp/jQuery-File-Upload/tree/master/server/php

...5678...30...

 

如果你喜歡我的文章,請幫忙按 1-10次 LikeButton 化讚為賞,非常感謝!越喜歡當然可以越按越多 😛

搜尋 Search

簡介 Bio

香港人,現居南十字星空下。

為人貪心,科技、生活、財經、散文 皆有興趣,周身刀冇張利。

思想矛盾,喜歡現在work-life balance 既生活又懷念a city never sleep。

 

每月送我一杯咖啡支持我: liker.land/hang321




分類 Categories

  • 好文閱讀
  • 時事評論
  • 未分類
  • 生活記事
  • 科技資訊
  • 金融財經
  • 電腦編程
  • 音樂電影

文章存檔 Archives




熱門文章 Popular Posts

  • Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8)
    Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8) June 8, 2015
  • 呢幾日個blogger 有問題….
    呢幾日個blogger 有問題…. October 28, 2004
  • assembly
    assembly February 11, 2006
  • 新工作
    新工作 January 6, 2009
  • 嫁人要嫁工程師
    嫁人要嫁工程師 April 27, 2006

標籤雲 Tag Cloud

CentOS Character chroot Cluster crash cryptography DD-WRT debug Domino DSM Dual Core DWA email ESXi GCP git google HylaFax IE Java Javascript JRE LikeCoin Linux log LotusScript mint MX MySQL nginx PKI PowerShell Qwiklabs srt telent VMware vpn vSphere WinXP wordpress XPEnology 專欄 網絡資訊 選股 風帆

日曆 Calendar

June 2025
M T W T F S S
  « Feb    
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Follow Me

Follow Us on RSSFollow Us on TwitterFollow Us on YouTube

文章存檔 Archives

Copyright © 2004-2021 hang321.net. All Rights Reserved