When making a web application or site, it’s good to run as many tests as possible. We always do this to ensure that it accomplishes the necessary quality, performance and operation parameters to satisfy customer needs. It is recommended to test in a special environment dedicated to this task, called staging environment; where the final production environment can be simulated.
Imagine a place where you can feel free to brake, screw or mess up things without worrying about altering the final live site. So Staging is the perfect environment to test with no concerns about affecting site’s general function and to move your site one step closer to "live." Once all tests have been done, it’s time to move to a stable production environment.
AWS is a great solution when looking for configuring staging environments
What is needed to configure a staging environment on AWS?
Create your own AWS Account.
According with the tools and service list that you saw above, we need an AWS account.
First, access to your AWS account. If you don’t have an account, follow the next steps to create your own AWS account.
Prepare your web server with LEMP Stack in Ubuntu 16.04
Now, we can prepare your web server; we recommend the LEMP Stack to have high performance on your website.
LEMP Stack (Linux, Nginx, Mysql and PHP) is the software integration to serve dynamic websites and web applications. This is the integration of the open source OS Linux, the web server Nginx, the database Mysql and PHP that manage the dynamic process in the site.
To install this environment on your web server, follow the next steps.
1. Install Ngnix
When you access your web server, you need to install Nginx, use the next command to install it.
apt install nginx
After this, in the terminal screen you can see an output with the packages that you will install on your server, type yes or just type Enter to continue with the installation
2. Install Mysql
Now you need to install MySQL server to manage the database from your future site in your server, run this command to install it.
apt install mysql-server
Like the installation above, you will see an output with the packages that will be installed in your web server, type yes or just press Enter to install it.
Configure Nginx to use PHP
Now you need to edit your nginx virtual host to send the PHP request to FPM, to this add the following lines inside the server block in your virtual host.
First, your virtual host that Nginx created by default should see like this:
Test the new configuration
To test that php is working fine, you need to create an info.php file in your HTML directory, copy and paste the next code into the info.php file.
Now, you can access your domain name or IP address from your server and add the name from the file info.php in your browser and you will see the information like this.
Finally, we have installed the LEMP stack where your future website will be hosted.
Create an EC2 instance in AWS
Once you have your AWS Account, you can start with this creating your first EC2 instance in your AWS console.
1. Go to aws.amazon.com and click on one of the “Sign in to the Console” buttons.
3. Once you enter in your AWS console, you will see an AWS Services search bar, below that you can see the recently visited services that you have used before, and below that you will see All services divided into categories, find Compute and you can see EC2, click on it to continue.
4. Next, you will see the EC2 dashboard. In this screen, you can see all the AWS resources that you are using in the region that you have chosen, you need to find the Create Instance block and then click on the Launch Instance button
If you want to go to the previous page when you chose an AMI, you can click in the Previous button and follow the instructions in the Step 1, if you want to jump the other steps and launch the instance now, click in the Review and Launch button and follow the indications that are expose in the Step 7 in this tutorial, or if you want to continue with the other steps remaining, click in the Next: Configure Instance Details button to continue with the installation and the next step in this tutorial.
● Step 3: Now, in the next screen, you need to specify the instance details to suit your requirements
Step 4: In this next step, we will add the storage to our new instance. You must need to put the size that your instance will require. This size can’t be “” but it can grow if you need.
When you finish to fill all the fields in this form, click in the “Next” button to continue.
Now, you need to configure advanced settings from your instance, among the configurations that you will see in this step we have:
Network and security:
Here you can allow to encrypt your instance.
Finally, when you finish to specify all the correct information about this points that were described below, you must click in “Launch DB Instance” button to create and launch you own DB instance.
To see your DB instances you can access to the RDS dashboard and select the “Instances” section in the left menu.
Create and configure a bucket with Amazon S3 Service.
Amazon Simple Storage Services (Amazon S3), is a service that store static content from your site and backups that will be accesibles in a 99% of time.
To create a bucket to start this you need to access to your AWS console and search “S3” in the search bar from the dashboard.
IAM means Identity and Access Management, this is an AWS service that allows users to access to your AWS account, manage groups and roles and provide this users to your work team to delegate responsibilities oriented to a specific service in your own AWS account
Now, we will create a new user using the IAM service, to this follow the next steps to create an IAM user.
1. Log in to your AWS account and type in the Search bar the word “IAM”, to access into the IAM dashboard
You can use Amazon CloudWatch to gain system-wide visibility into resource utilization, application performance, and operational health. You can use these insights to react and keep your application running smoothly.
Now, we can start with the configuration of AWS CloudWatch Service.
1. First, log in to your AWS account and type in the Search bar cloudwatch to access into the CloudWatch Dashboard