# 500 Internal Server Error when trying to install

**URL:** <https://help.nextcloud.com/t/500-internal-server-error-when-trying-to-install/195343>\
**Category:** ℹ️ Support\
**Tags:** ubuntu, nginx\
**Created:** [June 17, 2024, 11:17am UTC](https://help.nextcloud.com/t/500-internal-server-error-when-trying-to-install/195343 "2024-06-17T11:17:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabocota](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gabocota/32/62570_2.png) [@Gabocota](https://help.nextcloud.com/u/Gabocota)\
**Post date:** [June 17, 2024, 11:17am UTC](https://help.nextcloud.com/t/500-internal-server-error-when-trying-to-install/195343/1 "2024-06-17T11:17:11Z")

</div>

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:

```auto
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

```auto
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:

```auto
[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.

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/6_22734026db12803ebb3e059622ac3534.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [June 17, 2024, 11:19am UTC](https://help.nextcloud.com/t/500-internal-server-error-when-trying-to-install/195343/2 "2024-06-17T11:19:39Z")

</div>

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

> [@First maintenance release for Hub 5](https://help.nextcloud.com/t/first-maintenance-release-for-hub-5/166851/2):
>
> Hub 5 is Nextcloud 27! Here is a table with supported php version vs. NC versions: NC version php 7.3 php 7.4 php 8.0 php 8.1 php 8.2 php 8.3 22white_check_markwhite_check_markwhite_check_mark23white_check_markwhite_check_markwhite_check_mark24white_check_markwhite_check_markwhite_check_mark25white_check_markwhite_check_markwhite_check_mark26white_check_markwhite_check_markwhite_check_mark27white_check_mark…

---

<div class="post-metadata">

**Author:** ![jtr](https://help.nextcloud.com/letter_avatar/jtr/32/6_22734026db12803ebb3e059622ac3534.png) [@jtr](https://help.nextcloud.com/u/jtr)\
**Post date:** [June 17, 2024, 1:45pm UTC](https://help.nextcloud.com/t/500-internal-server-error-when-trying-to-install/195343/3 "2024-06-17T13:45:01Z")

</div>

> [@Gabocota](#):
>
> I dont know what other logs i can check or what is happening but the rest of my site works fine.

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](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](https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html#nextcloud-in-a-subdir-of-the-nginx-webroot)

---

<div class="post-metadata">

**Author:** ![Gabocota](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gabocota/32/62570_2.png) [@Gabocota](https://help.nextcloud.com/u/Gabocota)\
**Post date:** [June 17, 2024, 9:04pm UTC](https://help.nextcloud.com/t/500-internal-server-error-when-trying-to-install/195343/4 "2024-06-17T21:04:24Z")

</div>

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:

```auto
[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](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.

```auto
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:

```auto
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](https://help.nextcloud.com/uploads/default/original/3X/e/d/ed999ba2ce5f8cbf571cc1dee3071486a4885b63.png)

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/6_22734026db12803ebb3e059622ac3534.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [June 18, 2024, 6:48am UTC](https://help.nextcloud.com/t/500-internal-server-error-when-trying-to-install/195343/5 "2024-06-18T06:48:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gabocota](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gabocota/32/62570_2.png) [@Gabocota](https://help.nextcloud.com/u/Gabocota)\
**Post date:** [June 18, 2024, 10:13am UTC](https://help.nextcloud.com/t/500-internal-server-error-when-trying-to-install/195343/6 "2024-06-18T10:13:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/6_22734026db12803ebb3e059622ac3534.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [June 18, 2024, 11:08am UTC](https://help.nextcloud.com/t/500-internal-server-error-when-trying-to-install/195343/7 "2024-06-18T11:08:04Z")

</div>

Then turn on logging:

> <https://serverfault.com/questions/574880/nginx-php-fpm-error-logging>

> [@Gabocota](#):
>
> Thats why I refuse to work with php.

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

---

<div class="post-metadata">

**Author:** ![jtr](https://help.nextcloud.com/letter_avatar/jtr/32/6_22734026db12803ebb3e059622ac3534.png) [@jtr](https://help.nextcloud.com/u/jtr)\
**Post date:** [June 18, 2024, 1:31pm UTC](https://help.nextcloud.com/t/500-internal-server-error-when-trying-to-install/195343/8 "2024-06-18T13:31:54Z")

</div>

> [@Gabocota](#):
>
> 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.

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.

> [@Gabocota](#):
>
> But now im just stuck with a 503 Service unavailable.  
> I made a pool config file called nc.conf and made it this:
> 
> ```auto
> [php]
> user = gabocota
> group = gabocota
> listen = /run/php/php8.3-fpm.sock
> listen.owner = gabocota
> listen.group = gabocota
> 
> ```

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.

---

<div class="post-metadata">

**Author:** ![system](https://help.nextcloud.com/user_avatar/help.nextcloud.com/system/32/29333_2.png) [@system](https://help.nextcloud.com/u/system)\
**Post date:** [September 23, 2024, 1:28pm UTC](https://help.nextcloud.com/t/500-internal-server-error-when-trying-to-install/195343/9 "2024-09-23T13:28:36Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
