Tuesday 9 April 2019

How to host a WordPress Blog with in Amazon Linux by Raj Gupta

We assumes that we have launched an Amazon Linux instance with a functional web server with PHP and database (either MySQL or MariaDB) in other word we need a LAMP server.



Now we need to run the below command on Amazon Linux(LAMP server) to install WordPress:-

1. Download the latest WordPress installation package with the wget command.
[root@ip-172-31-81-1 ~]# wget https://wordpress.org/latest.tar.gz

2. Unzip and unarchive the installation package. The installation folder is unzipped to a folder called wordpress.
[root@ip-172-31-81-1 ~]# tar -xzf latest.tar.gz
[root@ip-172-31-81-1 ~]# ls
latest.tar.gz  wordpress


Our WordPress installation needs to store information, such as blog posts and user comments, in a database. Below procedure helps us create our blog's database and a user that is authorized to read and save information to it.

1. Start the database server.
[root@ip-172-31-81-1 ~]# sudo service mysqld start

2. Log in to the database server as the root user. Enter your database root password.
[root@ip-172-31-81-1 ~]# mysql -u root -p
Enter password:                       ------>in my case root password is raj123456, you enter your database root password.

3. Create a user and password for your MySQL database.
mysql> CREATE USER 'raj'@'localhost' IDENTIFIED BY 'raj1234';

4. Create your database
mysql> CREATE DATABASE `wordpress-db`;

5. Grant full privileges for your database to the WordPress user that you created earlier.
mysql> GRANT ALL PRIVILEGES ON `wordpress-db`.* TO "raj"@"localhost";

6. Flush the database privileges to pick up all of your changes. 
mysql> FLUSH PRIVILEGES;

7. Exit the mysql client.
mysql> exit


Now do the changes in WordPress file.

1. Copy the wp-config-sample.php file to a file called wp-config.php. This creates a new configuration file and keeps the original sample file intact as a backup.

[root@ip-172-31-81-1 ~]# cp wordpress/wp-config-sample.php wordpress/wp-config.php

2. Edit the wp-config.php file as per our database setting:-

[root@ip-172-31-81-1 ~]# vi wordpress/wp-config.php

a. Find the below line that defines DB_NAME,DB_USER and DB_PASSWORD change as per our values.

/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress-db' );

/** MySQL database username */
define( 'DB_USER', 'raj' );

/** MySQL database password */
define( 'DB_PASSWORD', 'raj1234' );
b. Find the section called Authentication Unique Keys and Salts in this file and update the key values.

Visit https://api.wordpress.org/secret-key/1.1/salt/ to randomly generate a set of key values that you can copy and paste into your wp-config.php file.

c. Save the file and exit your text editor.

To install your WordPress files under the Apache document root, copy the contents of the wordpress installation directory.

[root@ip-172-31-81-1 ~]# cp -r wordpress/* /var/www/html/


To allow WordPress to use permalinks
Find the section that starts with <Directory "/var/www/html">. in the file httpd.conf

[root@ip-172-31-81-1 ~]# sudo vi /etc/httpd/conf/httpd.conf

Change the AllowOverride = None to AllowOverride= All.

Now save it.

Now copy the public IP of server and past in the browser


Now our WordPress Blog are ready for use, Just fill above data click on install WordPress.
Then enter your Username and password what ever you have set in above picture. Then you will get below screen.


1 comment:

  1. wordpress maintenance perth
    Hire your own Wordpress engineer to look after maintenance, updates, security, page speed, adjustments, edits, and strategy advice.

    ReplyDelete