user_data = <<-EOL
#!/bin/bash
sudo amazon-linux-extras install nginx1
sudo systemctl start nginx
sudo systemctl status nginx
echo "Hello World from ec2" > /usr/share/nginx/html
EOL
Search amazon-linux-extras
$ yum search nginx
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
31 packages excluded due to repository priority protections
============================================================ N/S matched: nginx =============================================================
pcp-pmda-nginx.x86_64 : Performance Co-Pilot (PCP) metrics for the Nginx Webserver
Name and summary matches only, use "search all" for everything.
$ amazon-linux-extras list | grep nginx
38 nginx1 available [ =stable ]
$ amazon-linux-extras info nginx1
nginx1 recommends nginx # yum install nginx
$ sudo amazon-linux-extras install nginx1
Installing nginx
Failed to set locale, defaulting to C
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Cleaning repos: amzn2-core amzn2extra-docker amzn2extra-kernel-5.10 amzn2extra-nginx1
17 metadata files removed
6 sqlite files removed
0 metadata files removed
.....
$ nginx -v
nginx version: nginx/1.22.0
$ sudo systemctl start nginx
$ sudo systemctl status nginx
* nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2023-01-05 23:05:20 UTC; 5s ago
Process: 3450 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 3446 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 3445 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 3452 (nginx)
CGroup: /system.slice/nginx.service
|-3452 nginx: master process /usr/sbin/nginx
`-3453 nginx: worker process
Failed to set locale, defaulting to C
export LC_ALL=C
user_data = <<-EOL
#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
echo "Hello World from EC2" > /var/www/html/index.html
EOL