Build My Blog

TODO List

Main reference: Build website using WordPress

  • Buy VPS
  • Register a domain (recommend: .com)
  • Set up LNMP in VPS
  • Build your website

1. Buy Hostwinds VPS

Don’t know how to choose Virtual Hosting (Shared Hosting) or Virtual Private Server? Please check the reference blog.

Here I choose Hostwinds VPS because I have multiple uses. 

The detailed guide of buying steps and problems you may have are here

Problems:

  • Can’t finish payment via Alipay.
    Solution:
    Use Credit Card.
  • IP is blocked.
    Solution:
    1. Make sure account region is set as China. (Only China can change IP for free.)
    2. VPS CMS -> Manage IP’s -> Fix ISP Block –>> Confirm

2. Buy & Register Domain in Namesilo

When waiting installation: Set up your domain name

2.1 Buy

  1. Sign Up (Make sure activate account via email)
  2. Choose a Domain
  3. Finish payment (Pay attention to Renew Privacy)

2.2 Register

  1. Enter Domain Manager tag
  2. Remove the existing record
  3. Create two new A record

Done! Just need to wait for update.

3.Connect VPS via SSH & Download FileZilla

Mac OS is very simple:
$ ssh root@vpsip

Security Settings

  • For security reason, change SSH port: 22 -> 3752

    After modification, connect command is:
    $ ssh -p portnum root@ip 
  • Remove those two lines to enable longer login duration.
$ vi /etc/ssh/sshd_config 
$ service sshd restart (Redirect to) 
$ systemctl restart sshd.service 
  • Update system
    Make sure all software/kernel are updated.
    $ yum -y update 
    

Connect VPS via FileZilla

In order to transfer files between local computer and cloud server.

4.Install LNMP on VPS

Install LNMP in one step. Detailed steps can be found here.
In this tutorial, install lnmp1.6 version. 

1. Download Installation Package

Use the following command to install.

$ wget http://soft.vpser.net/lnmp/lnmp1.6.tar.gz -cO lnmp1.6.tar.gz && tar zxf lnmp1.6.tar.gz && cd lnmp1.6 && ./install.sh lnmp

2. Install Procedures

MySQL 5.5.60 (Default)

  1. MySQL 5.6,5.7 and MariaDB 10 require > 1G RAM. Input your version number and press enter.
  2. Enter your database password.
  3. Enable InnoDB.

PHP 7.2.18 (Default is PHP 5.6.40)

  1. Recommend PHP 7 version. (Will end support PHP 5. More info here ).

Press any key to continue… Enter and wait.

Problems:

  1. Nginx and MySQL are stopped. Can’t restart.

    Solution:
  • Check error log first.
  • Edit the /etc/my.cnf file.
  • Then restart service to see if successes.

Here is the related problem.

$ vi /etc/my.cnf
// modify dist of socket
socket  = /var/lib/mysql/mysql.sock

Done! LNMP installed successfully!

5.Install WordPress

Prerequisite
Install eAccelerator and memcached to improve PHP speed.
Here we install OPcache and Memcached.

$cd /root/lnmp1.6
$./addons.sh install opcache
// select 2: php-memcached
$./addons.sh install memcached 

5.1 Add virtual host

lnmp add has many functions, like add/edit/del.

$ lnmp vhost add

5.2 Add SSL/HTTPS

Oops! Haven’t finished yet. Will update soon or later.

Problems:

  1. can’t start MySQL
    Solution
  2. can’t start LNMP & open www.miawy.com

    When successfully start LNMP:
  3. Sth wrong when connecting database:
    Failed to create database.
  4. PHP error 
// error.log is in php-fpm.log  
/usr/local/php/var/log/php-fpm.log  
// error.log setting is in php-fpm.conf  
/usr/local/php/etc/php-fpm.conf

Remember to clear logs regularly!

6.Move HTTP to HTTPS

This is the Tutorial.

Can’t connect MySQL because the connect command!! Higher than PHP7.0 should use mysqlicommand!