Nginx – PHP App (Owncloud) Pages Requesting Incorrect Path for Assets

nginxowncloudpathPHP

I have a VPS set up with php-fpm and nginx (with ssl). I have set up Tiny Tiny RSS already, and it works just fine. However, I recently attempted to set up Owncloud, and instantly hit a roadblock.

I visited the index page to do the initial set up, and there was absolutely no styling at all. I looked in Firefox's console, and saw several 404 errors. Looking closely, I saw that all the paths to the assets were wrong. Instead of requesting http://mydomain.com/owncloud/some/important/component.js, it requested http://mydomain.com/usr/share/nginx/html/owncloud/some/important/component.js.

It would seem that php is doing something wrong when it's processing the pages. I don't have this problem with Tiny Tiny RSS, so I would assume it has something to do with the way Owncloud was written.

I'm assuming there's a php.ini key I have to change. Any ideas?

The following is the content of my server block:

            listen 443 ssl;
            ssl_certificate /var/ssl/secret/sauce.key
            ssl_certificate_key /var/ssl/secret/sauce.key;
            server_name localhost 127.0.0.1 mydomain.com;
            root /usr/share/nginx/html;
            index index.html index.htm index.php;
            client_max_body_size 1000M;

            location / {
                    try_files $uri $uri/ @webdav =404;
            }

            location ~ \.php$ { 
                    include fastcgi_params;
                    fastcgi_index index.php;
                    try_files $1 = 404;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_param HTTPS on;
                    fastcgi_pass 127.0.0.1:9000;
            }

            location ~ ^/owncloud/(data|config|\.ht|db_structure\.xml|README) {
                    deny all;
            }

            location @webdav {
                    fastcgi_split_path_info ^(.+\.php)(/.*)$;
                    fastcgi_pass 127.0.0.1:9000;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_param HTTPS on;
                    include fastcgi_params;
            }

I realise that this isn't the complete configuration that the Owncloud documentation recommends, but I generally like to get a minimal working configuration and work up in order to learn how everything works. Reviewing the configuration options I left out, there didn't seem to be any that affected php processing, so I'm assuming it's fine. Otherwise, I would like to know what nginx directive I'm missing and why it's important.

Best Answer

I'm assuming there's a php.ini key I have to change. Any ideas?

No, your application is likely configured wrong - Owncloud's PHP is generating those paths. Make sure you configured the URL path correctly in Owncloud.