How to install Nextcloud on CyberPanel — CyberPanel - WebHosting Control Panel for OpenLiteSpeed

How to install Nextcloud on CyberPanel

To view this tutorial on Nextcloud (with proper Markdown formatting): https://nuage.fiatlux.tk/s/o4gBeiR2gYkmbXR

Prerequisites:

* Create a PHP website/domain with SSL certificate for your Nextcloud site
* Create a blank mysql database for Nextcloud
* SSH access to the VPS (or a SSH access to the website account)
* Alternatively : an FTP access to the website

Steps :

* [ ] 1. Get the Nextcloud archive and installer
* [ ] 2. Run the installer
* [ ] 3. PHP settings (CyberPanel)
* [ ] 4. Nextcloud basic config
* [ ] 5. Force HTTPS (.htaccess)
* [ ] 6. Tweak and optimize your instance

## 1. Get the Nextcloud archive and installer

Select the version of Nextcloud you want to use here: <https://nextcloud.com/install/#instructions-server>

* For SSH, we only need the link to the archive
* For FTP, we need to download the archive and installer first (download installer here: <https://download.nextcloud.com/server/installer/setup-nextcloud.php>)

### SSH (CyberPanel)

Log to your VPS and switch to the webite user. To list usernames for each website:

```
# sudo ls -l /home
```

To switch user :

```
# sudo su <username>
```

I guess you can use a SSH account created in CyberPanel for the website too, in which case you wouldn't need to switch user (I didn't try).

Move to the public directory and download the archive and installer (here with Nextcloud 21.0.0) :

```
# cd ~/public_html
# wget -O nc.zip https://download.nextcloud.com/server/releases/nextcloud-21.0.0.zip
# wget https://download.nextcloud.com/server/installer/setup-nextcloud.php
```

### FTP

Simply upload the archive and the installer to the website's `public_html`. Make sure you rename the archive `nc.zip` before launching the installer.

## 2. Run the installer

Navigate your broswer to `https://<domain>/setup-nextcloud.php` and follow the instructions.

A few notes:

1. *Dependency Check* screen : enter `.` to install Nextcloud at the root of the site (unless you want to access your instance via `https://<domain>/nextcloud/`)
2. Use a (very) strong password for the admin account
3. *Storage and database* :
* *Data directory* : remove `public_html` from the path, eg. enter `/home/<domain>/data` in place of `/home/<domaine>/public_html/data` (default vallue) -- this will ensure that user data will not accidentally get exposed publicly.
* *Database* : select *MySQL/MariaDB* and enter the database credentials. Leave `localhost`as hostname.

There you go, you have a running Nextcloud instance.

## 3. PHP settings (CyberPanel)

We'll override some PHP settings for that specific website instead of tweaking `php.ini` for the entire server. Set this way, they will also apply regardless of the version of PHP used, so you can switch them freely.

In CyberPanel, go to *Websites* > *List Websites* > *Manage* (for the Nextcloud website)

Under *Configurations*, click the *vHost Conf* icon.

Spot the `phpIniOverride` section (which should be empty) and replace it with this and hit the *Save button*:

```
phpIniOverride {
php_value mbstring.func_overload 0
php_value always_populate_raw_post_data -1
php_value default_charset "UTF-8"
php_value output_buffering 0
php_value memory_limit "512M"
php_value max_execution_time 300
php_value upload_max_filesize "1024M"
php_value post_max_size "1280M"
php_value max_input_time 600
}
```

(Some of these values would be debatable, be my guest!)

## 4. Nextcloud basic config

Edit the Nextcloud configuration file located at `~/public_html/config/config.php` (or `~/public_html/nextcloud/config/config.php` if Nextcloud was installed in the default directory).

```
# nano ~/public_html/config/config.php
```

For now, we'll simply set the default locale/language and get rid of the ugly `index.php` compound in the URLs. Insert the following lines, save and exit (CTRL+X in nano):

```
'default_locale' => 'en_US',
'default_language' => 'en',
'htaccess.RewriteBase' => '/',
'htaccess.IgnoreFrontController' => true,
```

Then ask Nextcloud to rebuild `.htaccess` to account the changes (you need SSH for this).

```
# php ~/public_html/occ maintenance:update:htaccess
```

> Doing so might destroy custom rules in your `.htaccess`, that's why we do it now. You only need to run that command if you change any `htaccess.*` value.

## 5. Force HTTPS (.htaccess)

In CyberPanel, go to *Websites* > *List Websites* > *Manage* (for the Nextcloud website)

Under *Configurations*, click the *Rewrite Rules* icon.

Right under `#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####`, paste the following:

```
<IfModule mod_rewrite.c>
## Forcer HTTPS
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTPHOST}%{REQUESTURI} [R,L]
</IfModule>
```

## 6. Tweak and optimize your instance

There is *a lot more* you can do to optimize your Nextcloud instance. A good start is to login into your Nextcloud administrator account, navigate to *Settings* (top right menu) > *Overview*, and follow the recommendations that show up on that screen.

Comments

  • I get it to work in much much simplest way. However, I found issue with SSL (rewrite rule) and can't figure where is mistake.

    So, my manual cli installation of CyberPaanel is different from original only as docRoot is not on /var/www/ instead it is on /home/xxxx.mydomain.com/nectcloud/. However, rewrite rules what worth for other PHP applications (WP, Matomo, …) not works here. I have message as - "This website does not supply ownership information".

    So, vHost (part) looks like:

    docRoot $VH_ROOT/seopanel
    vhDomain $VH_NAME
    vhAliases www.$VH_NAME
    ...
    enableGzip 1
    enableIpGeo 1

    Rules are:

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

    What I’m doing wrong?
  • edited March 23
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

    Browser showing "This website does not supply ownership information" indicates a problem with the SSL certificate.

    CyberPanel uses /home/<domain>/public_html as default docRoot. Why not stick with it?

    As for my tutorial, I wanted to balance between being as straightforward as thorough, assuming a fairly standard CyberPanel installation. From those steps, anyone would easily know where to look if they needed to tweak something. You'll need to go through any of those essential steps at some point anyway.

    But every path leads to Rome! If you've found a simplest way to get a Nextcloud up and running, please kindly share it with us!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!