Nextcloud, PHP apps and per-site PHP settings
Host Nextcloud on a Linux web server, give a PHP app more memory, bigger uploads or the functions it needs within limits you set, add folders outside the site and a reviewed nginx include.
Most PHP sites run happily on the defaults. Some apps need more: Nextcloud wants at least 512 MB of memory, large uploads, long requests and functions that are normally switched off, and keeps its data on a separate disk. Tenvara has a Nextcloud runtime that is set up the way Nextcloud documents, and every Linux PHP site has a Settings tab for its own PHP settings, folders outside the site and an nginx include, all within limits you set per server and per hosting plan.
Everything here is for Linux web servers with nginx. A Windows site's settings are on its IIS tab; see Windows hosting: IIS, SQL Server and MySQL.
Creating a Nextcloud site
- Press Create site on Infrastructure > Websites or on an adopted nginx server's page, and fill in the server, customer, name and short name as for any site (see Creating and managing sites).
- Choose the Nextcloud runtime and a PHP version.
- Enter the Domains. Point their DNS at the server before issuing a certificate.
- Under Folders outside the site, add Nextcloud's data folder if it lives on another disk, such as
/srv/nextcloud-data. It must already exist; the site user is given access to it. - Press Create site.
The site gets Nextcloud's documented nginx configuration: the front controller, so /remote.php/dav and the apps work for the sync clients; the /.well-known/carddav and /caldav redirects for calendars and contacts; request bodies buffered, which CalDAV needs; and Nextcloud's private folders (data, config, lib and the rest) refused from the web. Its PHP pool gets Nextcloud's minimums: 512 MB of memory, 512 MB uploads, an hour for long requests, and exec and proc_open allowed for previews. config, data and custom_apps are kept across deploys, so a new release never loses the configuration, the data or the apps installed from the app store.
Then deploy Nextcloud
- On the site's Deploy tab, choose Uploaded artefact and upload Nextcloud's release archive. It is unpacked from inside its
nextcloudfolder, so the release is Nextcloud itself. - On the Database tab, press Create database.
- Open the site in the browser and finish Nextcloud's setup with that database and your data folder.
Run Nextcloud's background jobs from the site's Cron tab. See Site databases, SFTP, cron and logs.
Tip: Nextcloud's admin overview checks the server too. An APCu memory cache, a bigger OPcache interned strings buffer and a maintenance window are server settings in
php.iniand Nextcloud's own configuration, not site settings.
A site's PHP settings
Open the site and its Settings tab. Under PHP, set only what the app needs; empty fields keep the default.
| Setting | What it changes |
|---|---|
| Memory limit (MB) | PHP's memory_limit for this site. |
| Upload size (MB) | One value for the largest upload and post, and nginx's request size, so the three always agree. |
| Time limit (seconds) | How long a request may run. Over 300 seconds, nginx and the PHP pool wait as long. |
| Enable functions | Functions that are disabled for every site unless enabled here, such as exec, proc_open and shell_exec. Only those the limits allow can be enabled. |
| OPcache | Check files for changes, and Check every (seconds), when the limits let sites change OPcache. |
Press Save PHP settings. The site's pool is tested and reloaded, so nothing goes down. Each field says the most it may be (At most 1024 MB here), and a Nextcloud site never goes under Nextcloud's minimums whatever is set. An app's own .user.ini still applies.
Limits you set
You decide how far a site may go:
- Per server: the PHP limits for sites in the server's Settings, on its page under Infrastructure > Web servers.
- Per hosting plan: the same limits on the plan, so customers in the hosting panel stay inside what they pay for. See The hosting panel, resellers and site owners.
Each sets Memory (MB), Uploads (MB), Time limit (seconds), Functions a site may enable and whether Sites may change OPcache settings. A site gets the tighter of its server's and its plan's. With neither set, a site may go up to 1024 MB of memory, 2048 MB uploads and an hour, and enable exec and proc_open. A Nextcloud site needs limits of at least 512 MB that allow exec and proc_open.
Folders outside the site
A site's PHP can use folders besides its own, such as a data disk. On the Settings tab, under Folders outside the site, add up to ten absolute paths and press Save folders.
- A folder must already exist as a real folder, not a link.
- System folders (
/etc,/usr,/var/lib,/var/logand the like), roots the whole server shares (/,/srv,/home,/mnt,/data) and anything inside the sites folder are refused. - If the site user cannot use the folder yet, the server gives it access with an ACL and checks again. If it still cannot, the save is refused and says why, for example a read-only disk.
Each folder is added to the site's open_basedir. Taking a folder off removes the site user's access to it; its files stay.
The nginx include
Some apps need a rule of their own in nginx, such as an extra rewrite. The nginx include on the Settings tab is added inside the site's own server block, before the runtime's rules, at most 16 KiB.
- Enter the directives.
- Press Test and save.
Directives that reach past the site (include, server, listen, certificates, paths outside the site folder and the like) are refused. nginx then tests the include in the site's real configuration; if the test fails, the include and the site's configuration are put back and nginx is not reloaded, so other sites never see it. Only people with the Infrastructure Manage permission can change the include; everyone else sees it read-only on the site page.
Hosting panel servers
Servers run by DirectAdmin, cPanel, Plesk or CloudPanel are recognised and say Managed by with the panel's name on their page. Their services, Apache includes and databases are read the panel's way, so a panel's own unit names and database login do not show up as stopped services or errors. See Web servers.
Related
Was this page helpful?
Thanks for the feedback.