Nextcloud + PHP = Postgresql + Apache

How are you?

I am trying to install Nextcloud with postgresql, apache and php. Follow the Official Nexcloud doc I can run apache ok, postgresql ok and php ok. But when try to access the web: it shows this

The apache service here

Postgresql service:here

Are my first steps on apache web server
I have not much experience with it

But, I need to up nextcloud service with postgresql.

Please Somebody can help me?



You don’t have php enabled in apache. That is the first problem.


sudo a2enmod php7
sudo systemctl restart apache2

Then try the test URL again.


Thanks answer but, still does not work!

It shows me Object not found


Here it shows me

The apache2 status

systemctl status apache2         
**●** apache2.service - The Apache Webserver
   Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled)
   Active: **active (running)** since Mon 2021-04-05 14:22:09 -03; 14s ago
  Process: 1901 ExecStop=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k graceful-stop (code=exited, status=0/SUCCESS)
 Main PID: 1909 (httpd-prefork)
   Status: "Processing requests..."
    Tasks: 7
   CGroup: /system.slice/apache2.service
           ├─1909 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/ -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /e>
           ├─1915 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/ -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /e>
           ├─1916 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/ -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /e>
           ├─1917 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/ -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /e>
           ├─1918 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/ -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /e>
           ├─1919 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/ -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /e>
           └─1921 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/ -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /e>

abr 05 14:22:09 srvnc systemd[1]: Starting The Apache Webserver...
abr 05 14:22:09 srvnc systemd[1]: Started The Apache Webserver.

And nextcloud vhost.d

**/etc/apache2/vhosts.d #** cat nextcloud.conf  
<VirtualHost *:80>
  DocumentRoot /srv/www/htdocs/nextcloud

  <Directory /srv/www/htdocs/nextcloud>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews

    <IfModule mod_dav.c>
      Dav off


How did you install nextcloud? Did you install it via YaST and get the openSUSE version or did you get it directly from nextcloud?

The reason is that if you instal the openSUSE version via YaST it puts a configuration file in as /etc/apache2/conf.d/nextcloud.conf.

I have two systems running nextcloud one is installed manually and the other via YaST. On the manually installed one I simply have this:

    Alias /nextcloud /srv/www/htdocs/sites/
    <Directory /srv/www/htdocs/sites/>
            Options +FollowSymlinks
            AllowOverride All

in the virtual host file and followed the nextcloud documentation.

I also have the following in /etc/apache2/conf.d/mod_php7.conf

Cumulus:/etc/apache2/conf.d # cat mod_php7.conf 
<IfModule mod_php7.c>
       <FilesMatch "\.ph(p[3457]?|tml)$">
           SetHandler application/x-httpd-php
       <FilesMatch "\.php[3457]?s$">
           SetHandler application/x-httpd-php-source
        DirectoryIndex index.php4
        DirectoryIndex index.php5
        DirectoryIndex index.php7
        DirectoryIndex index.php


I installed nextcloud manually trying to follow nextcloud documentation with postgresql + php-fpm + apache
Ow, I will try to follow mode_php_7.conf. This part I do not config.

I go to check again!

Thanks attention and help!


If you had just installed the nextcloud packages from openSUSE,
Then everything would practically work from the moment the install completed.

Since you installed nextcloud manually following nextcloud documentation, you’ll have to do <everything> described in the documentation to install and configure.
The question is… do you really want to continue what you’re doing? Although you’ve done quite a bit, there are still some small details you still need to do.
One fairly large possible issue is that although you’ve been posting your Apache server configuration and status, you haven’t posted anything about what you’ve done to set up your PostGreSQL and whether you’'ve enabled the server to start and start on bootup.
In fact, setting up PostGreSQL isn’t even in the nextcloud documentation you’re following (Is there other documentation you’re using besides what you posted?).

My advice is…
Unless what you’re doing is for self-education, a more practical approach is to remove what you’ve installed and start over installing using the openSUSE packages.


The question is simple:

I do not want to install by opensuse nextcloud package because it installs mysql. Yes, I kow that is easy way to install it. The official nextcloud doc preffer mysql too but, I want to install postgres that the doc says is possible use it, so I am trying to read some blogs, home pages, foruns that choose postgres + nextcloud. Other easy way to install it is by: snap mode but, it installs mysql. Some days I am trying to install with postgres. With mysql on opensuse in other moment its works fine, but I preffer postgresql

My steps:

1 - update system
2 - install postgresql - start service - enable at boot system
3 - Postgresql - create user - create database - alter databese to user - Grant all previleges on database to user
4 - install apache and php7 dependencies:

zypper in php7 php7-ctype php7-curl php7-dom php7-gd  php7-iconv php7-json php7-mbstring php7-openssl php7-posix php7-xmlreader php7-xmlwriter php7-zip php7-zlib php7-pgsql php7-fileinfo php7-bz2 php7-intl php7-smbclient php7-bcmath php7-gmp php7-exif php7-redis php7-imagick apache2-mod_fcgid php7-fpm php7-gettext php7-mysql

5 - edit the file /etc/php7/cli/php.ini

memory_limit = 512M
upload_max_filesize = 10M

6 - Copy and create php7 file:

cp /etc/php7/fpm/php-fpm.conf.default  /etc/php7/fpm/php-fpm.conf
cp /etc/php7/fpm/php-fpm.d/www.conf.default /etc/php7/fpm/php-fpm.d/www.conf

7 - edit the file:

vi /etc/php7/fpm/php-fpm.d/www.conf

and uncomment:

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

8 - Start and enable service on boot

systemctl start php-fpm
systemctl enable php-fpm

9 - Edit filE and insert:

nano /etc/php7/conf.d/pgsql.ini

pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0

10 - Start - Enable on boot and status Apache

systemctl start apache2 
systemctl enable apache2
systemctl status apache2 

11 - Eneblae some Apache mods

a2enmod rewrite
a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime
a2enmod setenvif

12 - Make nexttemp directory and enter the directory created and download nextcloud zip file

mkdir nexttemp 
cd nexttemp

13 - Unzip the file


14 - Make nextcloud directory on /srv and make directory for nextdata

mkdir /srv/www/htdocs/nexcloud21
mkdir /srv/nextdata 

15 - Go to nexttemp directory again

cd /nexttemp/

16 - Copy recursevely nextcloud to /srv/www/htdocs/nextcloud21

cp -R nexttemp/nextcloud/ /srv/www/htdocs/nextcloud21/

17 - Change owner the nextcloud21 diretory and nextdata directory to wwwrun

chown wwwrun:wwwrun /srv/www/htdocs/nextcloud21
chown wwwrun:wwwrun /srv/nextdata

Now my problem is access the nextcloud site but, when try it, it shows download.php file for download

so, I try to check that julianaB shows me and try to fix apache or php_mod and know if its works!

Thank you!


Thx for sharing and @JulianaB contribution could be invaluable if as she says has a manually installed instance running (has gone through the work comparing to a YaST installed instance).

Looks like the complete original documentation

describes numerous options and configurations…
One that jumps out at me that’s not mentioned in your install is to be certain Apache’s own WebDAV is disabled because Nextcloud has its own WebDAV…

Also, for what you’re describing you’re seeing, I’m guessing for some reason your PHP isn’t working so you’re seeing the download page file instead of the rendered page. Maybe doublecheck your a2enmod?

Good Luck,

It’s a long time since I did the manual instal and though not difficult it did have a few tricks and then there was the PHP upgrade!

  • I think the mods that you have made to /etc/php7/cli/php.ini I also had to make to /etc/php7/apache2/php.ini

Here is my …/nextlcoud/config/config.php

$CONFIG = array (
  'instanceid' => '<some stuff>',
  'passwordsalt' => '<some stuff>',
  'secret' => '<some stuff>',
  'trusted_domains' => 
  array (
    0 => '',
    1 => '',
  'datadirectory' => '/nextcloud/data',
  'overwrite.cli.url' => '',
  'dbtype' => 'sqlite3',
  'version' => '',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'PLAIN',
  'mail_domain' => '',
  'mail_from_address' => 'nextcloud',
  'mail_smtphost' => 'localhost',
  'mail_smtpport' => '25',
  'mail_smtptimeout' => 30,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud.log',
  'activity_expire_days' => 30,
  'mail_sendmailmode' => 'pipe',

I have obfuscated my domains and what is possible sensitive at the top.

Note my data directory is non standard and I have set up the trusted domains.

A kind of level 1 test to see if php is working and the config is kind of sane would be to manually run this from a shell:

Cumulus:/srv/www/htdocs/sites/ # sudo -u wwwrun php occ list

OCC is kind of the next cloud command interpreter and you should get a list of the commands. if that does not work something is truly broken!

As you can see I have installed as site specific and you have to run it from the nextcloud directory.

Good luck and let us know if the command works.