Here's another tutorial for you all on how to setup your own Nextcloud VPS and run your own cloud.
Prerequisites
- Ubuntu Server VPS: Ensure you have access to a blank Ubuntu server VPS.
- Root or Sudo User Access: Ensure you have root or sudo privileges on your server.
Step-by-Step Guide
1. Update Your Server
First, log in to your Ubuntu server via SSH:
ssh username@your_server_ip
Then, update your package list and upgrade your packages:
sudo apt update
sudo apt upgrade -y
2. Install Apache
Install Apache web server:
sudo apt install apache2 -y
Ensure Apache is running:
sudo systemctl start apache2
sudo systemctl enable apache2
3. Install MySQL
Install MySQL server:
sudo apt install mysql-server -y
Secure your MySQL installation:
sudo mysql_secure_installation
Follow the prompts to set a root password and secure your installation.
4. Install PHP
Install PHP and required extensions:
sudo apt install php php-mysql libapache2-mod-php php-cli php-gd php-json php-curl php-mbstring php-intl php-imagick php-xml php-zip -y
Restart Apache to load PHP modules:
sudo systemctl restart apache2
5. Create a MySQL Database and User for Nextcloud
Log in to the MySQL root user:
sudo mysql -u root -p
Create a database and a user for Nextcloud:
CREATE DATABASE nextcloud_db;
CREATE USER 'nextcloud_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON nextcloud_db.* TO 'nextcloud_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
6. Download and Install Nextcloud
Navigate to the web root directory:
cd /var/www/html
Download the latest Nextcloud package:
sudo wget https://download.nextcloud.com/server/releases/latest.zip
Install unzip
if you don't have it:
sudo apt install unzip -y
Extract the Nextcloud package:
sudo unzip latest.zip
Change ownership of the Nextcloud directory to the Apache user:
sudo chown -R www-data:www-data /var/www/html/nextcloud
sudo chmod -R 755 /var/www/html/nextcloud
7. Configure Apache for Nextcloud
Create a new Apache configuration file for Nextcloud:
sudo nano /etc/apache2/sites-available/nextcloud.conf
Add the following content to the file:
<VirtualHost *:80>
DocumentRoot /var/www/html/nextcloud
ServerName your_domain_or_ip
<Directory /var/www/html/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud
</Directory>
ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>
Enable the new configuration and the necessary Apache modules:
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime setenvif ssl
sudo systemctl restart apache2
8. Complete the Installation via Web Browser
Open your web browser and navigate to your server's IP address or domain:
http://your_domain_or_ip
You will be redirected to the Nextcloud setup page. Follow the on-screen instructions to complete the installation:
- Create an admin account.
- Enter the database details:
- Database user:
nextcloud_user
- Database password:
your_password
- Database name:
nextcloud_db
- Database host:
localhost
9. Secure Your Nextcloud Installation with HTTPS
(Optional but recommended) Set up an SSL certificate for your domain using Let's Encrypt:
Install Certbot:
sudo apt install certbot python3-certbot-apache -y
Obtain and install the SSL certificate:
sudo certbot --apache
Follow the prompts to configure HTTPS.
Additional Configuration
Security Tips
- Regularly update Nextcloud, Apache, and your server packages.
- Consider installing security plugins and configuring additional security settings within Nextcloud.
Troubleshooting
- Database Connection Errors: Double-check your database credentials.
- File Permissions Issues: Ensure that the Nextcloud files have the correct permissions (e.g., 755 for directories and 644 for files).
- 500 Internal Server Errors: Check your Apache and Nextcloud configuration files for errors.
Following these steps will help you set up a Nextcloud instance on a blank Ubuntu server VPS. If you encounter any issues, refer to the Nextcloud documentation or seek help from the community forums.