Reinstalled Nextcloud -> <server-address>/index.php/apps/files/ Error: 404 Not Found

Hi All,
i’ve just tried to move my Nextcloud installation to a new server. The old one was a preinstalled FreeNAS package, but the new installation is configured by hand. Therefore, 1st I installed nginx, php-fpm, and nextcloud. The config.php was coppied from the old installation as well as the data directory and the database.
Database has already been tested and is working.

With the copied config.php, the installation was not running at all. So I’ve used the default config and set up the initial configuration with the existing database and data directory.
The screen for the initial setup was shown and some apps were updated, but now I’m always geting the Error Page 404 Not Found, when I try to connect to the server (Address shown in the browser: http:///index.php/apps/files/).

I’m using the nginx config from the Admin_manual without the SSL-config.

All log-files are clean after a connection attempt - not one single error entry.
Does anybody have an idea, what else I can test?

Current NGINX-config:

server {
listen 80 default_server;

server_name _;

server_tokens off;
client_max_body_size 0; # maximum file-size needed for nginx

include /usr/local/etc/nginx/snippets/server-hardening.conf;

Remove X-Powered-By, which is an information leak

fastcgi_hide_header X-Powered-By;

root /usr/local/www/nextcloud;
index index.php index.html index.htm;

include /usr/local/etc/nginx/snippets/php-config.conf;

location / {
    rewrite ^ /index.php;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /.ht {
    deny all;
}

location = /.well-known/carddav {
  return 301 $scheme://$host:$server_port/remote.php/dav;
}
location = /.well-known/caldav {
  return 301 $scheme://$host:$server_port/remote.php/dav;
}

location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
deny all;
}

location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
  deny all;
}

location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
  fastcgi_split_path_info ^(.+\.php)(/.*)$;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param PATH_INFO $fastcgi_path_info;
  #fastcgi_param HTTPS on;
  fastcgi_param modHeadersAvailable true;
  fastcgi_param front_controller_active true;
  fastcgi_pass php-handler;
  fastcgi_intercept_errors on;
  fastcgi_request_buffering off;
  fastcgi_keep_conn off;
  fastcgi_buffers 16 256K;
  fastcgi_buffer_size 256k;
  fastcgi_busy_buffers_size 256k;
  fastcgi_temp_file_write_size 256k;
  fastcgi_send_timeout 3000s;
  fastcgi_read_timeout 3000s;
  fastcgi_connect_timeout 3000s;
}

location ~ ^/(?:updater|oc[ms]-provider)(?:$|/) {
try_files $uri/ =404;
index index.php;
}

# ADDING THE CACHE CONTROL HEADER FOR JS AND CSS FILES
# MAKE SURE IT IS BELOW PHP BLOCK
location ~ \.(?:css|js|woff2?|svg|gif)$ {
  try_files $uri /index.php$uri$is_args$args;
  add_header Cache-Control "public, max-age=15778463";
  # HEADERS SECURITY RELATED
  # IT IS INTENDED TO HAVE THOSE DUPLICATED TO ONES ABOVE
  add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
  # HEADERS
  add_header X-Content-Type-Options nosniff;
  add_header X-XSS-Protection "1; mode=block";
  add_header X-Robots-Tag none;
  add_header X-Download-Options noopen;
  add_header X-Permitted-Cross-Domain-Policies none;
  # OPTIONAL: DONT LOG ACCESS TO ASSETS
  access_log off;
}

location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
  try_files $uri /index.php$uri$is_args$args;
  # OPTIONAL: DONT LOG ACCESS TO OTHER ASSETS
  access_log off;
}

And config.php

<?php

$CONFIG = array (
‘apps_paths’ =>
array (
0 =>
array (
‘path’ => ‘/usr/local/www/nextcloud/apps’,
‘url’ => ‘/apps’,
‘writable’ => true,
),
1 =>
array (
‘path’ => ‘/usr/local/www/nextcloud/apps-pkg’,
‘url’ => ‘/apps-pkg’,
‘writable’ => true,
),
),
‘logfile’ => ‘/var/log/nextcloud/nextcloud.log’,
‘memcache.local’ => ‘\OC\Memcache\Redis’,
‘instanceid’ => ‘xxx’,
‘passwordsalt’ => ‘xxx’,
‘secret’ => ‘xxx’,
‘trusted_domains’ =>
array (
0 => ‘server-ip’,
),
‘datadirectory’ => ‘/data’,
‘dbtype’ => ‘mysql’,
‘version’ => ‘18.0.4.2’,
‘overwrite.cli.url’ => ‘http://server-ip’,
‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘localhost’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,
‘mysql.utf8mb4’ => true,
‘dbuser’ => ‘oc_xxx’,
‘dbpassword’ => ‘xxx’,
‘installed’ => true,
‘theme’ => ‘’,
‘loglevel’ => 2,
‘maintenance’ => false,
);

Today I’ve tested some additional options:

Boundary conditions of original nextCloud Plugin:

  • PHP7.1.32
  • Mysql 14.14 Distrib 5.6.45
  • Nextcloud 16.0.5.1

New installation:

  • PHP7.2.31
  • Mysql 14.14 Distrib 5.6.48
  • Nextcloud 16.0.10.2

For the new installation i was following this upgrade tutorial.

Before starting the upgrade process with

sudo -u www php occ upgrade

I tried to access the server and got a well functioning page, which said that a upgrade is needed.
The manual upgrade process using the shell command finished successfully.
However, with the next try to reach the Nextcloud-server it shows the 404 Error page again.

Finally I got it running - might be interesting for somebody else facing similar problems:

  1. Issue was a wrong path for the php-fpm.sock in the nginx.conf
  2. Issue were wrong access permissions for the database-files in /var/db/
2 Likes