<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Hossam ELMansy</title>
    <description>The latest articles on Forem by Hossam ELMansy (@hossamelmansy).</description>
    <link>https://forem.com/hossamelmansy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F574141%2F87b8c99c-cf29-48dc-ba8f-8498613d8793.jpeg</url>
      <title>Forem: Hossam ELMansy</title>
      <link>https://forem.com/hossamelmansy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hossamelmansy"/>
    <language>en</language>
    <item>
      <title>Installing LAMP on Amazon Linux 2</title>
      <dc:creator>Hossam ELMansy</dc:creator>
      <pubDate>Thu, 11 Feb 2021 09:17:19 +0000</pubDate>
      <link>https://forem.com/hossamelmansy/installing-lamp-on-amazon-linux-2-46np</link>
      <guid>https://forem.com/hossamelmansy/installing-lamp-on-amazon-linux-2-46np</guid>
      <description>&lt;p&gt;In this tutorial you'll learn how to install LAMP stack on Amazon Linux 2. LAMP is an acronym for &lt;em&gt;Linux&lt;/em&gt;, &lt;em&gt;Apache&lt;/em&gt;, &lt;em&gt;PHP&lt;/em&gt; and &lt;em&gt;MySQL&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;You'll install Apache web server with PHP and MariaDB. You can use this server to host a static website or dynamic PHP application (ex. Wordpress).&lt;/p&gt;

&lt;h1&gt;
  
  
  Prerequisites
&lt;/h1&gt;

&lt;p&gt;Before started, I assume you have an Amazon Linux 2 EC2 instance and you have connected to it. Also, your instance's security group must be configured to allow &lt;em&gt;SSH (port 22)&lt;/em&gt; and &lt;em&gt;HTTP (port 80)&lt;/em&gt;. If you don't have, follow my previous tutorial &lt;a href="https://dev.to/hossamelmansy/creating-your-first-amazon-ec2-linux-instance-472c"&gt;Creating Your First Amazon EC2 Linux Instance&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Getting Started
&lt;/h1&gt;

&lt;p&gt;First, you need to connect to your EC2 instance.&lt;/p&gt;

&lt;p&gt;Ensure that all of your software packages are up to date:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum update -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Install LAMP Stack
&lt;/h1&gt;

&lt;p&gt;Install &lt;code&gt;lamp-mariadb10.2-php7.2&lt;/code&gt; and &lt;code&gt;php7.2&lt;/code&gt; Amazon Linux Extras repositories to get the latest versions of &lt;em&gt;LAMP MariaDB&lt;/em&gt; and &lt;em&gt;PHP&lt;/em&gt; packages for Amazon Linux 2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install &lt;strong&gt;Apache web server&lt;/strong&gt; and &lt;strong&gt;MariaDB&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum install -y httpd mariadb-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start the &lt;strong&gt;Apache web server&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start httpd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enable the &lt;strong&gt;Apache Web Server&lt;/strong&gt; so it can start each time the system boot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl enable httpd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test your web server. Open a web browser and type the &lt;strong&gt;public IPv4 DNS address&lt;/strong&gt; or the &lt;strong&gt;public IPv4 address&lt;/strong&gt; of your instance. You should see the &lt;strong&gt;Apache&lt;/strong&gt; test page:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---0ZOqRXH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/au147r2j4d5jvogxvy7x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---0ZOqRXH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/au147r2j4d5jvogxvy7x.png" alt="Alt Text" width="880" height="448"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Update Apache File Permissions
&lt;/h1&gt;

&lt;p&gt;Apache &lt;strong&gt;httpd&lt;/strong&gt; serves files that are kept in a directory called &lt;strong&gt;Apache Document Root&lt;/strong&gt; which by default &lt;code&gt;/var/www/html&lt;/code&gt; and owned by &lt;strong&gt;root&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To allow &lt;code&gt;ec2-user&lt;/code&gt; to work with this directory, you need to modify the ownership and permissions of this directory.&lt;/p&gt;

&lt;p&gt;First, add &lt;code&gt;ec2-user&lt;/code&gt; (or your user) to &lt;code&gt;apache&lt;/code&gt; group:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo usermod -aG apache ec2-user 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the group ownership of &lt;code&gt;/var/www&lt;/code&gt; directory and its contents to the &lt;code&gt;apache&lt;/code&gt; group:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chown -R ec2-user:apache /var/www
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add group write permissions to &lt;code&gt;/var/www&lt;/code&gt; directory and its future subdirectories:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chmod 2775 /var/www &amp;amp;&amp;amp; find /var/www -type d -exec sudo chmod 2775 {} \;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add group write permissions to &lt;code&gt;/var/www&lt;/code&gt; directory files recursively:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;find /var/www -type f -exec sudo chmod 0664 {} \;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Logout and login again to pick the new group permissions.&lt;/p&gt;

&lt;p&gt;Now, any member of the &lt;code&gt;apache&lt;/code&gt; group (ex. &lt;code&gt;ec2-user&lt;/code&gt;) can add, delete and edit files in the &lt;strong&gt;Apache Document Root&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To test your LAMP server, create a PHP file in the &lt;strong&gt;Apache Document Root&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "&amp;lt;?php phpinfo(); ?&amp;gt;" &amp;gt; /var/www/html/phpinfo.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open a web browser, type your instance &lt;em&gt;public IPv4 DNS address&lt;/em&gt; or &lt;em&gt;public IPv4 address&lt;/em&gt; followed by the file you just created &lt;code&gt;http://[public-dns-address]/phpinfo.php&lt;/code&gt;, you should see the PHP information page:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vkvJHHmg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/luc7o20nz21zsrt37ohr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vkvJHHmg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/luc7o20nz21zsrt37ohr.png" alt="Alt Text" width="880" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Delete the &lt;code&gt;phpinfo.php&lt;/code&gt; file as it shouldn't be exposed to the Internet because it exposes information about your server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm /var/www/html/phpinfo.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have a fully functional Apache web server that's configured with PHP and MariaDB installed.&lt;/p&gt;

&lt;h1&gt;
  
  
  Secure the MariaDB Server
&lt;/h1&gt;

&lt;p&gt;The default installation of the MariaDB server is great for testing and development, but for production servers you need to secure your database. There's a command &lt;strong&gt;mysql_secure_installation&lt;/strong&gt; that walks you through the process of securing your MariaDB server.&lt;/p&gt;

&lt;p&gt;Start the &lt;strong&gt;MariaDB Server&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start mariadb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enable the &lt;strong&gt;MariaDB Server&lt;/strong&gt; so it can start each time the system boot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl enable mariadb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;strong&gt;mysql_secure_installation&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mysql_secure_installation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, the &lt;strong&gt;root&lt;/strong&gt; account doesn't have a password. press Enter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Enter current password for root (enter for none):
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter &lt;strong&gt;Y&lt;/strong&gt; to set the &lt;strong&gt;root&lt;/strong&gt; password:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Type your &lt;strong&gt;root&lt;/strong&gt; password twice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;New password: 
Re-enter new password:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter &lt;strong&gt;Y&lt;/strong&gt; to remove anonymous user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter &lt;strong&gt;Y&lt;/strong&gt; to prevent &lt;strong&gt;root&lt;/strong&gt; user to login remotely:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter &lt;strong&gt;Y&lt;/strong&gt; to remove the test database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter &lt;strong&gt;Y&lt;/strong&gt; to reload table privileges:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations🎉🎉 You have successfully installed the LAMP web server. In the next tutorial you'll learn how to host a Wordpress website on your LAMP web server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thank you for following through this tutorial. If you have any questions and/or if you want me to write about anything related to AWS please let me know.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>lamp</category>
      <category>ec2</category>
      <category>linux</category>
    </item>
    <item>
      <title>Hosting static Next.js website on AWS S3</title>
      <dc:creator>Hossam ELMansy</dc:creator>
      <pubDate>Tue, 09 Feb 2021 21:52:11 +0000</pubDate>
      <link>https://forem.com/hossamelmansy/hosting-static-next-js-website-on-aws-s3-32lm</link>
      <guid>https://forem.com/hossamelmansy/hosting-static-next-js-website-on-aws-s3-32lm</guid>
      <description>&lt;p&gt;In this tutorial you will learn how to host a static Next.js app on AWS S3.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To complete this tutorial you must have both &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;NodeJS&lt;/a&gt; and &lt;a href="https://www.npmjs.com/" rel="noopener noreferrer"&gt;NPM&lt;/a&gt; &lt;br&gt;
installed and &lt;a href="https://aws.amazon.com/cli/" rel="noopener noreferrer"&gt;AWS CLI&lt;/a&gt; installed and configured.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Getting started
&lt;/h1&gt;

&lt;p&gt;First, create a new Next.js app and change into the directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-next-app next-website

&lt;span class="nb"&gt;cd &lt;/span&gt;next-website
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start your Next.js app locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server will start on port &lt;code&gt;3000&lt;/code&gt;. Access your app with &lt;code&gt;http://localhost:3000&lt;/code&gt;:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F56ck3a5dbajaj63mel16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F56ck3a5dbajaj63mel16.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Build Next.js App
&lt;/h1&gt;

&lt;p&gt;Before building your app you need to know the following Next.js commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;next build&lt;/code&gt; creates an optimized build of your app.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;next export&lt;/code&gt; allows you to export your app to static HTML.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To build your app you need to combine both commands.&lt;/p&gt;

&lt;p&gt;Update your scripts in your &lt;code&gt;package.json&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"next build &amp;amp;&amp;amp; next export"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you now have a static version of your app in the &lt;code&gt;out&lt;/code&gt; directory.&lt;/p&gt;

&lt;h1&gt;
  
  
  Create and Configure S3 Bucket
&lt;/h1&gt;

&lt;p&gt;Open &lt;a href="https://console.aws.amazon.com/console/home" rel="noopener noreferrer"&gt;AWS Management Console&lt;/a&gt; and Click &lt;strong&gt;Services&lt;/strong&gt; -&amp;gt; &lt;strong&gt;S3&lt;/strong&gt; to open &lt;a href="https://s3.console.aws.amazon.com/s3/home" rel="noopener noreferrer"&gt;S3 Management Console&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg61hs324ru88lnjjocq2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg61hs324ru88lnjjocq2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose &lt;strong&gt;Create bucket&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu6z19axzmavx1amhvcyh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu6z19axzmavx1amhvcyh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;Bucket name&lt;/strong&gt;, enter your bucket name. Bucket name must meet the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DNS-compliant.&lt;/li&gt;
&lt;li&gt;Unique across all Amazon S3 buckets.&lt;/li&gt;
&lt;li&gt;Between 3 and 63 characters long.&lt;/li&gt;
&lt;li&gt;Doesn't contain uppercase characters.&lt;/li&gt;
&lt;li&gt;Start with a lowercase letter or number.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9xawzu6e9fs7c7tbg8qj.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Select &lt;strong&gt;Region&lt;/strong&gt; your S3 bucket will be created in.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flkgmrh9ug2uvloaotsy8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flkgmrh9ug2uvloaotsy8.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose &lt;strong&gt;Create bucket&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff0dpoiy9xz0t8a2194gp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ff0dpoiy9xz0t8a2194gp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Configuring your S3 bucket as a static website requires three steps:&lt;/p&gt;

&lt;p&gt;1- Disable &lt;strong&gt;Block Public Access settings&lt;/strong&gt;.&lt;br&gt;
2- Add a &lt;strong&gt;Bucket Policy&lt;/strong&gt; that grants public read access.&lt;br&gt;
3- Enable bucket &lt;strong&gt;Static website hosting&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Choose your bucket. And let's begin configure it.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs2zxhklrz61hf770psz8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs2zxhklrz61hf770psz8.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Disable Block Public Access Settings
&lt;/h2&gt;

&lt;p&gt;Choose &lt;strong&gt;Permissions&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F69grjxzjy1c5wkhu7veh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F69grjxzjy1c5wkhu7veh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under &lt;strong&gt;Block public access (bucket settings)&lt;/strong&gt; choose &lt;strong&gt;Edit&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fja9sdxy7dd6ymy5w4l7e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fja9sdxy7dd6ymy5w4l7e.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unckeck &lt;strong&gt;Block all public access&lt;/strong&gt; and choose &lt;strong&gt;Save changes&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fre7xqh8cvkkrr4w1mxt4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fre7xqh8cvkkrr4w1mxt4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confirm&lt;/strong&gt; your changes.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flpoft089y4cdfv3o8mfu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flpoft089y4cdfv3o8mfu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Add a Bucket Policy
&lt;/h2&gt;

&lt;p&gt;In the same page under &lt;strong&gt;Bucket policy&lt;/strong&gt; choose &lt;strong&gt;Edit&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fmfpjk4w19zd4ggdu0g8l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fmfpjk4w19zd4ggdu0g8l.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In policy section copy the following and replace &lt;em&gt;[bucket-name]&lt;/em&gt; with your bucket name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"Principal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"s3:GetObject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"arn:aws:s3:::[bucket-name]/*"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Choose &lt;strong&gt;Save changes&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0sct4pc5z0613bequ6a1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0sct4pc5z0613bequ6a1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Enable Bucket Static Website Hosting
&lt;/h2&gt;

&lt;p&gt;Choose &lt;strong&gt;Properties&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz7onadtkdp6i6fugn1mv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz7onadtkdp6i6fugn1mv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under &lt;strong&gt;Static website hosting&lt;/strong&gt; choose &lt;strong&gt;Edit&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fumhbvr7akbkycasg9ve7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fumhbvr7akbkycasg9ve7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select &lt;strong&gt;Enable&lt;/strong&gt; static website hosting and &lt;strong&gt;Host a static website&lt;/strong&gt;. In &lt;strong&gt;Index document&lt;/strong&gt; enter &lt;em&gt;index.html&lt;/em&gt; and in &lt;strong&gt;Error document&lt;/strong&gt; enter &lt;em&gt;404.html&lt;/em&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3b16co8wmrho35d6bk21.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3b16co8wmrho35d6bk21.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose &lt;strong&gt;Save changes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now that you have created and configured your bucket, it's time to publish your Next.js app to it.&lt;/p&gt;
&lt;h1&gt;
  
  
  Publish Next.js App to S3 Bucket
&lt;/h1&gt;

&lt;p&gt;I'll use AWS CLI to upload Next.js app files and folders to S3 as this method easy and more practical than using AWS Console.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To configure AWS CLI &lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html" rel="noopener noreferrer"&gt;click here&lt;/a&gt; and follow the instructions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Change into your Next.js app directory and enter the following command (&lt;strong&gt;Don't forget to change bucket name with yours&lt;/strong&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws s3 &lt;span class="nb"&gt;sync&lt;/span&gt; ./out/ s3://next-website/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now all your files and folders in &lt;em&gt;out&lt;/em&gt; directory have been uploaded to your bucket.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fk4o8vxm3vfg4wxiy8d5c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fk4o8vxm3vfg4wxiy8d5c.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To access your website Choose &lt;strong&gt;Properties&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fw3lkw74bd4jr4exke0o0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fw3lkw74bd4jr4exke0o0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under &lt;strong&gt;Static website hosting&lt;/strong&gt; you'll find your &lt;strong&gt;Bucket website URL&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4tv13nzmr5d8i9kybyfm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4tv13nzmr5d8i9kybyfm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open the URL:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6t437p96r1s4hbdlnr5i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6t437p96r1s4hbdlnr5i.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Congratulations&lt;/strong&gt;🎉🎉 You have successfully published your Next.js website on AWS S3.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thank you for following through this tutorial. If you have any questions and/or if you want me to write about anything related to AWS please let me know.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>nextjs</category>
      <category>react</category>
      <category>s3</category>
    </item>
    <item>
      <title>Creating Your First Amazon EC2 Linux Instance</title>
      <dc:creator>Hossam ELMansy</dc:creator>
      <pubDate>Sat, 06 Feb 2021 08:12:30 +0000</pubDate>
      <link>https://forem.com/hossamelmansy/creating-your-first-amazon-ec2-linux-instance-472c</link>
      <guid>https://forem.com/hossamelmansy/creating-your-first-amazon-ec2-linux-instance-472c</guid>
      <description>&lt;p&gt;In this tutorial you will learn how to launch Linux EC2 instance. You can use Amazon EC2 to launch virtual servers, configure security and networking, and manage storage. Amazon EC2 enables you to scale up or down to handle changes in requirements or spikes in popularity.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To complete this tutorial you must have an AWS account. To create an AWS account &lt;a href="https://portal.aws.amazon.com/billing/signup"&gt;click here&lt;/a&gt; and follow the instructions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Launch an instance
&lt;/h1&gt;

&lt;p&gt;First, Open &lt;a href="https://console.aws.amazon.com/console/home"&gt;AWS Management Console&lt;/a&gt; and select the region you want to create your instance. I'll use N. Virginia (us-east-1).&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GHQpyY5l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xdst9m9rfey6u197fqej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GHQpyY5l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xdst9m9rfey6u197fqej.png" alt="Alt Text" width="880" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, click &lt;strong&gt;Services&lt;/strong&gt; -&amp;gt; &lt;strong&gt;EC2&lt;/strong&gt; to open &lt;a href="https://console.aws.amazon.com/ec2/v2/home"&gt;Amazon EC2 Console&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8hWIRFoU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/x6pilopxae2gad2yqi56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8hWIRFoU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/x6pilopxae2gad2yqi56.png" alt="Alt Text" width="880" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, choose &lt;strong&gt;Launch Instance&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H-Rbtogm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ji0d1d70hzw62uths4fz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H-Rbtogm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ji0d1d70hzw62uths4fz.png" alt="Alt Text" width="880" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, choose an &lt;strong&gt;Amazon Machine Image (AMI)&lt;/strong&gt; which serves as a template for your instance. Select &lt;strong&gt;Amazon Linux 2 AMI (HVM)&lt;/strong&gt;. Note that it's marked as &lt;em&gt;Free tier eligible&lt;/em&gt; (won't cost money if your account is in the &lt;em&gt;Free tier&lt;/em&gt;). Click &lt;strong&gt;Select&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kgmsiWsk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dz659y4wdmixs1cbprmp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kgmsiWsk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/dz659y4wdmixs1cbprmp.png" alt="Alt Text" width="880" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, choose an &lt;strong&gt;Instance Type&lt;/strong&gt; which means the hardware configurations of your instance. Select &lt;strong&gt;t2.micro&lt;/strong&gt; instance type. Note also it's marked as &lt;em&gt;Free tier eligible&lt;/em&gt;. Click &lt;strong&gt;Next: Configure Instance Details&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_t6ktjww--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6l7j3u85ja4vgbcloni0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_t6ktjww--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6l7j3u85ja4vgbcloni0.png" alt="Alt Text" width="880" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, in &lt;strong&gt;Configure Instance Details&lt;/strong&gt; page make sure that &lt;strong&gt;Auto-assign Public IP&lt;/strong&gt; option is &lt;strong&gt;Use subnet setting (Enable)&lt;/strong&gt;. When enabled, your instance will have public IPv4 address which is needed to connect to your instance later.  If it's &lt;em&gt;Disable&lt;/em&gt;, enable it. Click &lt;strong&gt;Next: Add Storage&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T-BbGmaU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ykh57kcuh1thtd85tvl0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T-BbGmaU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ykh57kcuh1thtd85tvl0.png" alt="Alt Text" width="880" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, in &lt;strong&gt;Add Storage&lt;/strong&gt; page you can any additional storage volumes you need. Click &lt;strong&gt;Next: Add Tags&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Next, in &lt;strong&gt;Add Tags&lt;/strong&gt; page you can add one tag. Click &lt;strong&gt;Add Tag&lt;/strong&gt;, let &lt;em&gt;Key=Name&lt;/em&gt; and &lt;em&gt;Value=WebServer&lt;/em&gt;. Click &lt;strong&gt;Next: Configure Security Group&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PyzfhHw_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8y0c41id6fz3mqc9igg9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PyzfhHw_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8y0c41id6fz3mqc9igg9.png" alt="Alt Text" width="880" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, in &lt;strong&gt;Configure Security Group&lt;/strong&gt; page let's create a new security group: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select &lt;strong&gt;Create a new security group&lt;/strong&gt; option.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;Security group name&lt;/strong&gt; enter &lt;em&gt;WebServer-SG&lt;/em&gt; and for &lt;strong&gt;Description&lt;/strong&gt; enter &lt;em&gt;Allows SSH and HTTP&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;You'll notice that a rule with type &lt;strong&gt;SSH&lt;/strong&gt; already added. Click &lt;strong&gt;Add Rule&lt;/strong&gt; and for the new rule type select &lt;strong&gt;HTTP&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;For both rules make sure &lt;strong&gt;Source&lt;/strong&gt; is set to &lt;strong&gt;Custom&lt;/strong&gt; with &lt;em&gt;0.0.0.0/0&lt;/em&gt; to make your instance accessible from the Internet.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This security group allows your instance to receive traffic on port &lt;em&gt;22&lt;/em&gt; and &lt;em&gt;80&lt;/em&gt; from any IPv4 address. You many want to restrict &lt;em&gt;source&lt;/em&gt; to your IPv4 address, so no one can access it except you.&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Review and Launch&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F8NChjhp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nhqabxppzgdk4yhk4tr3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F8NChjhp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nhqabxppzgdk4yhk4tr3.png" alt="Alt Text" width="880" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, in &lt;strong&gt;Review Instance Launch&lt;/strong&gt; page make sure all your instance settings are correct and click &lt;strong&gt;Launch&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When prompted for a key pair, if you have a key pair select &lt;strong&gt;Choose an existing key pair&lt;/strong&gt;. If you don't have a key pair, select &lt;strong&gt;Create a new key pair&lt;/strong&gt; and name it. Let's name it &lt;em&gt;WebServerKP&lt;/em&gt;. Click &lt;strong&gt;Download Key Pair&lt;/strong&gt; to download it, then click &lt;strong&gt;Launch Instances&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5c5UtGtL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mhch9fn16equug4fpg7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5c5UtGtL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mhch9fn16equug4fpg7g.png" alt="Alt Text" width="880" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now your instance is launching. Click &lt;strong&gt;View Instances&lt;/strong&gt; to close this page and return to the console.&lt;/p&gt;

&lt;p&gt;On the &lt;strong&gt;Instances&lt;/strong&gt; page, you can view the status of your instance launch. When you launch an instance, its initial state is &lt;em&gt;Pending&lt;/em&gt;. After the instance starts, its state changes to &lt;em&gt;Running&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Select your instance, and in the details section you can view your instance attributes like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instance ID&lt;/li&gt;
&lt;li&gt;Instance state&lt;/li&gt;
&lt;li&gt;Instance type&lt;/li&gt;
&lt;li&gt;Public IPv4 address&lt;/li&gt;
&lt;li&gt;Public IPv4 DNS&lt;/li&gt;
&lt;li&gt;etc.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z7bSrt04--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/akullf8i6kp08mqlbjtu.png" alt="Alt Text" width="880" height="462"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that our instance is running, lets connect to it. Write down your instance &lt;em&gt;IPv4 address&lt;/em&gt;, as you will need it to connect to the instance.&lt;/p&gt;
&lt;h1&gt;
  
  
  Connect to your instance
&lt;/h1&gt;

&lt;p&gt;There are several options to connect to the instance and it all depends on the operating system of your local computer. If your local computer operating system is Linux/macOS (like mine) you can use &lt;em&gt;SSH client&lt;/em&gt;. If your local computer operating system is Windows you can use &lt;a href="https://www.putty.org/"&gt;PuTTY&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this tutorial I will use &lt;em&gt;SSH client&lt;/em&gt; as I'm using Linux as my local operating system. This &lt;em&gt;SSH client&lt;/em&gt; will be already installed by default on most Linux distributions.&lt;/p&gt;

&lt;p&gt;First, navigate to &lt;em&gt;Downloads&lt;/em&gt; directory where your downloaded keypair &lt;strong&gt;WebServerKP.pem&lt;/strong&gt; resides:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~/Downloads/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will use this key to connect to your instance. Copy your instance &lt;em&gt;Public IPv4 address&lt;/em&gt; and enter the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i WebServerKP.pem ec2-user@54.84.177.115
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get a response like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The authenticity of host '54.84.177.115 (54.84.177.115)' can't be established.
ECDSA key fingerprint is SHA256:6mrCwTMUa+2wZwjhMC0lldEmzuYqjk2JrLMoDdeSh6c.
Are you sure you want to continue connecting (yes/no)?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify the fingerprint in the security alert, and enter &lt;code&gt;yes&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You will receive the following error message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Warning: Permanently added '54.84.177.115' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0664 for 'WebServerKP.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "WebServerKP.pem": bad permissions
ec2-user@54.84.177.115: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which means that the &lt;em&gt;WebServerKP.pem&lt;/em&gt; key can be accessed by other users which is not secure. You need to change this file permissions and make it only accessible by you. To change permissions enter the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod 400 WebServer.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now connect to your instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i WebServerKP.pem ec2-user@54.84.177.115
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the following response you successfully connected to your instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-172-31-85-146 ~]$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Clean up your instance
&lt;/h1&gt;

&lt;p&gt;After you have finished with the instance, you should clean up by terminating the instance. If you forget to terminate your instance it will incur charges if you are not within the &lt;a href="https://aws.amazon.com/free/"&gt;AWS Free Tier&lt;/a&gt;. If you want to use your instance later you can &lt;em&gt;stop&lt;/em&gt; it and &lt;em&gt;start&lt;/em&gt; it again later.&lt;/p&gt;

&lt;p&gt;To terminate your instance:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In &lt;strong&gt;Instances&lt;/strong&gt; page, select your instance.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Instance state&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Terminate instance&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;When prompted click &lt;strong&gt;Terminate&lt;/strong&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xHWZrbol--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g9a066p9d7s8ugmftvhj.png" alt="Alt Text" width="880" height="462"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After your instance is terminated, it remains visible on the console for a short while until data on instance store volumes deleted, and then the entry automatically deleted.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>ec2</category>
      <category>cloudcomputing</category>
      <category>cloud</category>
    </item>
  </channel>
</rss>
