After successful completion of first and second step i.e. creating an EC2 instanceand connecting to EC2 instance in AWS using PuTTY and Terminal respectively. Further moving ahead, it is time to install Apache, PHP, MySQL to run WordPress on an EC2 instance. If you are not familiar with command line / Linux commands just run these commands in same order.
NOTE: This instruction is for Amazon Linux and will not work if you are trying different machine image like Ubuntu or Windows Server.
Connect to your instance via PuTTY (Windows) / Terminal (Mac OS) / Bash (Linux OS)
Just to make sure everything is up to date
sudo yum -y update
If you want, you may directly switch from ‘ec2-user’ user to root using sudo su command.
Install multiple software packages:
sudo yum install -y httpd24 php70 mysql56-server php70-mysqlnd
Start Apache Server:
sudo service httpd start
Create a page to check your PHP installation
a) vi test.php
b) Type i to start the insert mode
c) Type <?php phpinfo() ?>
d) Hit escape button and type :wq, now hit enter to exit
e) Open a browser and http://ec2-xxx-xxx-xxx-xxx.us-west-1.compute.amazonaws.com/test.php (use you public IP DNS followed by /test.php)
If you see a phpinfo page then you are good to move forward, otherwise you may want to start over.
Delete the test.php file as it is for the information only and you definitely don’t want to give away sensitive information about your server:
rm -f /var/www/html/test.php
Secure Start SQL service
Start MySQL service and run secure installation
sudo service mysqld start
sudo mysql_secure_installation
When prompted, enter a password for the root account. By default, the root account does not have a password set, so press Enter.
Type Y to set a password, and enter a secure password twice
1) Remove anonymous users? [Y/n] Y
2) Disallow root login remotely? [Y/n] Y
3) Remove test database and access to it? [Y/n] Y
4) Reload privilege tables now? [Y/n] Y
Restart MySQL to pick up the changes:
sudo service mysqld restart
Login into MySQL and Create a database for WordPress
Log in to the MySQL server as the root user and enter your MySQL root password when prompted
mysql -u root –p
Create a user name and password for your MySQL database.
CREATE USER 'aksgeek'@'localhost' IDENTIFIED BY 'aksgeekpassword';
Replace ‘aksgeek’ with your WordPress username and ‘aksgeekpassword’ with your strong password.
Create a database for WordPress:
CREATE DATABASE `wordpressdb`;
(you can create a database with any name)
GRANT ALL PRIVILEGES ON `wordpressdb`.* TO "aksgeek"@"localhost";
FLUSH PRIVILEGES;
exit
Install WordPress
cd /var/www/html
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
cd wordpress/
mv wp-config-sample.php wp-config.php
nano wp-config.php
Start editing wp-config.php. (user arrow keys to move around)
define('DB_NAME', 'wordpressdb');
define('DB_USER', 'aksgeek');
define('DB_PASSWORD', 'aksgeekpassword');
define('DB_HOST', 'localhost');
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.
Ctrl + X
Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ? Y
File Name to Write [DOS Format]: wp-config.php hit Enter.
Move your WordPress installation to root or in subdirectory / folder
You may want to run your WordPress blog from root like your_public_dns.amazonaws.com/) then
mv * /var/www/html/
Or
Most of you want to install it in a subdirectory or folder (for example, your_public_dns.amazonaws.com/blog, then
mkdir /var/www/html/blog
mv * /var/www/html/blog
To allow WordPress to use permalinks
sudo nano /etc/httpd/conf/httpd.conf
<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>
|
Find the section that starts with <Directory "/var/www/html"> and change the AllowOverride None line to AllowOverride All.
To ensure that the httpd and mysqld services start at every system boot
sudo chkconfig httpd on
sudo chkconfig mysqld on
Open a web browser and enter the URL of your WordPress blog, you should see the WordPress installation screen
Example for root installation: http://ec2-xx-xxx-xxx-xxx-us-west-1.compute.amazonaws.com
or
for subdirectory / folder (blog): http://ec2-xx-xxx-xxx-xxx-us-west-1.compute.amazonaws.com/blog.
Enter your site name, username, password and email address and hit submit.
Congratulations!! You are running WordPress blog on Amazon Web Services (AWS) EC2 instance.
Troubleshooting
Having trouble updating and downloading themes/plugin in WordPress blog as it is asking for FTP credentials then run this command:
sudo chown -R apache:apache /var/www/html
0comments:
Post a Comment