EC2 Instance Setup
Launch and secure your Ubuntu EC2 instance to serve ownCloud or manage deployments.
To run ownCloud and serve as the interface for file uploads, we begin by launching and configuring an Amazon EC2 instance.
This chapter walks you through the creation of the EC2 instance, setting up the web server, PHP environment, and preparing it to host ownCloud.

Prerequisites:
An AWS account with access to EC2
Step 0: Create Key Pair and Security Group
0.1 Create a Key Pair
Go to EC2 Dashboard → Key Pairs
Click Create Key Pair
Set:
Name:
owncloud-key
(or any name)Key pair type: RSA
Private key format:
.pem
Click Create key pair – the
.pem
file will download automatically
0.2 Create a Security Group
Go to EC2 Dashboard → Security Groups
Click Create Security Group
Set:
Name:
owncloud-sg
Description: OwnCloud Security Group
Under Inbound Rules, add the following:
HTTTP
TCP
80
Custom 0.0.0.0/0
Custom TCP
TCP
8000
Custom 0.0.0.0/0
All Traffic
All
All
Custom 0.0.0.0/0
Under Outbound Rules, add the following:
SSH
TCP
22
Custom 103.167.131.175/32
HTTP
TCP
80
Custom 0.0.0.0/0
HTTPS
TCP
443
Custom 0.0.0.0/0
Custom TCP
TCP
8000
Custom 0.0.0.0/0
Click Create Security Group.
Step 1: Launch EC2 Instance
Go to AWS Console → EC2 → Launch Instance
Choose:
Ubuntu 22.04 LTS (or Amazon Linux 2)
t2.micro (or higher)
Configure:
Add inbound rules for HTTP (80), HTTPS (443), SSH (22)
Launch the instance and connect using:
ssh -i "your-key.pem" ubuntu@<your-ec2-public-ip>

Step 2: Create Setup Script
To automate the LAMP stack and ownCloud setup, create a bash script.
nano setup-owncloud.sh
Paste this script:
#!/bin/bash
# Update system
sudo apt update && sudo apt upgrade -y
# Install Apache
sudo apt install apache2 -y
sudo systemctl enable apache2
sudo systemctl start apache2
# Install MySQL
sudo apt install mysql-server -y
sudo mysql -e "CREATE DATABASE owncloud_db;"
sudo mysql -e "CREATE USER 'owncloud_user'@'localhost' IDENTIFIED BY 'strongpassword';"
sudo mysql -e "GRANT ALL PRIVILEGES ON owncloud_db.* TO 'owncloud_user'@'localhost';"
sudo mysql -e "FLUSH PRIVILEGES;"
# Install PHP & Extensions (because Owncloud supports versions 7.4 or below)
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
sudo apt install php7.4 php7.4-mysql php7.4-cli php7.4-common php7.4-xml php7.4-zip php7.4-mbstring php7.4-curl php7.4-gd php7.4-intl -y
sudo systemctl restart apache2
# Download & Install ownCloud
sudo apt install unzip -y
wget https://download.owncloud.com/server/stable/owncloud-complete-latest.zip
unzip owncloud-complete-latest.zip
sudo mv owncloud /var/www/html/
sudo chown -R www-data:www-data /var/www/html/owncloud
sudo chmod -R 755 /var/www/html/owncloud
# Configure Apache
echo '<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
DocumentRoot /var/www/html/owncloud
ServerName <your_ec2_public_ip>
<Directory /var/www/html/owncloud/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>' | sudo tee /etc/apache2/sites-available/owncloud.conf
sudo a2ensite owncloud.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
echo "ownCloud installation complete! Open http://your-ec2-public-ip to configure."
Step 3: Make the Script Executable
chmod +x setup-owncloud.sh
Run the script:
sudo ./setup-owncloud.sh
This installs:
Apache web server
MySQL (and sets up database, user, and password)
PHP 7.4 with required modules
ownCloud from the official source
Step 4: Access ownCloud from Browser
Once the script finishes, open your browser:
http://<your-ec2-public-ip>
You’ll be greeted by the ownCloud setup page.
Step 5: Complete ownCloud Installation (GUI)
Fill in the following on the web setup screen:
Admin Username: Choose your own
Password: Set a strong one
Data Folder:
/var/www/html/owncloud/data
Step 6: Database Configuration:
Database Type: MySQL/MariaDB
Database Name:
owncloud_db
DB User:
owncloud_user
Password:
strongpassword
Host:
localhost
Click Finish Setup
You are Done ✅
ownCloud will finish configuring and take you to the dashboard. You’re now ready to move on to the next steps:
Connect ownCloud to your deduplication API
Upload files → monitor Lambda triggers → S3 deduped storage
Visual Walkthrough: Installing ownCloud on EC2
Prefer to watch and follow along? This video walks you through launching an EC2 instance and setting up ownCloud step by step:
Last updated