# How to edit config.php for Nextcloud snap

**URL:** <https://help.nextcloud.com/t/how-to-edit-config-php-for-nextcloud-snap/218564>\
**Category:** 📑 How to\
**Tags:** snap, wiki, configphp\
**Created:** [February 27, 2025, 11:11am UTC](https://help.nextcloud.com/t/how-to-edit-config-php-for-nextcloud-snap/218564 "2025-02-27T11:11:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scubamuc](https://help.nextcloud.com/user_avatar/help.nextcloud.com/scubamuc/32/63165_2.png) [@scubamuc](https://help.nextcloud.com/u/scubamuc)\
**Post date:** [February 27, 2025, 11:11am UTC](https://help.nextcloud.com/t/how-to-edit-config-php-for-nextcloud-snap/218564/1 "2025-02-27T11:11:02Z")

</div>

# Edit `config.php` for Nextcloud snap

[**PHP configuration options**](https://github.com/nextcloud-snap/nextcloud-snap/wiki/Configure-config.php)

Some Nextcloud snap settings may need to be done directly in the `config.php` configuration file. While the default configurations are mostly fine, you might want to fine tune your Nextcloud snap instance.

Nextcloud snap offers different configuration methods. While some folks prefer editing the configuration file using their favourite editor like `nano`, `vim` or UI texteditors like gedit, kedit etc. the [OCC management console](https://help.nextcloud.com/t/how-to-use-occ-management-console-for-nextcloud-snap/216111/) is a safe and comfortable method to configure your instance.

Regardless which method you prefer, be sure to **backup** your configuration file **before editing**! Take care to preserve the syntax and special characters, as incorrect formatting or misplaced characters and spaces may render your Nextcloud unusable.

> #### TIP
> 
> Some systems don’t add /snap/bin to the PATH. Try
> 
> `sudo /snap/bin/nextcloud.occ`

> #### TIP
> 
> **Nextcloud documentation**
> 
> [Nextcloud configuration parameters](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#configuration-parameters)

## Editing Nextcloud snap configuration file

> #### IMPORTANT
> 
> **Backup** the original `config.php` file **before editing**.

- **Backup** `config.php`

```auto
sudo cp /var/snap/nextcloud/current/nextcloud/config/config.php config.php.bak

```

- **Edit** `config.php`

```auto
sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php 

```

## Setting **trusted domains**

Adding multiple trusted domains manually in `config.php`:

- edit `config.php`

```bash
sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php 

```

and add/edit section

```auto
 'trusted_domains' =>
  array (
    0 => 'cloud.yourdomain.xyz',
    1 => 'cloud.yourotherdomain.zxy',
    2 => 'localhost',
    3 => 'nextcloud.local',
  ),

```

or issue occ command on host (iterating values 0, 1, 2…):

```bash
sudo nextcloud.occ config:system:set trusted_domains 0 --value=cloud.yourdomain.xyz

```

> #### CAUTION
> 
> Be aware that the values for `trusted_domains` should be domain names (see [FQDN](https://en.wikipedia.org/wiki/Fully_qualified_domain_name)). IP addresses are not domain names! See [hosts & FQDN configuration](https://github.com/nextcloud-snap/nextcloud-snap/wiki/Hosts-and-FQDN-for-Nextcloud-snap#fqdn-fully-qualified-domain-name).

## Setting trusted proxies

Adding trusted proxies manually in `config.php`:

edit `config.php` and add/edit section

```
sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php 

```

```auto
  'trusted_proxies' => 
  array (
    0 => 'your.reverse.proxy.ip',
    1 => 'your.other.proxy.ip',
   ),

```

or issue occ command on host (iterating values 0, 1, 2…):

```
sudo nextcloud.occ config:system:set trusted_proxies 0 --value="your.reverse.proxy.ip"

```

> #### CAUTION
> 
> Be aware that these values should be IPv4 or IPv6 addresses in [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) notation see [reverse proxy documentation](https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/reverse_proxy_configuration.html)

## Setting overwrite parameters

[Nextcloud overwrite parameters](https://docs.nextcloud.com/server/27/admin_manual/configuration_server/reverse_proxy_configuration.html#overwrite-parameters) such as `overwriteprotocol` and `overwritehost` are two configs that absolutely depend on your [reverse proxy](https://help.nextcloud.com/t/101-reverse-proxy/194840) setup.

Be aware that some devices require an additional setting in `config.php` if your Nextcloud snap instance is behind a [reverse proxy](https://help.nextcloud.com/t/101-reverse-proxy/194840).

For internet facing Nextcloud snap that handles encryption itself or a pass-through reverse proxy is present it shouldn’t be necessary to set `overwriteprotocol` and `overwritehost`.

edit `config.php` and add/edit section

```auto
    'overwriteprotocol' => 'https',

```

```auto
    'overwritehost' => 'cloud.yourdomain.xyz',

```

or issue occ command on host:

```auto
sudo nextcloud.occ config:system:set overwriteprotocol --value="https"

```

```auto
sudo nextcloud.occ config:system:set overwritehost --value="cloud.yourdomain.xyz"

```

## Setting default maintenance window

Set default maintenance window time 01:00 (1 a.m.)

edit `config.php` and add/edit line in `config.php`

```auto
    'maintenance_window_start' => 1,

```

or issue occ command on host:

```
sudo nextcloud.occ config:system:set maintenance_window_start --value="1"

```

## Setting default phone region

[country codes](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#user-experience)

edit `config.php` and add/edit line in `config.php`

```auto
    'default_phone_region' => 'GB',

```

or issue occ command on host:

```
sudo nextcloud.occ config:system:set default_phone_region --value="GB"

```

## Setting default language

[country codes](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#user-experience)

edit `config.php` and add/edit line in `config.php`

```auto
    'default_language' => 'en',

```

or issue occ command on host:

```
sudo nextcloud.occ config:system:set default_language --value="en"

```

## Setting default locale

[country codes](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#user-experience)

edit `config.php` and add/edit line in `config.php`

```auto
    'default_locale' => 'en_GB',

```

or issue occ command on host:

```
sudo nextcloud.occ config:system:set default_locale --value="en_GB"

```

## Setting default landing app

edit `config.php` and add/edit line in `config.php`

> default value is `""` (empty)

```auto
    'defaultapp' => '<appname>',

```

or issue occ command on host:

```
sudo nextcloud.occ config:system:set defaultapp --value="<appname>"

```

example: `sudo nextcloud.occ config:system:set defaultapp --value="mail"`

or

 ![grafik](https://help.nextcloud.com/uploads/default/original/3X/4/a/4a70bedffe6cad460925c57cbbba41789cb4e099.png)

## Setting Talk push notification

edit `config.php` and add/edit line in `config.php`

```auto
'has_internet_connection' => 'true',

```

or issue occ command on host:

```
sudo nextcloud.occ config:system:set has_internet_connection --value="true"

```

## Setting default folder for shares

edit `config.php` and add/edit line in `config.php`

```auto
    'share_folder' => '/SHARE_with_others',

```

or issue command on host:

```auto
sudo nextcloud.occ config:system:set share_folder --value="/SHARE_with_others"

```

## Setting default folder for shared with me

edit `config.php` and add/edit line in `config.php`

```auto
    'share_folder' => '/SHARED_with_me',

```

or issue occ command on host:

```auto
sudo nextcloud.occ config:system:set share_folder --value="/SHARED_with_me"

```

## Setting trashbin retention

> #### NOTE
> 
> The default setting keeps files and folders in the trashbin for 30 days and automatically deletes anytime after that if space is required.
> 
> add/edit line in `config.php` and add `trashbin_retention_obligation`
> 
> ```auto
> 'trashbin_retention_obligation' => 'auto',
> 
> ```
> 
> to **enable** the background job issue command:
> 
> ```auto
> sudo nextcloud.occ config:app:delete files_trashbin background_job_expire_trash
> 
> ```

**Example** : keep files and folders in the trash bin for at least 90 days and delete when exceeds 120 days

edit `config.php` and add/edit line in `config.php`

```auto
    'trashbin_retention_obligation' => '90, 120',

```

or issue occ command on host:

```auto
sudo nextcloud.occ config:system:set trashbin_retention_obligation --value="90, 120"

```

to **enable** the background job issue command:

```auto
sudo nextcloud.occ config:app:delete files_trashbin background_job_expire_trash

```

to **disable** the background job issue command:

```auto
sudo nextcloud.occ config:app:set --value=no files_trashbin background_job_expire_trash

```

see docs: [https://docs.nextcloud.com/server/latest/admin\_manual/configuration\_files/trashbin\_configuration.html](https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/trashbin_configuration.html)

> #### TIP
> 
> Be aware that files may not be deleted automatically if space is available.  
> To cleanup the trashbin manually run:
> 
> ```auto
> sudo nextcloud.occ trashbin:cleanup --all-users
> 
> ```
> 
> also note, there is a difference between trashbin and groupfolders-trashbin. To cleanup groupfolders-trashbin run:
> 
> ```auto
> sudo nextcloud.occ groupfolders:trashbin:cleanup -f 
> 
> ```

## **Skeleton** for default Nextcloud documents, files and folders etc.

Default documents, files and folders for new users may be placed in a “skeleton” directory. Thus new users will find documents files an folders in their Nextcloud upon first login.

Create a skeleton directory `/var/snap/nextcloud/common/skeleton`

```auto
sudo mkdir /var/snap/nextcloud/common/skeleton

```

Add your default files folders here. You may also add group folders here. See [Group folders app](https://apps.nextcloud.com/apps/groupfolders)

edit `config.php` and add skeleton directory path

```auto
    'skeletondirectory' => '/var/snap/nextcloud/common/skeleton',

```

or issue occ command on host:

```auto
sudo nextcloud.occ config:system:set skeletondirectory --value="/var/snap/nextcloud/common/skeleton"

```

## Secure session cookie

```auto
    'session.cookie_secure' => 'true',

```

or issue command on host:

```auto
sudo nextcloud.occ config:system:set session.cookie_secure --value="true"

```

## Session lifetime, auto log out

the default session lifetime is 24 hours after which an idle user will be logged out automatically. Session lifetime and auto logout may be configured as required.

- [**session\_lifetime**](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#user-session) parameters are not user specific and apply to all users when configured
- [**auto\_logout**](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#auto-logout) is required and dependent on session\_lifetime

> **TIP** :  
> avoid `session_lifetime` below 4 hours in a corporate environment, as users will complain

[https://docs.nextcloud.com/server/latest/admin\_manual/configuration\_server/config\_sample\_php\_parameters.html#user-session](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#user-session)

see [how to edit config.php in Nextcloud snap](https://help.nextcloud.com/t/how-to-edit-config-php-for-nextcloud-snap/218564)

> ### TIP:
> 
> the documentation may be misleading, calculate the value for session\_lifetime:
> 
> - default value 24 hours (`60x60x24`) = `86400`
> - value for 12 hours (`60x60x12`) = `43200`
> - value for 8 hours (`60x60x8`) = `28800`
> - value for 4 hours (`60x60x4`) = `14400`

## Remove signup link

edit `config.php` and add/edit line in `config.php`

```auto
    'simpleSignUpLink.shown' => false,

```

or issue occ command on host:

```auto
sudo nextcloud.occ config:system:set simpleSignUpLink.shown --value="false"

```

## Disable reset password link

If your user backend does not allow password resets (e.g. when it’s a read-only user backend like LDAP), disable password reset link

edit `config.php` and add/edit line in `config.php`

```auto
    'lost_password_link' => 'disabled',

```

or issue occ command on host:

```auto
sudo nextcloud.occ config:system:set lost_password_link --value="disabled"

```

you may however specify a custom link for resetting system password, when clicking the “reset password” link after a failed login-attempt

`'lost_password_link' => 'https://example.org/link/to/password/reset',`

## Setting Nextcloud snap log level

![grafik](https://github.com/user-attachments/assets/3f084149-3ddf-4bc7-86dd-63b7fc34d014)

- set the logging backend [file, syslog, errorlog, systemd]
- set the log level [debug, info, warning, error, fatal]

example command for log level _debug_ (extremely verbose)

```auto
sudo nextcloud.occ log:manage --level=debug

```

example command for log level _info_ (very verbose)

```auto
sudo nextcloud.occ log:manage --level=info

```

example command for log level _warning_ (verbose)

```auto
sudo nextcloud.occ log:manage --level=warning

```

example command for log level _error_ (less verbose)

```auto
sudo nextcloud.occ log:manage --level=error

```

## Nextcloud Text editor file locking timeout

Nextcloud’s file-locking is great for large groups and teams collaborating/editing \*.md documents with the Nextcloud text editor. Folks are using the Notes app will soon bump into locking issues, as notes uses the text editor too. This may cause syncronisation issues on android and IOS devices using the nextcloud notes app.

- simple solution for small instances:
  - disable file locking `sudo nextcloud.occ app:disable files_lock`

- larger instances, set `files_lock` timeout, unlocking files automatically
  - `sudo nextcloud.occ config:app:set files_lock lock_timeout --value=120`

* * *

- [How to configure Nextcloud snap](https://help.nextcloud.com/t/how-to-configure-nextcloud-snap/216036)
- [How to edit config.php for Nextcloud snap](https://help.nextcloud.com/t/how-to-edit-config-php-for-nextcloud-snap/218564)
- [How to manage setup warnings in Nextcloud snap](https://help.nextcloud.com/t/now-to-resolve-setup-warnings-in-nextcloud-snap/216054)
- [PHP configuration options](https://github.com/nextcloud-snap/nextcloud-snap/wiki/Configure-config.php)
- [Nextcloud configuration parameters](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#configuration-parameters)

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [February 27, 2025, 3:46pm UTC](https://help.nextcloud.com/t/how-to-edit-config-php-for-nextcloud-snap/218564/2 "2025-02-27T15:46:13Z")

</div>


