500 Internal Server Error when trying to install

I have been trying to install nextcloud in my web server that already has stuff in it.
I installed php7.4-fpm and downloaded the latest nextcloud server.
I installed mariadb and created a db called nextcloud_db
I am using an external drive mounted in /mnt/ext/ and I have correct permissions. Everything configured to be used with the gabocota user, nginx, the php www.conf file, everything.
In the nginx.conf file I added the following:

location /nube {
      rewrite ^ /nube/index.php$request_uri;

      location ~ \.php(?:$|/) {
        include fastcgi_params;
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Yes this is the same as the "listen = " one in the php www.conf file
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
      }

      location ~* \.(?:css|js|woff|svg|gif)$ {
        try_files $uri /nube/index.php$request_uri;
        add_header Cache-Control "public, max-age=15778463";
        add_header X-Content-Type-Options nosniff;
        add_header X-Frame-Options "SAMEORIGIN";
        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;
        access_log off;
      }

      location ~* \.(?:png|html|ttf|ico|jpg|jpeg)$ {
        try_files $uri /nube/index.php$request_uri;
        access_log off;
      }
    }

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

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

    location ~ ^/nube/(?:index|remote|public|cron|core/ajax/update|status|ocs/v1|ocs/v2)\.php(?:$|/) {
      include fastcgi_params;
      fastcgi_split_path_info ^(.+?\.php)(/.*)$;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_path_info;
      fastcgi_param HTTPS on;
      fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
      fastcgi_intercept_errors on;
      fastcgi_request_buffering off;
    }

    location ~ ^/nube/(?:updater|ocs-provider)(?:$|/) {
      try_files $uri/ =404;
      index index.php;
    }

I also added

opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1

to /etc/php/7.4/fpm/php.ini

After all this im stuck with a 500 Internal Server Error on every request inside of /nube/
yes nube does contain the contents of the normally named ‘nextcloud’ folder left behind by the latest.zip

nginx/error.log doesnt say anything and access.log just says:

[17/Jun/2024:04:29:54 -0600] "GET /nube/index.php HTTP/1.1" 500 1886 "https://gabocota.net/nube/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0"

I dont know what other logs i can check or what is happening but the rest of my site works fine.

The last version for php7.4 was NC25, which is not supported any more:

2 Likes

The Nextcloud log, by default, is located in your data directory and called nextcloud.log.

That said, not sure what installation tutorial you’re following, but I don’t think it’s the official one. Check https://docs.nextcloud.com.

The below is the recommended Nginx config for a subfolder deployment:

https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html#nextcloud-in-a-subdir-of-the-nginx-webroot

1 Like

I did this, installed 8.3 and configured it. But now im just stuck with a 503 Service unavailable.
I made a pool config file called nc.conf and made it this:

[php]
user = gabocota
group = gabocota
listen = /run/php/php8.3-fpm.sock
listen.owner = gabocota
listen.group = gabocota
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_flag[allow_url_fopen] = off
; Choose how the process manager will control the number of child processes.
pm = dynamic
pm.max_children = 75
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.process_idle_timeout = 10s

And I changed the nginx.conf to work with the https://docs.nextcloud.com one. The thing is that I cant follow these tutorials by the book because I already have a website that doesn’t use php set up so its hard to keep the php stuff only for /nube/ but it seems fine.

location ^~ /nube {
      client_max_body_size 512M;
      client_body_timeout 300s;
      fastcgi_buffers 64 4K;

      gzip on;
      gzip_vary on;
      gzip_comp_level 4;
      gzip_min_length 256;
      gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
      gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

      client_body_buffer_size 512k;

      add_header Referrer-Policy                   "no-referrer"       always;
      add_header X-Content-Type-Options            "nosniff"           always;
      add_header X-Frame-Options                   "SAMEORIGIN"        always;
      add_header X-Permitted-Cross-Domain-Policies "none"              always;
      add_header X-Robots-Tag                      "noindex, nofollow" always;
      add_header X-XSS-Protection                  "1; mode=block"     always;

      fastcgi_hide_header X-Powered-By;

      index index.php index.html /nube/index.php$request_uri;

      location = /nube {
        if ( $http_user_agent ~ ^DavClnt ) {
          return 302 /nube/remote.php/webdav/$is_args$args;
        }
      }

      location ~ ^/nube/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { 
        return 404;
      }
      location ~ ^/nube/(?:\.|autotest|occ|issue|indie|db_|console) { 
        return 404;
      }

      # Ensure this block, which passes PHP files to the PHP process, is above the blocks
      # which handle static assets (as seen below). If this block is not declared first,
      # then Nginx will encounter an infinite rewriting loop when it prepends
      # `/nube/index.php` to the URI, resulting in a HTTP 500 error response.
      location ~ \.php(?:$|/) {
        # Required for legacy support
        rewrite ^/nube/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /nube/index.php$request_uri;

        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        set $path_info $fastcgi_path_info;

        try_files $fastcgi_script_name =404;

        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param HTTPS on;

        fastcgi_param modHeadersAvailable true;         # Avoid sending the security headers twice
        fastcgi_param front_controller_active true;     # Enable pretty urls
        fastcgi_pass php-handler;

        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;

        fastcgi_max_temp_file_size 0;
      }

      # Serve static files
      location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ {
        try_files $uri /nube/index.php$request_uri;
        # HTTP response headers borrowed from nube `.htaccess`
        add_header Cache-Control                     "public, max-age=15778463$asset_immutable";
        add_header Referrer-Policy                   "no-referrer"       always;
        add_header X-Content-Type-Options            "nosniff"           always;
        add_header X-Frame-Options                   "SAMEORIGIN"        always;
        add_header X-Permitted-Cross-Domain-Policies "none"              always;
        add_header X-Robots-Tag                      "noindex, nofollow" always;
        add_header X-XSS-Protection                  "1; mode=block"     always;
        access_log off;     # Optional: Don't log access to assets
      }

      location ~ \.woff2?$ {
        try_files $uri /nube/index.php$request_uri;
        expires 7d;         # Cache-Control policy borrowed from `.htaccess`
        access_log off;     # Optional: Don't log access to assets
      }

      # Rule borrowed from `.htaccess`
      location /nube/remote {
        return 301 /nube/remote.php$request_uri;
      }

      location /nube {
        try_files $uri $uri/ /nube/index.php$request_uri;
      }
    }

All of that is inside of the server listening to 443 and I added:

upstream php-handler {
    server unix:/run/php/php8.3-fpm.sock;
  }
  map $arg_v $asset_immutable {
    "" "";
    default ", immutable";
  }

Right after http {

Both processes are running fine and I don’t honestly know what else could be.
image

And what does your webserver’s error.log tell you?

Nothing at all. Its so infuriating I just gave up and installed seafile even though is worse.
Thats why I refuse to work with php.

Then turn on logging:

Independent from that, you often find strange errors that don’t tell you right away what is wrong.

Are you installing Nextcloud in a sub-folder under your root? Are all sites located under it or are you trying to install Nextcloud somewhere outside of the root?

You should be able to use the subdir config as-is, as long as you’re deploying Nextcloud underneath your nginx root in, in this case, a folder on disk called /path_to_root/nube/

You could also just create a vhost, since that’ll be cleaner, and vhosts don’t require their own IPs.

This will create some issues since nginx is likely not running under that user/group and the default mod will be 0660.

I would also check on-disk that you’re /run/php/php8.3-fpm.sock is showing as expected.