\n
sudo dnf update<\/p>\n<\/div><\/div>\n\n\n\n
This command requires higher system privileges so make sure you use the sudo.<\/p>\n\n\n\n
Often the repositories are up to date once the instance has been provisioned, but it is always a good idea to check, mainly for security and compatibility reasons.<\/p>\n\n\n\n <\/figure>\n\n\n\nStep 5: Install nginx on Amazon Linux<\/h2>\n\n\n\n Now we can install nginx on our Amazon Linux instance by running the following command:<\/p>\n\n\n\n
\n
sudo dnf install nginx<\/p>\n<\/div><\/div>\n\n\n\n <\/figure>\n\n\n\nWe can type y <\/strong>and press Enter <\/strong>in order to continue with the nginx installation.<\/p>\n\n\n\nOnce the installation is complete we need to start and enable the service so it starts each time we boot our system.<\/p>\n\n\n\n
\n
sudo systemctl start nginx<\/p>\n<\/div><\/div>\n\n\n\n
\n
sudo systemctl enable nginx<\/p>\n<\/div><\/div>\n\n\n\n
Since SELinux is present and enabled on Amazon Linux by default we can add a new rule that will allow http connections.<\/p>\n\n\n\n
First, we can verify if SELinux is enabled and running on our system:<\/p>\n\n\n\n
\n
sestatus<\/p>\n<\/div><\/div>\n\n\n\n <\/figure>\n\n\n\nNext, we need to adjust the SELinux policy:<\/p>\n\n\n\n
\n
sudo setsebool -P httpd_can_network_connect 1<\/p>\n<\/div><\/div>\n\n\n\n
Now, we can restart our nginx service so that the configuration is applied:<\/p>\n\n\n\n
\n
sudo systemctl restart nginx<\/p>\n<\/div><\/div>\n\n\n\n
In order to check whether we are getting the nginx start page in our browser, we first need to find our public IP address.<\/p>\n\n\n\n
There are two quick options for this. You can run the curl <\/strong>command that will provide you with the public IP for your instance:<\/p>\n\n\n\n\n
curl ifconfig.me<\/p>\n<\/div><\/div>\n\n\n\n
The output will provide you with your public IP address:<\/p>\n\n\n\n <\/figure>\n\n\n\nThe second option is to check directly in your AWS account, Instances<\/strong> page:<\/p>\n\n\n\n <\/figure>\n\n\n\nNow, if we want to check whether our nginx is correctly configured and also if our access rules across the Amazon Linux system and AWS are working, we can type in the browser:<\/p>\n\n\n\n
\n
http:\/\/3.79.150.186\/<\/p>\n<\/div><\/div>\n\n\n\n
As the output we get the welcome page from nginx.<\/p>\n\n\n\n <\/figure>\n\n\n\nWith your Amazon Linux instance up and running, you can now deploy and run applications, host websites, or perform various computing tasks on the AWS cloud infrastructure. Consider using an elastic network interface<\/a>, or Elastic IP address, to handle failover if your workloads are missions critical. Enjoy the flexibility and scalability that EC2 instances provide for your projects and workloads.<\/p>\n\n\n\n AWS Workshop for Using 探花大神 as an External Identity Provider<\/a>\n","protected":false},"excerpt":{"rendered":"Learn how to set up Amazon Linux on EC2 instances in this step-by-step tutorial.<\/p>\n","protected":false},"author":150,"featured_media":104510,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_oasis_is_in_workflow":0,"_oasis_original":0,"_oasis_task_priority":"","inline_featured_image":false,"footnotes":""},"categories":[2781],"tags":[],"collection":[2778],"platform":[],"funnel_stage":[3017],"coauthors":[2535],"acf":[],"yoast_head":"\n
How to Set Up Amazon Linux on EC2 Instances - 探花大神<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n\t \n\t \n\t \n