Create an EC2 instance config with apache web server and launch wordpress site using AWS (RDS&EC2)

1. AWS Free Tier & Creating an Account

AWS free tier page.

2. Hands On

2.1. Security Groups

In AWS console main page, you can see a service search field, type “EC2” and click on the first search result

  • On the name field I’m typing “server-tier”
  • On the description field I’m typing “traffic into and out of servers”
  • On the VPC I’m leaving it to default
  • Add a new rule to the group
  • Choose “HTTP” for the type
  • Leave the protocol and port range to defaults
  • Choose “Anywhere” for the source
  • Give it a description
  • Add another rule to the group
  • Choose “SSH” for the type
  • Leave the protocol and port range to defaults
  • Choose “My IP” for the source
  • Give it a description
  • Click on Create
  • On the name field I’m typing “db-tier”
  • On the description field I’m typing “traffic into database”
  • On the VPC I’m leaving it to default
  • Add a new rule to the group
  • Choose “MYSQL/Aurora” for the type
  • Leave the protocol and port range to defaults
  • Choose “Custom” for the source and paste the Group ID created for the server-tier
  • Give it a description
  • Add another rule to the group
  • Choose “MYSQL/Aurora” for the type
  • Leave the protocol and port range to defaults
  • Choose “My IP” for the source
  • Give it a description
  • Click on Create

2.2. Creating RDS Instance

2.2.1. Checking Connection

2.3. Creating EC2 Instance

2.3.1. Connecting Via SSH

2.3.2. Checking Connection To RDS

> sudo yum update -y
> sudo yum install mysql -y
> mysql -h ec2-rds-wordpress.cllwpsr5wpkr.us-west-2.rds.amazonaws.com -u admin -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 5.6.37-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| innodb |
| my_site_1 |
| mysql |
| performance_schema |
| sys |
+--------------------+
6 rows in set (0.00 sec)

2.4. Creating And Hosting Wordpress Site

> sudo yum install -y httpd24 php70 php70-mysqlnd
> sudo service httpd start
> sudo service httpd stop
> sudo usermod -a -G apache ec2-user
> groups
ec2-user wheel
> groups
ec2-user wheel apache
> sudo chown -R ec2-user:apache /var/www
> sudo chmod 2775 /var/www
> find /var/www -type d -exec sudo chmod 2775 {} \;
> find /var/www -type f -exec sudo chmod 2775 {} \;
> wget https://wordpress.org/latest.tar.gz
> tar -xzf latest.tar.gz
> cd wordpress
> cp wp-config-sample.php wp-config.php
> vim wp-config.php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'my_site_1');
/** MySQL database username */
define('DB_USER', 'admin');
/** MySQL database password */
define('DB_PASSWORD', 'your_password');
/** MySQL hostname */
define('DB_HOST', 'ec2-rds-wordpress.cllwpsr5wpkr.us-west-2.rds.amazonaws.com');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all
existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define('AUTH_KEY', 'generate from website above');
define('SECURE_AUTH_KEY', 'generate from website above');
define('LOGGED_IN_KEY', 'generate from website above');
define('NONCE_KEY', 'generate from website above');
define('AUTH_SALT', 'generate from website above');
define('SECURE_AUTH_SALT', 'generate from website above');
define('LOGGED_IN_SALT', 'generate from website above');
define('NONCE_SALT', 'generate from website above');
/**#@-*/
> cp -r wordpress/* /var/www/html/
> sudo vim /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">
...
AllowOverride All
...
</Directory>
> sudo service httpd start
> sudo chkconfig httpd on

3. Conclusion

4. Resources

--

--

--

self learner ! Engineer ! dedication to learn new skills

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What’s Your Decomposition Strategy?

How To Write A C++ Program That Computes Simple Interest

A laptop displays lines of codes with a c++ logo to its left.

PredictX: Successful Community Airdrop with Blockzone!

How to Manage Multiple SSH Keys for GitHub, GitLab, etc.

50 Top Java Projects on GitHub

How to secure GraphQL in DRF without duplicating code

How To Install pgadmin4 To Your Ubuntu?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Himanshu singh

Himanshu singh

self learner ! Engineer ! dedication to learn new skills

More from Medium

Trends in Cloud FinOps implementation

CONNECT WSO2 API MANAGER AND MYSQL SERVER ON DOCKER.

Using Proxima Streaming Clients

IoT Supply Chain: Real-life Use Cases & Challenges | Sumatosoft