Cloud server with a Raspberry Pi

Cloud server with a Raspberry Pi

Turning your Raspberry Pi into a personal cloud server is a useful and secure project. With Nextcloud, you can securely store, synchronize and share your files. Here's a detailed guide to help you get started.

Contents

  1. Introduction
  2. Equipment required
  3. Preparing the Raspberry Pi
  4. Installing Nextcloud
  5. Nextcloud configuration
  6. Securing the Cloud Server
  7. Remote Access
  8. Testing and adjustment
  9. Conclusion

1. Introduction

A personal cloud server lets you store, synchronize and share your files securely and privately. Using a Raspberry Pi and Nextcloud, you can create a cloud solution accessible from anywhere.

2. Materials required

  • Raspberry Pi (model 3 or higher)
  • microSD card (minimum 16 GB) with Raspbian installed
  • External hard disk or USB key for storage
  • Ethernet cable or Wi-Fi connection
  • Power supply for Raspberry Pi

3. Preparing the Raspberry Pi

  1. Install Raspbian :
    • Download the Raspbian image from the official website.
    • Use a tool like balenaEtcher to burn the image onto the microSD card.
    • Insert the microSD card into the Raspberry Pi and start it up.
  2. Configuring the Raspberry Pi :
    • Log in with the default credentials (user : pipassword : raspberry).
    • Update the system with the following commands:
      • sudo apt update
      • sudo apt upgrade

4. Installing Nextcloud

  1. Installing Apache, PHP and MariaDB :
    • Nextcloud requires a web server, a scripting language and a database:
      • sudo apt install apache2
      • sudo apt install php libapache2-mod-php php-mysql
      • sudo apt install mariadb-server
  2. Securing MariaDB :
    • Run the MariaDB security script:
      • sudo mysql_secure_installation
  3. Creating a database for Nextcloud :
    • Connect to MariaDB and create a database:
sudo mysql -u root -p
CREATE DATABASE nextcloud;
CREATE USER 'ncuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'ncuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

4. Download and install Nextcloud :

  • Download the latest version of Nextcloud :
    • wget https://download.nextcloud.com/server/releases/latest.tar.bz2
    • tar -xjf latest.tar.bz2
    • sudo mv nextcloud /var/www/html/

Setting permissions :

  • Grant the necessary permissions to Nextcloud files:
    • sudo chown -R www-data:www-data /var/www/html/nextcloud
    • sudo chmod -R 755 /var/www/html/nextcloud

5. Nextcloud configuration

  1. Configuring Apache for Nextcloud :
    • Create a configuration file for Nextcloud :
      • sudo nano /etc/apache2/sites-available/nextcloud.conf
    • Add the following content:
DocumentRoot /var/www/html/nextcloud/
    ServerName your_domain_or_ip

    
        Options +FollowSymlinks
        AllowOverride All

        
            Dav off
        

        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud
    

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

2. Activate the site and Apache modules :

  • Activate Nextcloud configuration and the required modules:
    • sudo a2ensite nextcloud.conf
    • sudo a2enmod rewrite headers env dir mime
    • sudo systemctl restart apache2

Browser access to Nextcloud :

  • Open a web browser and go to http://your_domain_or_ip/nextcloud to complete the installation.

6. Securing the cloud server

  1. Installing an SSL certificate with Let's Encrypt :
    • Secure your server with an SSL certificate:
      • sudo apt install certbot python3-certbot-apache
      • sudo certbot --apache -d your_domain
  2. Automatic certificate renewal :
    • Configure automatic certificate renewal :
      • sudo crontab -e
    • Add the following line to renew the certificate every day:
      • 0 3 * * * /usr/bin/certbot renew --quiet

7. Remote access

  1. Configuring external access :
    • If you want to access Nextcloud from outside your local network, configure port forwarding on your router to redirect port 80 and 443 to your Raspberry Pi.
  2. Use a Dynamic DNS service (optional) :
    • If your public IP changes regularly, use a dynamic DNS service like No-IP to associate a domain name with your dynamic IP address.

8. Tests and adjustments

  1. Test the system :
    • Check that all services are working properly and that you can access Nextcloud from different devices.
  2. Adjust parameters :
    • Customize Nextcloud settings to meet your specific needs, such as configuring storage quotas and users.

9. Conclusion

By following this guide, you now have a working personal cloud server with a Raspberry Pi. You can securely store, synchronize and share your files, and access your personal cloud from anywhere. Enjoy your cloud server, and feel free to explore the many applications and extensions available for Nextcloud to enrich your experience even further!

Leave a Reply

Your email address will not be published. Required fields are marked *