Category Archives: Technologies

How to add multiple IPs to an Amazon EC2 virtual machine


You have a Server 2008 R2 machine on Amazon EC2.

You want to secure multiple domains using different  SSL/TLS certificates.

Server 2008 R2 does not support Server Name Indication (SNI). Therefore you need to add multiple IPs to the machine to use different SSL/TLS certificates.

  1. Create an EC2 virtual machine.
  2. Create an EC2 network interface.
  3. Assign the network interface to the machine using the Attach feature in the Network Interfaces tab.
  4. Create multiple private IPs for the network interface using Manage IP Addresses feature.
  5. Allocate multiple elastic IPs in the Elastic IPs tab.
  6. Assign an elastic IP to a private IP of the network interface using the Associate Address feature in the Elastic IPs tab.
  7. Login Windows.
  8. View the network configuration using below command.
ipconfig /all

9. Manually configure the network adapter (Local Area Connection Network) using the information in the 8th step.

10. Add the private IPs in the 4th step to the machine in the Advanced TCP/IP Settings screen.

11. Restart the machine.

If you get any issue then try limit the number of private IPs of a network interface to 4 (including the default private IP)

How to move a WordPress instance from one server to another Linux server


You want to move a WordPress instance from one server to another to consolidate your websites to reduce cost.


Install and use below Duplicator plugin to achieve your goal.

User guide:

If everything goes well for you then congratulation!

Otherwise, please review below possible problems and corresponding solutions.

Problem 1:

You don’t have a website on the new server.

Solution 1:

1. Create a new virtual host in the /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
DocumentRoot "/var/www/"

2. Set 775 permission for /var/www/

3. Restart httpd service

sudo systemctl restart httpd

Problem 2:

You are using Amazon Linux 2 server.

You are logged in as ec2-user.

You use WinSCP to upload files and edit configuration files.

You cannot modify /etc/httpd/conf/httpd.conf and /etc/php.ini.

Solution 2:

1 View permission settings for the file

ls -ld /etc/httpd/conf/httpd.conf

The result indicates that the file owner is root user and root group, not ec2-user.

2. View groups of a user

groups ec2-user

The result indicates that the ec2-user does not belong to root group.

3. Add a user to root group

sudo usermod -a -G root ec2-user

4. Grant Read-Write permission against a file to root group

sudo chmod g+rwx /etc/httpd/conf/httpd.conf
sudo chmod g+rwx /etc/php.ini

5. Logout and login to the server again.

Problem 3:

You are using Amazon Linux 2 server. The ZipArchive feature is missing.

Solution 3:

1. Execute below commands:

sudo amazon-linux-extras install php7.2
sudo yum install php-pear php-devel gcc libzip-devel zlib-devel
sudo pecl install zip-1.13.5 # we must specify a slightly older version due due to compatibility

2. Add “” to /etc/php.ini

3. Restart the server

sudo reboot

Problem 4:

You don’t have a WordPress database on the new Linux server.

Solution 4:

Execute below MySQL commands:

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE `wp_database`;
GRANT ALL PRIVILEGES ON `wp_database`.* TO "username"@"localhost";

Problem 5:

An database error occurs while restoring a website.

Solution 5:

1. Execute below commands to remove the website:

sudo chown -R ec2-user:apache /var/www/
sudo chmod 2775 /var/www/ && find /var/www/ -type d -exec sudo chmod 2775 {} \;
find /var/www/ -type f -exec sudo chmod 0664 {} \;
rm -r /var/www/

2. Upload the Duplicator files again, and restore the website again.

Problem 6:

No write access against /var/www/ is available for Duplicator.

Solution 6:

1. Execute below commands:

sudo chown -R ec2-user:apache /var/www/
sudo chmod 2775 /var/www/ && find /var/www/ -type d -exec sudo chmod 2775 {} \;
find /var/www/ -type f -exec sudo chmod 0664 {} \;

2. Run again.

How to completely uninstall Python on Mac OS?


You have an issue with a Python version (e.g. the 3.7 version) and want to install another version (e.g. the 3.6 version). In order to install a fresh version you need to uninstall the current version first.


Assume that the current version is 3.7. Replace 3.7 with another version that you installed.

Follow these 3 steps below.

1. Remove the third-party Python 3.7 framework

sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.7

2. Remove the Python 3.7 applications directory

sudo rm -rf "/Applications/Python 3.7"

3. Remove the symbolic links, in /usr/local/bin, that point to this Python version. Ensure that the links exit using below command.

ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.7'

and then run the following command to remove all the links:

cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.7' | awk '{print $9}' | tr -d @ | xargs rm


Installing a new version:

  1. Download a version from, double click the file and follow the instructions.
  2. Verify installation: python3 –version
  3. Install Homebrew from
  4. Install virtualenv
  5. pip3 install virtualenv
    pip3 install virtualenvwrapper

5.  Create and activate a virtual environment

cd /Users/admin/Downloads/training_model/model 
python3 -m virtualenv /Users/admin/Downloads/training_model/model
source bin/activate

Setting File Permissions for WordPress on IIS


  • You have a WordPress instance in Windows with IIS.
  • You upload a file. Its thumbnail is not shown in Media Library.
  • You change the file permission. Its thumbnail now is shown correctly in Media Library.
  • You upload another file and have to change the file permission manually again.
  • How can we make WordPress automatically set the correct permission for new uploaded files?


  1. Ensure that the the Identity of Application pool that the website is running under is ApplicationPoolIdentity.
  2. Execute below commands as Administrator
icacls "C:\inetpub\wwwroot\" /grant "IUSR":(OI)(CI)F /T
icacls "C:\inetpub\wwwroot\" /grant "IIS_IUSRS":(OI)(CI)F /T

3. Open IIS Manager, click on your website, click Authentication, click Anonymous Authentication (which should be the only one enabled), click Edit, select Application pool identity if it is not selected, click OK.

How to change a WordPress website’s domain name?
  • Open the wp-config.php file.
  • Add two lines to the file, right before /* That’s all, stop editing! Happy blogging. */:
  • Bulk edit the posts content if needed.

How to change language of an EPUB file

Problem: Sometimes you have an EPUB file encoded with a wrong language tag.
Therefore when you use the Read aloud feature of the Google Play Books application the book is read aloud in a wrong language.


  1. Download the EPUB file to a PC.
  2. Change the extension from EPUB to ZIP.
  3. Open the .ZIP file.
  4. Open the content.opf file using the Notepad app.
  5. If you cannot file this content.opf file then please navigate to the OEBPS folder.
  6. Find the tag <dc:language> and change its value (e.g. from <dc:language>en</dc:language>to <dc:language>vi</dc:language>).
  7. If you cannot find the tag <dc:language> then just add a new tag right above the </metadata> tag (e.g.
  8. Save the content.opf file and rezip the EPUB file.
  9. Change the file extension from ZIP to EPUB.

How To Manually Install PHP 7.1 for Windows Server 2016


To understand how PHP works with IIS in order to be able to update PHP to any version to address compatibility or security issues.

Using a tool to install PHP for IIS, for example Microsoft Web Platform Installer 5.0, restricts us from using only versions supported by the tool.


  • Install CGI for IIS.
  • Download VC14 x86 Non Thread Safe under PHP 7.1 section from
  • Extract the ZIP file to C:\Program Files\php-7.1.15-nts-Win32-VC14-x86 folder.
  • Rename the php-.ini-development file to php.ini.
  • Open the php.ini file and add the following line at the end of the file.
  • Uncomment the following lines
fastcgi.impersonate = 1;

cgi.force_redirect = 1 (and change the value to 0, i.e. cgi.force_redirect = 0)

extension_dir = "C:\Program Files\php-7.1.15-nts-Win32-VC14-x86\ext"


error_log = "C:\Program Files\php-7.1.15-nts-Win32-VC14-x86\php_errors.log"

error_log = syslog
  • Add C:\Program Files\php-7.1.15-nts-Win32-VC14-x86 to System Path.
  • Download x86 package of WinCache 2.0 for PHP 7.1  from
  • Extract and copy the php.wincache.dll file to C:\Program Files\php-7.1.15-nts-Win32-VC14-x86\ext
  • Open IIS, click on Server name, double click on Handler Mappings > Add Module Mapping with below information
Request path = *.php
Module = FastCgiModule
Executable = "C:\Program Files\php-7.1.15-nts-Win32-VC14-x86\php-cgi.exe", Name = PHP7.1
Request Restrictions = File or folder

Open a Command Prompt, execute below command and ensure that no warnings appear.

php -version

Turning Hyper-V On and Off

Issue: Hyper-V cannot work in parallel with Android Studio emulator.


Use below steps to temporarily turn it off to launch Android Studio emulator:
  1. Open a Command or PowerShell as Admin
  2. Execute below command to turn Hyper-V off
bcdedit /set hypervisorlaunchtype off

3. Restart your computer.

To turn Hyper-V on again, use below steps:
  1. Open a Command or PowerShell as Admin
  2. Execute below command to turn Hyper-V off
bcdedit /set hypervisorlaunchtype auto start

3. Restart your computer.

Using Let’s Encrypt with IIS on Windows


Why use an SSL/TLS certificate to secure your website?

1. To protect your website users from man-in-the-middle attacks.
2. To ensure the integrity of the data being sent to your website.

Why use Let’s Encrypt SSL/TLS certificate?

It's FREE.

Tested environment:

  1. Windows Server 2016/IIS 10
  2. win-acme.v2.0.7.315


  1. Log in a Windows server.
  2. Download lets-encrypt-winsimple client
  3. Unzip the files to C:\inetpub\win-acme.v2.0.7.315
  4. Open cmd.exe as Administrator and cd to C:\inetpub\win-acme.v2.0.7.315
  5. Type wacs.exe and press Enter
  6. Follow the instructions. Please select 5: Manually input host names if you want to secure both naked domain and www domain.
  7. Open Task Scheduler and ensure that a task with description “Check for renewal of ACME certificates.” has been created.
  8. Open Firewall port 443 if needed.
  9. Open the selected site using HTTPS protocol.

Redirecting HTTP to HTTPS in IIS7:

  1. Install the Microsoft URL Rewrite Module if needed.
  2. Make sure Require SSL is NOT checked under SSL Settings for your website.
  3. Copy and paste the following code between the <rules> and </rules> tags in your web.config file in your website root directory.
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
  <match url="(.*)" />
      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
  <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />

4. Open your site using HTTP protocol and ensure that you are redirected to the HTTPS site.

Multiple SSL Certificates per IP Address

  1. You have to use Server 2012 IIS to support Server Name Indication (SNI) which allows you to bind multiple SSL certificates to a single IP Address.
  2. Please repeat the Procedure for each site, then go to the IIS site, Bindings and ensure that the check box Require Server Name Indication is selected and the corresponding SSL Certificate is selected.
  3. Please be noted that SNI does not work with Windows XP clients.

How to completely uninstall Android Studio on Mac OS?


You have an issue with Android Studio and want to reinstall it. In order to reinstall a fresh instance you need to uninstall the current version first.


Execute these commands from the terminal:

rm -Rf /Applications/Android\
rm -Rf ~/Library/Preferences/AndroidStudio*
rm ~/Library/Preferences/
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
rm -Rf ~/Library/Caches/AndroidStudio*
rm -Rf ~/.AndroidStudio*

if you would like to delete all projects:

rm -Rf ~/AndroidStudioProjects

to remove gradle related files (caches & wrapper)

rm -Rf ~/.gradle

use the below command to delete all Android Virtual Devices(AVDs) and *.keystore. note: this folder is used by others Android IDE as well, so if you still using other IDE you may not want to delete this folder)

rm -Rf ~/.android

to delete Android SDK tools

rm -Rf ~/Library/Android*


How do we make an image look darker using Photoshop?

How do we make an image look darker using Photoshop?

  • Use Ctrl+J to duplicate the image layer
  • Click on the top layer and change the blend mode to either Multiply or Overlay
  • Go to Image > Adjustments > Levels
  • Adjust the middle node (sliding right makes darker image, sliding left makes lighter image) till you get your desired outcome.

How do we change a layer’s opacity?

  • Right click a layer > Blending Options…
  • Change the Opacity value

How do we straighten a photo (transform perspective while cropping)?

  • Hold down the Crop tool and select the Perspective Crop tool
  • Draw a marquee around the distorted object. Match the edges of the marquee to the rectangular edges of the object.
  • Press Enter (Windows) or Return (Mac OS) to complete the perspective crop.

How do we crop a photo with 4×6 ratio?

  • Hold down the Crop tool and select the 2:3 (4:6) from the drop down box on the top panel.
  • Resize the grid to appropriate size.
  • Right click on the image and select Crop.

How do we horizontally straighten a photo?

  • Hold down the Ruler tool and draw a line as the new horizontal.
  • Click Straighten Layer on the top panel.