Install Nextcloud with LAMP stack on Debian 12 Bookworm

This tutorial intends to teach you to Install and Configure Nextcloud with LAMP Stack on Debian 12 Bookworm. Nextcloud is a great collaboration platform that allows teamwork to share documents, send or receive emails, manage calendars, and communicate via secure video chats. You can follow this instruction to set up the Nextcloud from the source and access it from the web interface.

Install Nextcloud with LAMP stack on Debian 12 Bookworm

To set up Nextcloud, you must have access to your server as a non-root user with sudo privileges and set up a basic firewall. For this purpose, you can visit the Initial Server Setup with Debian 12 Bookworm.

Because we want to install Nextcloud with LAMP, you must have it installed on your server. To do this, you can check this guide on How To Install LAMP Stack on Debian 12.

Also, you need a domain name that is pointed to your server’s IP address.

Step 1 – PHP Configuration for Nextcloud on Debian 12

At this point, you need to install some additional PHP extensions for Nextcloud on your server. To do this, run the command below:

sudo apt -y install php-{cli,xml,zip,curl,gd,cgi,mysql,mbstring,fpm}

Then, you need to add the FPM support and restart your Apache service by using the following commands:

# sudo a2enmod proxy_fcgi setenvif
# sudo a2enconf php8.2-fpm
# sudo systemctl restart apache2

Step 2 – Set up Nextcloud Database and User on Debian 12

At this point, you need to create a user and database for Nextcloud. First, log in to your MariaDB shell with the following command:

sudo mysql -u root -p

Then, from your MariaDB shell run the command below to create your user, here we named it nextcloud-user, remember to choose a strong password for it:

MariaDB [(none)]> CREATE USER 'nextcloud-user'@'localhost' IDENTIFIED BY "password";

Next, use the command below to create your database, here we named it nextclouddb:

MariaDB [(none)]> CREATE DATABASE nextclouddb;

Now you need to grant all the privileges to your Nextcloud DB with the command below:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextclouddb.* TO 'nextcloud-user'@'localhost';

Flush the privileges and exit from your MariaDB shell with the commands below:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

Step 3 – Download Latest Nextclould from Official Site on Debian 12

At this point, you need to visit the Nextcloud official page and download it. Right-click on the Download for server from the Archive file and copy the link address.

Then, use the wget command to download Nextcloud on Debian 12 Bookworm:

sudo wget https://download.nextcloud.com/server/releases/latest.zip

Unzip your downloaded file with the command below:

sudo unzip latest.zip

Next, move your extracted file to the /var/www/html/ directory:

sudo mv nextcloud/ /var/www/html/

Now Set the correct ownership for your Nextcloud directory:

sudo chown -R www-data:www-data /var/www/html/nextcloud

Step 4 – Configure Apache VirtualHost For Nextcloud on Debian 12

At this point, you need to create an Apache configuration file for Nextcloud, to serve the file in case you are using the domain name or multiple websites are running on the same server.

Create and open your file with your favorite text editor, here we use the vi editor:

sudo vi /etc/apache2/sites-available/nextcloud.conf

Add the following content to your file:

Remember to change the domain name with yours.

<VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/nextcloud
     ServerName example.com
     ServerAlias www.example.com

     <Directory /var/www/html/nextcloud/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
    
     <Directory /var/www/html/nextcloud/>
            RewriteEngine on
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*) index.php [PT,L]
    </Directory>
</VirtualHost>

When you are done, save and close the file.

At this point, you need to disable the default Apache configuration and enable the new one you have created above:

# sudo a2dissite 000-default.conf
# sudo a2ensite nextcloud.conf

Also, enable a few modules with the command below:

sudo a2enmod headers rewrite env dir mime

Finally, restart Apache to apply the changes:

sudo systemctl restart apache2

Step 5 – How To Access and Install Nextcloud from Web Interface?

At this step, you can easily access your Nextcloud dashboard from the web interface on Debian 12 Bookworm. Open your web browser and type your server’s IP address or domain name:

http://your-server-ip-address
or
http://your-domain.com

You will see the following screen. You need to create an Admin user and password and Then enter the details of the Database you have created. In the end, click Install.

Nextcloud admin account

Now the NextCloud Dashboard will be there to access and store your data.

nextcloud dashboard

That’s it, you are done.

Conclusion

At this point, you have learned to Install and Configure Nextcloud with LAMP stack on Debian 12 Bookworm. With Netcloud you can store your data and documents and share it with your teamwork. Hope you enjoy using it.

You may be interested in these articles:

Install the Latest Apache Solr on Debian 12 Bookworm

Install Rust on Debian 12 From Linux Terminal

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!