- Enhanced privacy and security
- Cost-effective
- Scalable
- Greater control and customization
- A computer running Ubuntu or any Debian-based distribution.
- Verify if your ISP allows port forwarding [Optional]
- Own a domain [Optional]
sudo apt update
sudo apt full-upgrade
sudo apt autoremove
sudo apt install neovim wget mariadb-server php php-apcu php-bcmath php-cli php-common php-curl php-gd php-gmp php-imagick php-intl php-mbstring php-mysql php-zip php-xml unzip nmap
- Modify the file to assign an appropriate hostname or domain name to your server.
sudo nvim /etc/hostname
sudo nvim /etc/hosts
- Restart your server to apply the changes.
sudo reboot
- Download the Nextcloud ZIP file.
wget https://download.nextcloud.com/server/releases/latest.zip
- Check the status of the
mariadb
service.
systemctl status mariadb
- Run the secure installation script.
sudo mysql_secure_installation
- Follow the prompts with the provided inputs:
Password prompt --> Press Enter
Switch to unix_socket_auth [Y/n] --> n
Change the root password [Y/n] --> Y
Enter your secure password:
Remove anonymous users [Y/n] --> Y
Disallow root login remotely [Y/n] --> Y
Remove test database and access to it [Y/n] --> Y
Reload privilege tables now [Y/n] --> Y
- Access MariaDB.
sudo mariadb
- Create the database.
CREATE DATABASE nextcloud;
- Set up permissions.
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'mypassword';
FLUSH PRIVILEGES;
- Exit by pressing
CTRL+D
.
- Enable the necessary PHP extensions.
sudo phpenmod bcmath gmp imagick intl
- Unzip the Nextcloud file.
unzip latest.zip
- Move the files to the serving location and set the appropriate permissions.
mv nextcloud your.domain.name
sudo chown -R www-data:www-data your.domain.name
sudo mv your.domain.name /var/www
- Disable the default Apache site.
sudo a2dissite 000-default.conf
- Create an Apache config file for serving Nextcloud.
sudo nvim /etc/apache2/sites-available/your.domain.name.conf
- Insert the following content into the file, modifying
your.domain.name
as needed:
<VirtualHost *:80>
DocumentRoot "/var/www/your.domain.name"
ServerName your.domain.name
<Directory "/var/www/your.domain.name/">
Options MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
TransferLog /var/log/apache2/your.domain.name_access.log
ErrorLog /var/log/apache2/your.domain.name_error.log
</VirtualHost>
- Enable the site.
sudo a2ensite your.domain.name.conf
- Edit the PHP configuration file.
sudo nano /etc/php/8.1/apache2/php.ini
- Locate and modify the following parameters:
memory_limit = 3G # Increase if you have more RAM
upload_max_filesize = 50G # Adjust based on your needs
max_execution_time = 3600
post_max_size = 50G # Adjust based on your needs
date.timezone = Europe/London # Adjust your timezone
opcache.enable=1
opcache.interned_strings_buffer=128
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1
- Enable PHP modules for Apache.
sudo a2enmod dir env headers mime rewrite ssl
- Restart Apache.
sudo systemctl restart apache2
- Upon first access, you will see a setup page.
- Enter the following information:
Username --> Your desired username
Password --> Set a secure password
Data Folder --> Leave as default
Database user --> nextcloud
Database password --> Your database password
Database name --> nextcloud
- Install the recommended apps.
- To access Nextcloud from outside your private network, enable port forwarding on your router.
- Example configuration for a Movistar router:
- Find your private IP using:
ifconfig -a
- Configure port forwarding in your router settings, enabling port 80 for your IP.
- Verify port 80 is open:
sudo nmap -n -PN -sT -sU -p80 {IP}
- Check if the Nextcloud page is accessible by entering your public IP in a web browser.
- To access Nextcloud via your public IP, edit the
config.php
file:
sudo nvim /var/www/your.domain.name/config/config.php
- Add your public IP to the
trusted_domains
array.
- Purchase or obtain a domain from providers like:
- In Advanced DNS settings, create a host record with your public IP.
- Edit the
config.php
file to add your domain to thetrusted_domains
array.
- Install
snapd
andcertbot
:
sudo apt install snapd
sudo snap install core && sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
- Obtain and install your certificates:
sudo certbot --apache
- Search online forums for solutions.
- For further assistance, contact me via email.
Please submit a pull request for any errors or suggestions.