Create EC2 instance
- t2.micro
- Ubuntu 20.04 LTS
- Add security groups so you can access both 22 and 80 (and 443 if adding SSL)
Install required packages
SSH into your instance and run...
sudo apt update
sudo apt install apache2 mariadb-server libapache2-mod-php7.4
sudo apt install php7.4-gd php7.4-mysql php7.4-curl php7.4-mbstring php7.4-intl
sudo apt install php7.4-gmp php7.4-bcmath php-imagick php7.4-xml php7.4-zip
Create db and user:
sudo /etc/init.d/mysql start
sudo mysql -uroot -p
Press enter for password
Then a MariaDB [root]> prompt will appear. Now enter the following lines, replacing username and password with appropriate values, and confirm them with the enter key:
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
quit;
Download nextcloud zip file:
wget [https://download.nextcloud.com/server/releases/nextcloud-23.0.2.zip](https://download.nextcloud.com/server/releases/nextcloud-23.0.2.zip)
Install unzip:
sudo apt install unzip
Unzip file and copy to webroot:
unzip nextcloud-x.y.z.zip
cp -r nextcloud /var/www
Apache Web server configuration
Create conf file for apache:
sudo touch /etc/apache2/sites-available/nextcloud.conf
Edit nextcloud.conf:
sudo nano /etc/apache2/sites-available/nextcloud.conf
Alias /nextcloud "/var/www/nextcloud/"
<Directory /var/www/nextcloud/>
Satisfy Any
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
Then enable the newly created site:
a2ensite nextcloud.conf
Additional Apache configurations
For Nextcloud to work correctly, we need the module mod_rewrite
. Enable it by running:
a2enmod rewrite
Additional recommended modules are mod_headers
, mod_env
, mod_dir
and mod_mime
:
a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime
Now restart Apache:
service apache2 restart
After restarting Apache you must complete your installation by running the graphical Installation Wizard. To enable this, change the ownership on your Nextcloud directories to your HTTP user:
chown -R www-data:www-data /var/www/nextcloud/
Additional optional steps:
- SSL
- pretty URLs
- increase memory limit