Tutorial: How to install wordpress on AWS EC2 t2.micro instance ? Charpter-2

Charpter 2: How to install a LAMP Web Server on Amazon Linux

Now, we will install Apache + MySQL + PHP on AWS EC2 t2.micro AMI.

(Clicker here to see Charpter 1: how to install AWS EC2 t2.micro AMI)

1.Connect to AWS EC2 t2.micro AMI Using PuTTY

(a) Download & Install PuTTY on windows

Download URL: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

(b) After installing PuTTY successfully, start PuTTYGen to generate key file.

Under Type of key to generate, select SSH-2 RSA

Type of key to generate
Type of key to generate

(c) Click Load. By default, PuTTYgen displays only files with the extension .ppk. To locate your .pem file, select the option to display files of all types.

PS: How to generate .pem file?

In previous tutorial‘s step 7. Review Instance Launch, you have downloaded a .pem file after launching the instance.

Or you can create a new .pem file as below steps:

(1) Sign in to AWS and open the Amazon EC2 console.

(2) From the navigation bar, select a region which your AMI located for the key pair.

           Select EC2 Region

(3) Click NETWORK & SECURITY > Key Pairs in the left navigation pane.

(4) Click Create Key Pair button.

(5) Enter a new key pair name in the Key pair name field of the Create Key Pair dialog box, and then click Create.

(6) The private key file is automatically downloaded by your browser. The base file name is the name you specified as the name of your key pair, and the file name extension is .pem. Save the private key file in a safe place.

(d) Select the private key .pem file that you created in the previous step and click Open. Click OK.

(e) Click Save private key. PuTTYgen displays a warning about saving the key without a passphrase. Click Yes.

(f) Specify the same name for the key that you used for the key pair. PuTTY automatically adds the .ppk file extension.

(g) Start PuTTY

Config PuTTY Session

  • Select Session and input the following fields:

(i) In the Host Name box, enter [email protected]_dns_name.

You can find your public_dns_name from Amazon EC2 consoleInstance Public DNS

(ii) Under Connection type, select SSH.

(iii) Ensure that Port is 22.

  •  Next select Connection, expand SSH, and then select Auth. Complete the following:

(i) Click Browse.

(ii) Select the .ppk file that you generated for your key pair, and then click Open.

(iii) Click Open to start the PuTTY session.

Select auth ppk file
Select auth ppk file

 (iv) If this is the first time you have connected to this instance, PuTTY displays a security alert dialog box that asks whether you trust the host you are connecting to. Click Yes. A window opens and you are connected to your instance.

2. Install “Web Server”, “MySQL Database” and “PHP Support”

(a) To update all software packages

(b) install the Apache web server, MySQL, and PHP software packages

After installation finish, you can check it like below:

(c) Install the php-mysql package

(d) Start web server

(e) Set apache to  start at each system boot.

Check the configure:

Then open the web browser to test http://your_instance_public_ip

 

Next Charpter: How to install wordpress on AWS EC2 t2.micro instance

 

Bookmark/Favorites

Tutorial: How to install wordpress on AWS EC2 t2.micro instance ? Charpter-3

Charpter-3: How to install wordpress on AWS EC2 t2.micro instance

This is the last charpter to introduce “How to install wordpress on AWS EC2 t2.micro instance”. You can click the links below to review the previous charpters:

To download and unzip wordpress
  1. Download latest WordPress installation package with the wget command.

     
  2. Unzip WordPress installation package.
To create a MySQL user and database for WordPress
  1. Start Mysql Server

     
  2. Login to the MySQL server as the root user

     
  3. Create wordpress database

     
  4. Create a user and password for your MySQL database.

     
  5. Grant full privileges for your wordpress database to the user you created earlier.

     
  6. Flush the MySQL privileges to pick up all of your changes.

    Exit the mysql client.

     
  7. To create and edit the wp-config.php file

    To modify the fields in wp-config.php below

    Save the file and exit your text editor.
To move your WordPress installation to the Apache document root

By default Apache document root is “/var/www/html” , move the WordPress installation to the Apache document root

At last open the browser, enter the URL (you can find the the public DNS address for your instance from Amazon EC2 Management Console > Instances Page)

Congratulations, you should now be able to log into your WordPress blog and start posting entries.

 

Bookmark/Favorites

[Shell Code] How to kill a process using pid in Linux shell?

 

Bookmark/Favorites

How to enable shadowsocks server to support multiple users?

We can use a config file instead of command line arguments to enable multiple users to connect server with different port.

Below is detail steps:

  1. Create a config file /etc/shadowsocks.json. Example:

     
  2. Start/Stop shadowsocks server

     

Notice: ONLY some version shadowsocks server version support multiple users, please check the refence below:

[Reference] https://github.com/shadowsocks/shadowsocks/wiki/Feature-Comparison-across-Different-Versions

 

After shadowsocks server start up, we can use the command line to check who is online:

Then you will get the port number and client ip like below

 

 

[Reference]:

Bookmark/Favorites

How to install Shadowsocks on Amazon EC2 AMI

  1. Confirm python version 


    so we need to install PIP [python 2.7.9 and later (on the python2 series), and Python 3.4 and later include pip by default ]
  2. Install PIP 

  3. Install Shadowsocks 


     
  4. Config Shadowsocks Server


    Add these two lines below

    Then tune the kernel parameters

    Add these lines below  (example)

    Start Shadowsocks Server

    To start shadowssocks server (example)

    To stop shadowssocks server (example)

     
Bookmark/Favorites

How to setup PPTP VPN server on Amazon EC2 Linux?

This blog is about how to set up PPTP VPN server on Amazon EC2 instance (AMI Linux)

  1. Install PPTP server

    Install 32 bit version

    Install 64 bit version

    [Reference http://poptop.sourceforge.net/dox/redhat-howto.phtml

  2. Edit /etc/pptpd.conf 

    This is an example of /etc/pptpd.conf

    logwtmp means that you can use last command to check who has logged in VPN server from /var/log/wtmp

    remoteip means that vpn client IP will be assigned from 172.28.29.196 to 172.28.29.210 when connect to VPN server.

  3. Edit /etc/ppp/options.pptpd

    Please input below :

    You also can change the dns to your ISP’s DNS.

  4. Manage VPN client account 

    Please input your client account, for example

    P.S. It seems that the password can not contain#‘. And you can add account without restart pptpd service.

  5. Edit /etc/sysctl.conf 

    To find net.ipv4.ip_forward and modify it as below: 

    Save it & exist. Then excute the command to reload sysctl.conf :

     

  6.  Configure the IPTABLES

    This setting will be reset on reboot, so please add the above command line to file /etc/rc.local 

  7. Configure Amazone EC2 instance security group to open 1723 port

    Login in AWS EC2 Management Console  >  Security Groups > Edit inbound rules

    Open 1723 port
    Open 1723 port
  8. Start PPTP VPN  service

     

 

 

Bookmark/Favorites

How to resovle the error “runtime/win32/PrebuiltRuntimeJs.exe can’t run normally” in win7?

Developement Enviroment:

  • OS: windows 7
  • Framework: Cocos2d-JS v3.6.1
  • IDE: Cocos Code IDE v2.0.0
  • Java: jdk-8u45-windows
  • Ant: apache-ant-1.9.6
  • Python: python-2.7.10
  • Android NDK: android-ndk-r10e
  • Android SDK: android-sdk_r24.3.3

When run the cocos2d-JS sample project, I got the errorRuntime D:\your_cocos2d-js_project\runtime/win32/PrebuiltRuntimeJs.exe can’t run normally.

 

I have done some test like below:

Goto find runtime/win32/PrebuiltRuntimeJs.exe and excute the file as administrator, I got missing MSVCP110.dll error.

 

Then how to resolve:

Download VC2012 runtime redistributable and install it. Then, run the cocos2d-JS sample project again, the simulator showed.

Bookmark/Favorites

How to disable DST (Daylight Saving Time) in Linux

As you know, Europe area has daylight saving time (summer time). DST will change the Linux server’s time automatically, so some system will become stranger under DST.

Here is an example to change Europe/London time to UTC time (because there is no DST in UTC time) to disable the DST.

  1. Confirm the system date

     
  2. Modify /etc/sysconfig/clock 

    Before modify

     
  3.  Backup localtime file

     
  4. Just link/copy the one you need to /etc/localtime

    P.S. If you want set the time as GMT+0/GMT-8 (etc.):

     
  5. Confirm system date again

     
  6. After the server reboot, system will read the hardware clock to set system time automatically, so we need write the system time to CMOS/BIOS hardware clock after changing the system time.

    Confirm the hwclock time

    The CMOS/BIOS hardware clock is same as system time
Bookmark/Favorites

MySQL Error 1017 (HY000): Can’t find file

Problem:

When run mysql command “show tables”, I got the error

But in fact the file xxxxx.frm really exists on the mysql data directory, how to resolve the problem.

Solutions:

I have do some research and find that there are 2 tips to resolve the problem:

  1. Check file permission

    Make sure that your MySQL data directory and all the files in it are owned by mysql user and mysql group.
  2. Repair corrupted tables

    Use mysqlcheck to check for corrupted tables and repair them if it finds any.

If you still cannot use the tables, perhapes you need run mysqldump to export and re-import the tables again.

Bookmark/Favorites

How to configure Centos Network from command line

  1. Check network status

    The server has two network interfaces eth0 and eth1 (exclude lo), but only eth0 is enabled
  2. Enable eth1

    Save ifcfg-eth1 
  3. Restart the network

     
  4. Confirm the network

     
Bookmark/Favorites