How to Install Nextcloud on Ubuntu for Private Cloud Storage
How to Install Nextcloud on Ubuntu for Private Cloud Storage
In today’s digital age, safeguarding your data while maintaining easy access is crucial. Nextcloud offers a self-hosted, private cloud storage solution, perfect for individuals and organizations that want to avoid relying on third-party services like Google Drive or Dropbox. By setting up Nextcloud on Ubuntu, you can maintain full control of your data, ensuring it remains secure and private. In this guide, we will walk through the process of installing and configuring Nextcloud on an Ubuntu server, helping you create your very own private cloud.
Prerequisites
Before we dive into the installation process, ensure you have the following prerequisites in place:
- A server running Ubuntu 20.04 or later with sudo privileges.
- A domain name (optional but recommended).
- A fully functional LAMP stack (Linux, Apache, MySQL, PHP).
- A static IP address for your server.
- Basic familiarity with using the Linux terminal.
Step 1: Update Your System
Before installing any software, it’s always a good practice to ensure your server’s package list is up to date. Run the following commands:
sudo apt update
sudo apt upgrade
This ensures that your system is using the latest software packages and security updates.
Step 2: Install Apache and PHP
Nextcloud requires a web server and PHP. We’ll use Apache as the web server and install PHP with the necessary modules.
Install Apache:
sudo apt install apache2
Install PHP and necessary extensions:
sudo apt install php libapache2-mod-php php-mysql php-gd php-json php-curl php-xml php-mbstring php-zip
php-intl php-bcmath php-imagick
Make sure Apache is running with the following command:
sudo systemctl start apache2
You can enable Apache to start on boot:
sudo systemctl enable apache2
Step 3: Install and Configure MariaDB
Nextcloud requires a database to store its data. We will use MariaDB, a popular MySQL alternative. Install MariaDB using:
sudo apt install mariadb-server
Once installed, secure MariaDB:
sudo mysql_secure_installation
Follow the prompts to set up a root password and secure the installation by removing unnecessary features.
Now, log into the MariaDB shell:
sudo mysql -u root -p
Create a database and a user for Nextcloud:
CREATE DATABASE nextcloud;
CREATE USER ‘nextclouduser’@’localhost’ IDENTIFIED BY ‘password’;
GRANT ALL PRIVILEGES ON nextcloud.* TO ‘nextclouduser’@’localhost’;
FLUSH PRIVILEGES;
EXIT;
Replace ‘password’ with a secure password.
Step 4: Download and Configure Nextcloud
Visit the Nextcloud download page to get the latest version or use the following command to download it directly to your server:
wget https://download.nextcloud.com/server/releases/nextcloud-25.0.3.zip
Unzip the downloaded file:
unzip nextcloud-25.0.3.zip
Move the extracted files to your web root:
sudo mv nextcloud /var/www/html/
Set the correct ownership and permissions:
sudo chown -R www-data:www-data /var/www/html/nextcloud
sudo chmod -R 755 /var/www/html/nextcloud
Step 5: Configure Apache for Nextcloud
We need to configure Apache to serve the Nextcloud installation. Create a new Apache configuration file for Nextcloud:
sudo nano /etc/apache2/sites-available/nextcloud.conf
Add the following configuration:
ServerAdmin [email protected]
DocumentRoot /var/www/html/nextcloud
ServerName your-domain.comRequire all granted
AllowOverride All
Options FollowSymLinks MultiViewsErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
Replace your-domain.com with your actual domain name or server IP.
Enable the Nextcloud site and necessary Apache modules:
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime setenvif ssl
Finally, restart Apache:
sudo systemctl restart apache2
Step 6: Set Up SSL with Let’s Encrypt (Optional but Recommended)
For enhanced security, it’s important to encrypt your site with SSL. You can easily get a free SSL certificate from Let’s Encrypt. First, install Certbot:
sudo apt install certbot python3-certbot-apache
Obtain and install the SSL certificate by running:
sudo certbot –apache
Follow the on-screen instructions to complete the SSL setup.
Step 7: Complete the Nextcloud Installation via Web Interface
Now that the server-side setup is complete, it’s time to finalize the installation through the Nextcloud web interface.
Open your browser and navigate to your server’s domain or IP:
http://your-domain.com
You’ll be greeted by the Nextcloud setup page. Enter the following details:
- Admin account: Create a username and password for the Nextcloud admin.
- Data folder: The default is /var/www/html/nextcloud/data, but you can change it if needed.
- Database: Select MySQL/MariaDB, then enter the database name (nextcloud), database user (nextclouduser), and the password you set earlier.
Click Finish Setup.
Nextcloud will now configure itself, and you’ll be redirected to your dashboard once the process is complete.
Step 8: Accessing Your Nextcloud Instance
Once the setup is complete, you can start using Nextcloud by accessing your domain or server IP in a browser. You’ll have a fully functional private cloud storage solution, where you can store files, share them with others, and even sync them across devices.
Thank you for visiting our page! Be sure to explore our other articles through the link below to further enhance your Linux skills. Don’t miss out on reading our Encrypt Your Linux System with LUKS article as well! 🙂
How to Encrypt Your Linux System with LUKS in 2024
and if you want to visit nextcloud’s official page, it is here.