[How-To] ownCloud using NGINX, PHP-FPM, and MySQL

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
INTRODUCTION
This guide's purpose is to show my recommended method to install ownCloud in a jail on FreeNAS. This method will have superior performance over the PBI method because this stack uses NGINX, PHP-FPM, and MySQL instead of Apache (with Mod-PHP) and SQLite.

INSTALLATION

OPTIONAL CONFIGURATION

NOTES
  • I use a 'Data folder' that is a dataset outside of the ownCloud jail. This separates data from programs for easy backup and snaphots.
  • I use a subdirectory '/owncloud' for my ownCloud instance; this is because I have other applications running in other sub-directories. I don't use sub-domains because I want everything on a single domain. I pay for a domain name and get a free SSL Certificate from StartSSL. The free SSL Certificate only works for the domain and a single sub-domain (usually www). You can alternatively choose to host ownCloud at the '/' of your server as seen here.
  • I have my SSL terminated by HAProxy running on my pfSense router. If you don't have this option, I recommend setting up SSL in NGINX as seen here.
 
Last edited:

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
INSTALLATION

FreeNAS WebUI
Storage > Create ZFS Dataset
  • Dataset Name = files
  • Compression level = lz4
  • Enable atime = Off
  • Dataset Name = db
  • Compression level = zle
  • Enable atime = Off
  • Record Size = 16K
Jails > Add Jails

Add Storage
  • Source = /mnt/tank/files
  • Destination = /mnt/files
  • Source = /mnt/tank/db
  • Destination = /var/db/mysql
Console in FreeNAS's userland
Code:
zfs set primarycache=metadata tank/db


Console in jail's userland

Code:
pkg upgrade
pkg install nginx mariadb101-server redis php70-bz2 php70-ctype php70-curl php70-dom php70-exif php70-fileinfo php70-filter php70-gd php70-hash php70-iconv php70-intl php70-json php70-mbstring php70-mcrypt php70-pdo_mysql php70-openssl php70-posix php70-session php70-simplexml php70-xml php70-xmlreader php70-xmlwriter php70-xsl php70-wddx php70-zip php70-zlib php70-opcache
portsnap fetch extract
make config-recursive install -C /usr/ports/databases/pecl-redis
make config-recursive install -C /usr/ports/devel/pecl-APCu
sysrc 'nginx_enable=YES' 'php_fpm_enable=YES' 'mysql_enable=YES' 'redis_enable=YES'
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini


  • Set 'worker_processes' to your FreeNAS server's number of threads
Code:
worker_processes 2;

events {
	worker_connections  1024;
}

http {
	include	  mime.types;
	default_type  application/octet-stream;
	sendfile		off;
	keepalive_timeout  65;
	gzip off;

	server {
		root /usr/local/www;
		location = /robots.txt { allow all; access_log off; log_not_found off; }
		location = /favicon.ico { access_log off; log_not_found off; }
		location ^~ /owncloud {
			error_page 403 /owncloud/core/templates/403.php;
			error_page 404 /owncloud/core/templates/404.php;
			location /owncloud {
				rewrite ^ /owncloud/index.php$request_uri;
			}
			location ~ ^/owncloud/(?:build|tests|config|lib|3rdparty|templates|data)/ {
				deny all;
			}
			location ~ ^/owncloud/(?:\.|autotest|occ|issue|indie|db_|console) {
				deny all;
			}
			location ~ ^/owncloud/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
				fastcgi_split_path_info ^(.+\.php)(/.*)$;
				include fastcgi_params;
				fastcgi_pass unix:/var/run/php-fpm.sock;
				fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
				fastcgi_param PATH_INFO $fastcgi_path_info;
				fastcgi_param front_controller_active true;
				fastcgi_intercept_errors on;
			}
			location ~* \.(?:css|js|woff|svg|gif)$ {
				try_files $uri /owncloud/index.php$request_uri;
				add_header Cache-Control max-age=15778463;
			}
			location ~* \.(?:png|html|ttf|ico|jpg|jpeg)$ {
				try_files $uri /owncloud/index.php$request_uri;
			}

		}
	}
}

Code:
cgi.fix_pathinfo=0
date.timezone = America/Los_Angeles
apc.enable_cli=1

Code:
listen = /var/run/php-fpm.sock
listen.owner = www
listen.group = www
env[PATH] = /usr/local/bin:/usr/bin:/bin

Code:
[server]
skip-networking
skip-name-resolve
expire_logs_days = 1
innodb_flush_method = O_DIRECT
skip-innodb_doublewrite
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table

Code:
port 0
unixsocket /tmp/redis.sock
unixsocketperm 777

Code:
service nginx start && service php-fpm start && service mysql-server start && service redis start
mysql -e "CREATE DATABASE owncloud;"
mysql -e "GRANT ALL PRIVILEGES ON owncloud.* TO 'ocuser'@'localhost' IDENTIFIED BY 'ocpass';"
mysql -e "FLUSH PRIVILEGES;"
mysql_secure_installation

Code:
fetch "http://download.owncloud.org/community/owncloud-9.1.1.tar.bz2"
tar jxf owncloud-*.tar.bz2 -C /usr/local/www
rm owncloud-*.tar.bz2
chown -R www:www /usr/local/www/owncloud /mnt/files


Code:
crontab -u www -e

Code:
*/15 * * * * /usr/local/bin/php -f /usr/local/www/owncloud/cron.php

ownCloud WebUI (http://jailip/owncloud)
Storage & database
  • Data folder = /mnt/files
  • Database user = ocuser
  • Database password = ocpass
  • Database name = owncloud
  • Database host = localhost:/tmp/mysql.sock
Console in jail's userland
Code:
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set memcache.local --value="\OC\Memcache\APCu"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set memcache.locking --value="\OC\Memcache\Redis"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set redis host --value="/tmp/redis.sock"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set redis port --value=0 --type=integer'
 
Last edited:

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
OPTIONAL CONFIGURATION

To ask search engine bots not to index your site
Code:
ln -s /usr/local/www/owncloud/robots.txt /usr/local/www


To enable all preview providers.
Code:
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enable_previews --value=true --type=boolean'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 0 --value="OC\Preview\PNG"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 1 --value="OC\Preview\JPEG"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 2 --value="OC\Preview\GIF"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 3 --value="OC\Preview\BMP"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 4 --value="OC\Preview\XBitmap"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 5 --value="OC\Preview\MarkDown"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 6 --value="OC\Preview\MP3"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 7 --value="OC\Preview\TXT"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 8 --value="OC\Preview\Illustrator"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 9 --value="OC\Preview\Movie"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 10 --value="OC\Preview\MSOffice2003"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 11 --value="OC\Preview\MSOffice2007"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 12 --value="OC\Preview\MSOfficeDoc"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 13 --value="OC\Preview\OpenDocument"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 14 --value="OC\Preview\PDF"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 15 --value="OC\Preview\Photoshop"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 16 --value="OC\Preview\Postscript"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 17 --value="OC\Preview\StarOffice"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 18 --value="OC\Preview\SVG"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 19 --value="OC\Preview\TIFF"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set enabledPreviewProviders 20 --value="OC\Preview\Font"'


To enable DOC/DOCX editing and document previews.
Code:
pkg install libreoffice
make config-recursive install -C /usr/ports/graphics/pecl-imagick


To enable video previews
Code:
pkg install ffmpeg
 
Last edited:

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
For the nginx.conf file am I adding any of the missing lines that you have posted? Because I noticed there is a big difference in the nginx.conf you posted and the one that I have installed by default.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
For the nginx.conf file am I adding any of the missing lines that you have posted? Because I noticed there is a big difference in the nginx.conf you posted and the one that I have installed by default.
the first 3 lines replace lines already in the config. the gzip lines are added in the http block, the server block replace the default server block.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Thanks for the help. Also for the my.cnf file, the mysql folder and the file itself do not exist. Should I be creating this folder and file with the lines you provided?
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Thanks for the help. Also for the my.cnf file, the mysql folder and the file itself do not exist. Should I be creating this folder and file with the lines you provided?

in my testing the folder did exist but the file didn't. did you successfully install mariadb55?
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
I was able to get mariadb55 installed but I needed to re-install the jail. Now I am having an issue when launching nginx. I receive the error below.

Code:
@Owncloud:/ # service nginx start
Performing sanity check on nginx configuration:
nginx: [emerg] location "/50x.html" is outside location "/owncloud" in /usr/local/etc/nginx/nginx.conf:67
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed
Starting nginx.
nginx: [emerg] location "/50x.html" is outside location "/owncloud" in /usr/local/etc/nginx/nginx.conf:67
/usr/local/etc/rc.d/nginx: WARNING: failed to start nginx
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I was able to get mariadb55 installed but I needed to re-install the jail. Now I am having an issue when launching nginx. I receive the error below.

Code:
@Owncloud:/ # service nginx start
Performing sanity check on nginx configuration:
nginx: [emerg] location "/50x.html" is outside location "/owncloud" in /usr/local/etc/nginx/nginx.conf:67
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed
Starting nginx.
nginx: [emerg] location "/50x.html" is outside location "/owncloud" in /usr/local/etc/nginx/nginx.conf:67
/usr/local/etc/rc.d/nginx: WARNING: failed to start nginx
please don't do all that work. just fix your nginx config.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Now maybe I removed too much of the contents of the file. Could you post your nginx file, if possible. Thanks.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Now maybe I removed too much of the contents of the file. Could you post your nginx file, if possible. Thanks.
not at home right now, on my phone. if you post your config I can edit it.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Here is the contents. Thanks.

Code:
#user  nobody;
worker_processes  8;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
 
http {
    include      mime.types;
    default_type  application/octet-stream;
 
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
    #access_log  logs/access.log  main;
 
    sendfile        on;
    tcp_nopush    on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    gzip  on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 9;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
 
    server {
    root /usr/local/www;
    location = /robots.txt { allow all; access_log off; log_not_found off; }
    location = /favicon.ico { access_log off; log_not_found off; }
    location ^~ /owncloud {
        index index.php;
        try_files $uri $uri/ /index.php?$args;
        client_max_body_size 512M;
        location ~ ^/owncloud/(?:\.|data|config|db_structure\.xml|README) {
            deny all;
        }
        rewrite ^/owncloud/apps/([^/]+)/(.+\.(css|php))$ /owncloud/index.php?app=$1&getfile=$2 last;
        rewrite ^/owncloud/remote/(.*)$ /owncloud/remote.php/$1 last;
        location ~ \.php/? {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php-fpm.sock;
            include fastcgi_params;
        }
        location ~* \.(?:jpg|gif|ico|png|css|js|svg)$ {
            expires max; add_header Cache-Control public;
        }
    }
}
 
        #error_page  404              /404.html;
 
        # redirect server error pages to the static page /50x.html
        #
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root  /usr/local/www/nginx-dist;
        }
 
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass  http://127.0.0.1;
        #}
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root          html;
        #    fastcgi_pass  127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
 
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
 
 
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen      8000;
    #    listen      somename:8080;
    #    server_name  somename  alias  another.alias;
 
    #    location / {
    #        root  html;
    #        index  index.html index.htm;
    #    }
    #}
 
 
    # HTTPS server
    #
    #server {
    #    listen      443;
    #    server_name  localhost;
 
    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
 
    #    ssl_session_timeout  5m;
 
    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
 
    #    location / {
    #        root  html;
    #        index  index.html index.htm;
    #    }
    #}
 
}
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Here is the contents. Thanks.

Code:
#user  nobody;
worker_processes  8;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
 
http {
    include      mime.types;
    default_type  application/octet-stream;
 
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
    #access_log  logs/access.log  main;
 
    sendfile        on;
    tcp_nopush    on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    gzip  on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 9;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
 
    server {
    root /usr/local/www;
    location = /robots.txt { allow all; access_log off; log_not_found off; }
    location = /favicon.ico { access_log off; log_not_found off; }
    location ^~ /owncloud {
        index index.php;
        try_files $uri $uri/ /index.php?$args;
        client_max_body_size 512M;
        location ~ ^/owncloud/(?:\.|data|config|db_structure\.xml|README) {
            deny all;
        }
        rewrite ^/owncloud/apps/([^/]+)/(.+\.(css|php))$ /owncloud/index.php?app=$1&getfile=$2 last;
        rewrite ^/owncloud/remote/(.*)$ /owncloud/remote.php/$1 last;
        location ~ \.php/? {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php-fpm.sock;
            include fastcgi_params;
        }
        location ~* \.(?:jpg|gif|ico|png|css|js|svg)$ {
            expires max; add_header Cache-Control public;
        }
    }
}
 
        #error_page  404              /404.html;
 
        # redirect server error pages to the static page /50x.html
        #
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root  /usr/local/www/nginx-dist;
        }
 
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass  http://127.0.0.1;
        #}
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root          html;
        #    fastcgi_pass  127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
 
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
 
 
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen      8000;
    #    listen      somename:8080;
    #    server_name  somename  alias  another.alias;
 
    #    location / {
    #        root  html;
    #        index  index.html index.htm;
    #    }
    #}
 
 
    # HTTPS server
    #
    #server {
    #    listen      443;
    #    server_name  localhost;
 
    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
 
    #    ssl_session_timeout  5m;
 
    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
 
    #    location / {
    #        root  html;
    #        index  index.html index.htm;
    #    }
    #}
 
}

You can delete line 63-133.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
So, that was what I originally had as the contents of the nginx file, but I still receive an error complaining about the last "}" missing but it isn't.

Current File with 63-133 removed:
Code:
#user  nobody;
worker_processes  8;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
 
http {
    include      mime.types;
    default_type  application/octet-stream;
 
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
    #access_log  logs/access.log  main;
 
    sendfile        on;
    tcp_nopush    on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    gzip  on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 9;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
 
    server {
      root /usr/local/www;
      location = /robots.txt { allow all; access_log off; log_not_found off; }
      location = /favicon.ico { access_log off; log_not_found off; }
      location ^~ /owncloud {
          index index.php;
          try_files $uri $uri/ /index.php?$args;
          client_max_body_size 10G;
          location ~ ^/owncloud/(?:\.|data|config|db_structure\.xml|README) {
              deny all;
          } 
          rewrite ^/owncloud/apps/([^/]+)/(.+\.(css|php))$ /owncloud/index.php?app=$1&getfile=$2 last;
          rewrite ^/owncloud/remote/(.*)$ /owncloud/remote.php/$1 last;
          location ~ \.php/? {
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              fastcgi_pass unix:/var/run/php-fpm.sock;
              include fastcgi_params;
          } 
          location ~* \.(?:jpg|gif|ico|png|css|js|svg)$ {
              expires max; add_header Cache-Control public;
          }
      }
}


Error with current configuration:

Code:
@Owncloud:/ # service nginx start
Performing sanity check on nginx configuration:
nginx: [emerg] unexpected end of file, expecting "}" in /usr/local/etc/nginx/nginx.conf:63
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed
Starting nginx.
nginx: [emerg] unexpected end of file, expecting "}" in /usr/local/etc/nginx/nginx.conf:63
/usr/local/etc/rc.d/nginx: WARNING: failed to start nginx
 
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
So, that was what I originally had as the contents of the nginx file, but I still receive an error complaining about the last "}" missing but it isn't.

Current File with 63-133 removed:
Code:
#user  nobody;
worker_processes  8;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
 
http {
    include      mime.types;
    default_type  application/octet-stream;
 
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
    #access_log  logs/access.log  main;
 
    sendfile        on;
    tcp_nopush    on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    gzip  on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 9;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
 
    server {
      root /usr/local/www;
      location = /robots.txt { allow all; access_log off; log_not_found off; }
      location = /favicon.ico { access_log off; log_not_found off; }
      location ^~ /owncloud {
          index index.php;
          try_files $uri $uri/ /index.php?$args;
          client_max_body_size 10G;
          location ~ ^/owncloud/(?:\.|data|config|db_structure\.xml|README) {
              deny all;
          }
          rewrite ^/owncloud/apps/([^/]+)/(.+\.(css|php))$ /owncloud/index.php?app=$1&getfile=$2 last;
          rewrite ^/owncloud/remote/(.*)$ /owncloud/remote.php/$1 last;
          location ~ \.php/? {
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              fastcgi_pass unix:/var/run/php-fpm.sock;
              include fastcgi_params;
          }
          location ~* \.(?:jpg|gif|ico|png|css|js|svg)$ {
              expires max; add_header Cache-Control public;
          }
      }
}


Error with current configuration:

Code:
@Owncloud:/ # service nginx start
Performing sanity check on nginx configuration:
nginx: [emerg] unexpected end of file, expecting "}" in /usr/local/etc/nginx/nginx.conf:63
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed
Starting nginx.
nginx: [emerg] unexpected end of file, expecting "}" in /usr/local/etc/nginx/nginx.conf:63
/usr/local/etc/rc.d/nginx: WARNING: failed to start nginx
 
it's the indents that are throwing you off. add a }. that's why I said delete 63-133, I never said delete 134.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Ah yes, I missed the indent there, been a long day. Thanks for the help.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Next time a diff file might be easier. ;)
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Is it possible to enable HTTPS with this setup?
 
Top