This userdata is only for Amazon Linux 2023 on EC2
With this script, you can install a full LAMP environment with auto Let's Encrypt credential issuing on Amazon Linux 2023 without any 3rd party repository.
- Operation System: Amazon Linux 2023
- Domain Name: Hosted your domain name on Route 53. How to use Amazon Route53 API
- Instance Type:
t3.small
or above. - fill thes arguments:
DOMAIN
: your domain name on route 53.MAIL
: your email for Let's encrypts issue progress.AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
: the IAM user's AKSK which has the permission to update your domain for the domain owner confirmation.ROOT_DB_PASSWORD
: the root password of MariaDB.NC_DB_NAME
: the database name for nextcloud.NC_DB_USER
: the user who has the full permssion of the database above.NC_DB_PASSWORD
: the password of the user above.NC_MAINTENANCE_WINDOW
: the maintenance window for nextcloud (UTC+0).
- Click the
Advanced details
tab in the button of theLaunch an instance
page. - Scrolling down to the button, copy & paste the user data contents. PLEASE REMEMBER TO UPDATE THE ARGUMENTS.
- Click
Launch instance
. - Attache an Elastic IP to your instance to prevent which released after stop/start.
- Add an A record to your domain of the Elastic IP in Route53.
- SSH into your instance, run the commands below to check the status. If you see string like
Cloud-init v. 22.2.2 finished at xxxx. Datasource DataSourceEc2. Up xxx seconds
means the environment build successful.
$ tail -f /var/log/cloud-init-output.log
# OR
$ cat /var/log/cloud-init-output.log
- when done the script done, open your domain in browser to install nextcloud.
- click
Storage & database
and selectMySQL&MariaDB
. (You can change the data path to other destination.) - Paste the DB info and click
install
.
- Amazon Linux 2023 is no providing
php8.3-imagick
package. - You can consider to connect with ElastiCache for the Redis/Memcached cache (More cost!!)
- I will recommend you to enable
External Storages
in Nextcloud and mount S3 as storage to save cost (If you allocated a large EBS volume, no mater how many data you store in EBS it will charge for the full EBS volume size, but S3 only charge the object size you used, and you can access your file form the AWS S3 console even your nextcloud instance is terminated.)