Nextcloud server installation

Hi guys,
I installed nexrtcloud on my server and made the first login, going to the SUMMARY section, it told me that the php and security settings were missing. doing several jobs, it gave me INTERNAL SERVER ERROR with the following error in the log file:

2020/10/14 16:59:39 [error] 1597#0: *4 FastCGI sent in stderr: “DRbYxKkvoxcQHel”,“level”:3,“time”:“2020-10-14T14:59:39+00:00”,“remoteAddr”:“192.168.178.23”,“user”:"–",“app”:“index”,“method”:“GET”,“url”:"/",“message”:{“Exception”:“Doctrine\DBAL\DBALException”,“Message”:“Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [14] unable to open database file”,“Code”:0,“Trace”:[{“file”:"/usr/share/nginx/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",“line”:1449,“function”:“connect”,“class”:“OC\DB\Connection”,“type”:"->"},{“file”:"/usr/share/nginx/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",“line”:892,“function”:“getWrappedConnection”,“class”:“Doctrine\DBAL\Connection”,“type”:"->"},{“file”:"/usr/share/nginx/html/lib/private/DB/Connection.php",“line”:194,“function”:“executeQuery”,“class”:“Doctrine\DBAL\Connection”,“type”:"->"},{“file”:"/usr/share/nginx/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php",“line”:206,“function”:“executeQuery”,“class”:“O…PHP message: {“reqId”:“YnQJFDRbYxKkvoxcQHel”,“level”:3,“time”:“2020-10-14T14:59:39+00:00”,“remoteAddr”:“192.168.178.23”,“user”:”–",“app”:“PHP”,“method”:“GET”,“url”:"/",“message”:“fopen(/usr/share/nginx/html/data/nextcloud.log): failed to open stream: Permission denied at /usr/share/nginx/html/lib/private/Log/File.php#85”,“userAgent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36”,“version”:""}" while reading response header from upstream, client: 192.168.178.23, server: , request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/run/php-fpm/www.sock:”, host: “192.168.178.34”

some one can help me ?

Thanks

Please try to use the search function to find an answer on your question. This kind of question is being asked at least once per week so that you should be able to find an answer on your question:

https://help.nextcloud.com/search?q=unable%20to%20open%20database%20file

Same for this question, Make sure that you’ve set the access rights correctly to prevent such kind of errors.

1 Like

hi, thanks for your answer, after managing the permissions it shows me the error 502 bad gateway, in the nginx log file I see the following error:

2020/10/15 15:51:52 [error] 1686#0: *9 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.178.23, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.178.34" $92.168.178.34"

this is the configuration of my nextcloud.conf file:

upstream php-handler {
server 127.0.0.1:9000;
#server unix:/run/php-fpm/www.sock;

}

server {
listen 80;
listen [::]:80;
# server_name my.domain.com;
# enforce https
# return 301 https://$server_name:443$request_uri;

# Add headers to serve security-related headers
# Before enabling Strict-Transport-Security headers please read into this
# topic first.
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
#
# WARNING: Only add the preload option once you read about
# the consequences in https://hstspreload.org/. This option
# will add the domain to a hardcoded list that is shipped
# in all major browsers and getting removed from this list
# could take several months.
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Download-Options "noopen" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "none" always;
add_header X-XSS-Protection "1; mode=block" always;

# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;

# Path to the root of your installation
root /usr/share/nginx/html/;

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

# The following 2 rules are only needed for the user_webfinger app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;

#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

# The following rule is only needed for the Social app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/webfinger /public.php?service=webfinger last;

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

location ^~ {

    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;

    # Enable gzip but do not remove ETag headers
    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 application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject 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;

    # Uncomment if your server is built with the ngx_pagespeed module
    # This module is currently not supported.
    # pagespeed off;

    location / {
        rewrite ^ /index.php;
    }

    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)(\/.*|)$;
        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;
        # Avoid sending the security headers twice
        fastcgi_param modHeadersAvailable true;
        # Enable pretty urls
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }

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

    # Adding the cache control header for js, css and map files
    # Make sure it is BELOW the PHP block
    location ~ ^\/.+[^\/]\.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        add_header Cache-Control "public, max-age=15778463";
        # Add headers to serve security related headers (It is intended
        # to have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read
        # into this topic first.
        #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
        #
        # WARNING: Only add the preload option once you read about
        # the consequences in https://hstspreload.org/. This option
        # will add the domain to a hardcoded list that is shipped
        # in all major browsers and getting removed from this list
        # could take several months.
        add_header Referrer-Policy "no-referrer" always;
        add_header X-Content-Type-Options "nosniff" always;
        add_header X-Download-Options "noopen" always;
        add_header X-Frame-Options "SAMEORIGIN" always;
        add_header X-Permitted-Cross-Domain-Policies "none" always;
        add_header X-Robots-Tag "none" always;
        add_header X-XSS-Protection "1; mode=block" always;

        # Optional: Don't log access to assets
        access_log off;
    }

    location ~ ^\/.+[^\/]\.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
        try_files $uri /index.php$request_uri;
        # Optional: Don't log access to other assets
        access_log off;
    }
}

}

did you ever get a successful outcome ?