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

diedrichg

Wizard
Joined
Dec 4, 2012
Messages
1,319
I would suspect that you are having conflicts with port 50 because it is reserved for: "50 TCP UDP Remote Mail Checking Protocol (RMCP)". You should be using anything in the "Dynamic/Private : 49152 through 65535" to avoid conflicts.
 

MuneebMufti

Dabbler
Joined
May 5, 2014
Messages
36
okay thank-you for that ill try that. before port 50 i was using port 83. had same issue thats why I changed it. Also one more thing i forgot to mention was that when i created jail i left the default checkboxes checked which included VIMAGE. I was later told on another conversation that i shouldnt have let it on.

I would suspect that you are having conflicts with port 50 because it is reserved for: "50 TCP UDP Remote Mail Checking Protocol (RMCP)". You should be using anything in the "Dynamic/Private : 49152 through 65535" to avoid conflicts.
 

diedrichg

Wizard
Joined
Dec 4, 2012
Messages
1,319
For future reference:
Well Known Ports: 0 through 1023. (Usually system reserved)

Registered Ports: 1024 through 49151.

Dynamic/Private : 49152 through 65535.

I'm assuming you meant to say that you should have turned them off? Reading the descriptions in the docs, yes, it is also my understanding that they should have been turned off.
 

MuneebMufti

Dabbler
Joined
May 5, 2014
Messages
36
okay thank you very much for the information on ports and yes I meant i should have turned off VIMAGE. Since I havent completely deployed my owncloud instance for full use and at the moment I am still doing quality testing if incase i delete the jail and start over again i am supposed to uncheck VIMAGE only or uncheck autostart aswell. NAT was unchecked by default when creating jail.

For future reference:
Well Known Ports: 0 through 1023. (Usually system reserved)

Registered Ports: 1024 through 49151.

Dynamic/Private : 49152 through 65535.

I'm assuming you meant to say that you should have turned them off? Reading the descriptions in the docs, yes, it is also my understanding that they should have been turned off.
 

diedrichg

Wizard
Joined
Dec 4, 2012
Messages
1,319
Leave autostart otherwise it won't start during a reboot. I don't remember the name of the other boxes, but everything else should be unchecked except autostart. And then in jail storage (in the left menu frame); be sure mount is checked.
 

MuneebMufti

Dabbler
Joined
May 5, 2014
Messages
36
okay thank you very much for clearing that up
Leave autostart otherwise it won't start during a reboot. I don't remember the name of the other boxes, but everything else should be unchecked except autostart. And then in jail storage (menu option in the left menu frame); be sure mount is checked.
 

MuneebMufti

Dabbler
Joined
May 5, 2014
Messages
36
One more question the nginx version used here is 1.4.7 is there any particular reason we are not using the current stable version 1.6.0? can we use that considering it should have bugfixes and be more stable
 

MuneebMufti

Dabbler
Joined
May 5, 2014
Messages
36
guys i am stuck at last step when i open jail-ip/owncloud i get blank page when i try jail-ip only i get 403 forbidden message. i had this issue last time i installed it in jail but I did what MrMuppet wrote on page 5 and changed permissions of owncloud folder to 755 and that time it worked. this time thats not working. did anyone else have blank page after following the guide ? if so how did you fix it. thank you

EDIT: Nevermind fixed the problem. As someone pointed out in the middle of thread to add only to the contents of nginx.conf file from the first post only. if you use the contents from lower posts or 2nd or 3rd page opening owncloud brings up blank page
 

Michael Sparks

Explorer
Joined
Apr 23, 2014
Messages
56
First off thank you Joshua & Cyberjock (SSL) for your tutorials for ownCloud. After the past couple days (multiple attempts) I've been successful in installing owncloud with SSl support. My only problem now is I am unable to access owncloud outside my local network, I'm quite stumped. I have forwarded ports 80 (added "listen 80;" to nginx config), and 443 on my router to the jail ip of owncloud. I have no-ip.org for my ddns setup, and tested it with by accessing my router from the outside to make sure that all worked, it did. I have read this entire thread and tried to follow the prior posts of Aubury and attempted to try and figure out if I was having the same problem but could not quite understand it. I've searched other forums and google links to the similar problem but have had no luck either. Just so you know my level of knowledge I just started using freenas about 2 months ago, mostly been following how-to's and testing a lot but still obviously a novice. Below is my test.php output. and I also added my ngnix.conf as an attachment. Any help would be greatly appreciated.
Untitled-1.jpg
 

Attachments

  • nginx conf.txt
    1.9 KB · Views: 392
Joined
Apr 22, 2014
Messages
4
For some reason, starting today, after I updated openssl from ports I started getting 502 bad gateway when trying to get to my owncloud instance. This is what I get when I looked at the nginx-error logs
Code:
2014/05/04 13:35:30 [crit] 66145#0: *1 connect() to unix:/var/run/php-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 192.168.1.1, server: mydomain.com, request: "PROPFIND /owncloud/remote.php/webdav/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "mydomain.com"

Not sure what's going on here...

Edit:
removing the comment out on
Code:
listen.owner = www
listen.group = www

fixed it.

This needs to be fixed in the OP. I ran into the same issue. I believe an update to the php-fpm package is now enforcing user permissions on the socket? I never looked closed at the permission of the socket to be sure.

But to be clear. The edit Aubury made was to the php-fpm.conf file. The socket now needs be the same permission as the nginx user (which for this tutorial is 'www').
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
it should always have been enforcing permissions on the socket, wonder what changed? I'll revise the OP once I get the chance to test.
 

JTT0

Explorer
Joined
Dec 21, 2013
Messages
82
Ok, so I followed these instructions to a T and have had various problems. Please help me understand what I have done wrong.

Primarily, the NGINX PHP config does not seem to work. I have been trying everything under the sun for the past week to get NGINX redirecting PHP to Owncloud properly, but all I get is the opportunity to download the Owncloud "index.php" file. I have tried the NGINX.conf file from this post as well as the NGINX.conf file on the Owncloud website (http://doc.owncloud.org/server/6.0/.../installation_source.html#nginx-configuration). Neither are working, so I have created a hybrid version below.

Please assist as I would rather get the performance out of this setup then using the Plugin.

Here is my NGINX.conf file:

Code:
#user  nobody;                                                                                                                   
worker_processes  4;                                                                                                             
                                                                                                                                 
#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;                                                                                                                                                                                                                                                  
 
    upstream php-handler {                                                                                                       
        server unix:/var/run/php-fpm.sock;                                                                                     
    }                                                                                                                                                                                                                                                           
 
    server {                                                                                                                       
        listen 80;                                                                                                                                                                                                                                                     
                                                                                                                                   
        # Path to the root of your installation                                                                                   
        root /usr/local/www/;                                                                                                     
                                                                                                                                   
        # Base Server Locations                                                                                                   
        location = /robots.txt { allow all; log_not_found off; access_log off; }                                                   
        location = /favicon.ico { access_log off; log_not_found off; }                                                             
                                                                                                                                   
        # OwnCloud Installation                                                                                                   
        location ^/owncloud {                                                                                                     
            index index.php;                                                                                                       
            error_page 403 /core/templates/403.php;                                                                               
            error_page 404 /core/templates/404.php;                                                                               
                                                                                                                                   
            # Service Configuration                                                                                               
            client_max_body_size 10G; # set max upload size                                                                       
            fastcgi_buffers 64 4K;                                                                                                 
                                                                                                                                   
            # Service Rewrites                                                                                                     
            rewrite ^/owncloud/caldav(.*)$ /remote.php/caldav$1 redirect;                                                         
            rewrite ^/owncloud/carddav(.*)$ /remote.php/carddav$1 redirect;                                                       
            rewrite ^/owncloud/webdav(.*)$ /remote.php/webdav$1 redirect;                                                         
            rewrite ^/owncloud/apps/([^/]+)/(.+\.(css|php))$ /owncloud/index.php?app=$1&getfile=$2 last;                           
            rewrite ^/owncloud/remote/(.*)$ /owncloud/remote.php/$1 last;                                                         
                                                                                                                                   
            # The following 2 rules are only needed with webfinger                                                                 
            rewrite ^/.well-known/host-meta /public.php?service=host-meta last;                                                   
            rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last; 
 
            rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;                                                           
            rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;                                                             
            rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;                                                                           
            try_files $uri $uri/ /index.php?$args;                                                                                 
                                                                                                                                   
            location ~ ^/(data|config|\.ht|db_structure\.xml|README) {                                                             
                deny all;                                                                                                         
            }                                                                                                                     
                                                                                                                                   
            # Optional: set long EXPIRES header on static assets                                                                   
            location ~* ^.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf|svg)$ {                                                         
                expires 30d;                                                                                                       
                # Optional: Don't log access to assets                                                                             
                access_log off;                                                                                                   
            }                                                                                                                     
                                                                                                                                   
            location ~ ^(.+?\.php)(/.*)?$ {                                                                                       
                try_files $1 = 404;                                                                                               
                                                                                                                                   
                include fastcgi_params;                                                                                           
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;                                                 
                fastcgi_param PATH_INFO $2;                                                                                       
                fastcgi_pass php-handler;                                                                                         
            }                                                                                                                     
        }                                                                                                                         
    }                                                                                                                             
}         
 


Thanks for the help!
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
your not actually getting the correct script filename anywhere there.

I wouldn't use the way OC 6 manual recommends. I already changed the manual for the upcomming OC 7 to use fastcgi_split_path_info.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
also when oc 7 releases in a month I'll post my full setup and config for freenas. but after that I'll ask that someone else make a stickied thread and maintain the OP cause my production OC setup is a bit different then what I'm posting.
 

JTT0

Explorer
Joined
Dec 21, 2013
Messages
82
also when oc 7 releases in a month I'll post my full setup and config for freenas. but after that I'll ask that someone else make a stickied thread and maintain the OP cause my production OC setup is a bit different then what I'm posting.

Good to know. Thanks for the quick reply!

My only concern here is that I tried your config from page 1, but yet still was prompted to download the file as opposed to viewing the page. Any thoughts on what I can change?
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Good to know. Thanks for the quick reply!

My only concern here is that I tried your config from page 1, but yet still was prompted to download the file as opposed to viewing the page. Any thoughts on what I can change?
a quick and dirty solution would be to copy over my server block in its entirety, and replace any other ones there. next time I'm just going to post the full file because people seems to have a lot of problems with nginx configs.
 

JTT0

Explorer
Joined
Dec 21, 2013
Messages
82
a quick and dirty solution would be to copy over my server block in its entirety, and replace any other ones there. next time I'm just going to post the full file because people seems to have a lot of problems with nginx configs.

That is exactly where I began. I removed my Server block and dropped yours in, no changes. It was missing a few "~" on the locations inside /owncloud. After fixing that, I got the download issue. As for NGINX config, I am new to it, but nowhere near a novice, I actually have this server sitting behind an NGINX Reverse Proxy doing some magic on the front-end. As for my tests, they were all via the direct IP, so the Reverse Proxy was never hit, just the Cloud Server itself.

Do you have any other thoughts on fixing this? I have also copy/pasted the NGINX server block from a post on the first page where the user had the location issue as I did. Nothing seems to work. I have also been clearing my cache between runs as to avoid any web caching issue.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Just did a pkg-ng update and upgrade and nginx is now barfing all over itself with 'bad gateway' messages. :P

Going to investigate...
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
That is exactly where I began. I removed my Server block and dropped yours in, no changes. It was missing a few "~" on the locations inside /owncloud. After fixing that, I got the download issue. As for NGINX config, I am new to it, but nowhere near a novice, I actually have this server sitting behind an NGINX Reverse Proxy doing some magic on the front-end. As for my tests, they were all via the direct IP, so the Reverse Proxy was never hit, just the Cloud Server itself.

Do you have any other thoughts on fixing this? I have also copy/pasted the NGINX server block from a post on the first page where the user had the location issue as I did. Nothing seems to work. I have also been clearing my cache between runs as to avoid any web caching issue.
I'll post the full config tonight when I get home from work. that should minimize the chance of any problems.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Just did a pkg-ng update and upgrade and nginx is now barfing all over itself with 'bad gateway' messages. :p

Going to investigate...
does php55 have the fpm option enabled in the compiled version? it didn't at first, then recently added it. if they removed it, were back to compiling php55 from ports and not upgrading it with pkg.
 
Top