Monday, August 9, 2021

Setting up nginx on AWS Ec2 Linux 2 AMI

Trying to run sudo yum install nginx 


Gave the below error 


sudo yum install nginx

Failed to set locale, defaulting to C

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd

amzn2-core                                                                                                 | 3.7 kB  00:00:00     

No package nginx available.

Error: Nothing to do



nginx is available in Amazon Linux Extra topic "nginx1"


To use, run

# sudo amazon-linux-extras install nginx1


The /etc/nginx/ folder showed the installation. However, running nginx was giving error not found 



Learn more at

https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras



sudo amazon-linux-extras install nginx1



I'd personally use Amazon's own repo.


The version provided by the Amazon repo is relatively old (1.12.2 at the time of writing). To see what versions the Amazon repo has access to run


amazon-linux-extras list | grep nginx



Alternative way to install that could be easier (has a fairly recent version of Nginx):


Below followed and go the nginx working well 


 sudo amazon-linux-extras list | grep nginx

 38  nginx1=latest            disabled      [ =stable ]


$ sudo amazon-linux-extras enable nginx1

 38  nginx1=latest            enabled      [ =stable ]

        

Now you can install:

$ sudo yum clean metadata

$ sudo yum -y install nginx

    

$ nginx -v

nginx version: nginx/1.16.1



References:

https://stackoverflow.com/questions/57784287/how-to-install-nginx-on-aws-ec2-linux-2

No comments:

Post a Comment