Install WordPress On Amazon Server
We all know allowing WordPress to work on amazon server is not an easy job.This tutorial assumes that you have launched an Amazon Linux instance with a functional web server with PHP and MySQL support.
To download and unzip the WordPress installation package
1.Download the latest WordPress installation package with the wget command. The following command should always download the latest release.
1 2 3 4 5 6 7 8 9 10 11 |
[ec2-user ~]$ wget https://wordpress.org/latest.tar.gz --2013-08-09 17:19:01-- https://wordpress.org/latest.tar.gz Resolving wordpress.org (wordpress.org)... 66.155.40.249, 66.155.40.250 Connecting to wordpress.org (wordpress.org)|66.155.40.249|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 4028740 (3.8M) [application/x-gzip] Saving to: latest.tar.gz 100%[======================================>] 4,028,740 20.1MB/s in 0.2s 2013-08-09 17:19:02 (20.1 MB/s) - latest.tar.gz saved [4028740/4028740] |
2.Unzip and unarchive the installation package. The installation folder is unzipped to a folder called wordpress.
1 2 3 |
[ec2-user ~]$ tar -xzf latest.tar.gz [ec2-user ~]$ ls latest.tar.gz wordpress |
To create a MySQL user and database for your WordPress installation
1.Start the MySQL server.
1 |
[ec2-user ~]$ sudo service mysqld start |
2.Log in to the MySQL server as the root user. Enter your MySQL root password when prompted; this may be different than your root system password, or it may even be empty if you have not secured your MySQL server.
1 2 |
[ec2-user ~]$ mysql -u root -p Enter password: |
3.Create a user and password for your MySQL database. Your WordPress installation uses these values to communicate with your MySQL database. Enter the following command, substituting a unique user name and password.
1 2 |
mysql> CREATE USER 'wordpress-user'@'localhost' IDENTIFIED BY 'your_strong_password'; Query OK, 0 rows affected (0.00 sec) |
4.Create your database. Give your database a descriptive, meaningful name, such as wordpress-db.
1 2 |
mysql> CREATE DATABASE `wordpress-db`; Query OK, 1 row affected (0.01 sec) |
5.Grant full privileges for your database to the WordPress user that you created earlier.
1 2 |
mysql> GRANT ALL PRIVILEGES ON `wordpress-db`.* TO "wordpress-user"@"localhost"; Query OK, 0 rows affected (0.00 sec) |
6.Flush the MySQL privileges to pick up all of your changes.
1 2 |
mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.01 sec) |
7.Exit the mysql client.
1 2 |
mysql> exit Bye |
To create and edit the wp-config.php file
The WordPress installation folder contains a sample configuration file called wp-config-sample.php. In this procedure, you copy this file and edit it to fit your specific configuration.
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.
1 2 |
[ec2-user ~]$ cd wordpress/ [ec2-user wordpress]$ cp wp-config-sample.php wp-config.php |
2.Edit the wp-config.php file with your favorite text editor (such as nano or vim) and enter values for your installation. If you do not have a favorite text editor, nano is much easier for beginners to use.
1 |
[ec2-user wordpress]$ nano wp-config.php |
2.1.Find the line that defines DB_NAME and change database_name_here to the database name that you created in Step 4 of To create a MySQL user and database for your WordPress installation.
1 |
define('DB_NAME', 'wordpress-db'); |
2.2.Find the line that defines DB_USER and change username_here to the database user that you created in Step 3 of To create a MySQL user and database for your WordPress installation.
1 |
define('DB_USER', 'wordpress-user'); |
2.3.Find the line that defines DB_PASSWORD and change password_here to the strong password that you created in Step 3 of To create a MySQL user and database for your WordPress installation.
1 |
define('DB_PASSWORD', 'your_strong_password'); |
2.4.Find the section called Authentication Unique Keys and Salts. These KEY and SALT values provide a layer of encryption to the browser cookies that WordPress users store on their local machines. Basically, adding long, random values here makes your site more secure. 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. To paste text into a PuTTY terminal, place the cursor where you want to paste the text and right-click your mouse inside the PuTTY terminal.
For more information about security keys, go to http://codex.wordpress.org/Editing_wp-config.php#Security_Keys.
The values below are for example purposes only; do not use these values for your installation.
1 2 3 4 5 6 7 8 |
define('AUTH_KEY', ' #U$$+[RXN8:b^-L 0(WU_+ c+WFkI~c]o]-bHw+)/Aj[wTwSiZ<Qb[mghEXcRh-'); define('SECURE_AUTH_KEY', 'Zsz._P=l/|y.Lq)XjlkwS1y5NJ76E6EJ.AV0pCKZZB,*~*r ?6OP$eJT@;+(ndLg'); define('LOGGED_IN_KEY', 'ju}qwre3V*+8f_zOWf?{LlGsQ]Ye@2Jh^,8x>)Y |;(^[Iw]Pi+LG#A4R?7N`YB3'); define('NONCE_KEY', 'P(g62HeZxEes|LnI^i=H,[XwK9I&[2s|:?0N}VJM%?;v2v]v+;+^9eXUahg@::Cj'); define('AUTH_SALT', 'C$DpB4Hj[JK:?{ql`sRVa:{:7yShy(9A@5wg+`JJVb1fk%_-Bx*M4(qc[Qg%JT!h'); define('SECURE_AUTH_SALT', 'd!uRu#}+q#{f$Z?Z9uFPG.${+S{n~1M&%@~gL>U>NV<zpD-@2-Es7Q1O-bp28EKv'); define('LOGGED_IN_SALT', ';j{00P*owZf)kVD+FVLn-~ >.|Y%Ug4#I^*LVd9QeZ^&XmK|e(76miC+&W&+^0P/'); define('NONCE_SALT', '-97r*V/cgxLmp?Zy4zUU4r99QQ_rGs2LTd%P;|_e1tS)8_B/,.6[=UK<J_y9?JWG'); |
2.5.Save the file and exit your text editor.
To install your WordPress files under the Apache document root
1.Now that you’ve unzipped the installation folder, created a MySQL database and user, and customized the WordPress configuration file, you are ready to copy your installation files to your web server document root so you can run the installation script that completes your installation. The location of these files depends on whether you want your WordPress blog to be available at the actual root of your web server (for example, my.public.dns.amazonaws.com) or in a subdirectory or folder under the root (for example, my.public.dns.amazonaws.com/blog).
2.If you want WordPress to run at your document root, copy the contents of the wordpress installation directory (but not the directory itself) as follows:
1 |
[ec2-user ~]$ cp -r wordpress/* /var/www/html/ |
3.If you want WordPress to run in an alternative directory under the document root, first create that directory, and then copy the files to it. In this example, WordPress will run from the directory blog:
1 2 |
[ec2-user ~]$ mkdir /var/www/html/blog [ec2-user ~]$ cp -r wordpress/* /var/www/html/blog/ |
To allow WordPress to use permalinks
WordPress permalinks need to use Apache .htaccess files to work properly, but this is not enabled by default on Amazon Linux. Use this procedure to allow all overrides in the Apache document root.
1. Open the httpd.conf file with your favorite text editor (such as nano or vim). If you do not have a favorite text editor, nano is much easier for beginners to use.
1 |
[ec2-user wordpress]$ sudo vim /etc/httpd/conf/httpd.conf |
2.Find the section that starts with
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 |
<Directory "/var/www/html"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Require all granted </Directory> |
3.Change the AllowOverride None line in the above section to read AllowOverride All.
There are multiple AllowOverride lines in this file; be sure you change the line in the
1 |
AllowOverride All |
4.Save the file and exit your text editor.
To fix file permissions for the Apache web server
Some of the available features in WordPress require write access to the Apache document root (such as uploading media though the Administration screens). If you have not already done so, apply the following group memberships and permissions (as described in greater detail in the LAMP web server tutorial).
1.Change the file ownership of /var/www and its contents to the apache user.
1 |
[ec2-user wordpress]$ sudo chown -R apache /var/www |
2.Change the group ownership of /var/www and its contents to the apache group.
1 |
[ec2-user wordpress]$ sudo chown -R [ec2-user wordpress]$ sudo chgrp -R apache /var/wwwapache /var/www |
3.Change the directory permissions of /var/www and its subdirectories to add group write permissions and to set the group ID on future subdirectories.
1 2 |
[ec2-user wordpress]$ sudo chmod 2775 /var/www [ec2-user wordpress]$ find /var/www -type d -exec sudo chmod 2775 {} \; |
4.Recursively change the file permissions of /var/www and its subdirectories to add group write permissions.
1 |
[ec2-user wordpress]$ find /var/www -type f -exec sudo chmod 0664 {} \; |
5.Restart the Apache web server to pick up the new group and permissions.
1 2 3 |
[ec2-user wordpress]$ sudo service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] |
To run the WordPress installation script
1.Use the chkconfig command to ensure that the httpd and mysqld services start at every system boot.
1 2 |
[ec2-user wordpress]$ sudo chkconfig httpd on [ec2-user wordpress]$ sudo chkconfig mysqld on |
2.Verify that the MySQL server (mysqld) is running.
1 2 |
[ec2-user wordpress]$ sudo service mysqld status mysqld (pid 4746) is running... |
If the mysqld service is not running, start it.
1 2 |
[ec2-user wordpress]$ sudo service mysqld start Starting mysqld: [ OK ] |
3.Verify that your Apache web server (httpd) is running.
1 2 |
[ec2-user wordpress]$ sudo service httpd status httpd (pid 502) is running... |
If the httpd service is not running, start it.
1 2 |
[ec2-user wordpress]$ sudo service httpd start Starting httpd: [ OK ] |
4.In a web browser, enter the URL of your WordPress blog (either the public DNS address for your instance, or that address followed by the blog folder). You should see the WordPress installation screen.
1 |
http://my.public.dns.amazonaws.com |
5.Enter the remaining installation information into the WordPress installation wizard.
6.Click Install WordPress to complete the installation.
Congratulations, you should now be able to log into your WordPress blog and start posting entries.
If you have any query/suggestion please feel free to contact me.