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

beltet

Dabbler
Joined
Sep 24, 2013
Messages
26
Hi!
First of I want to thank Joshua for the guide and everything. I choosed this guide because that Cyberjock made SSL to work, so thanks for that aswell.

But...
I stumbled upon some bumps here. When I'm going to acces the webgui I only get a 502 Bad gateway. i belive its a nginx problem. But not sure.
Can you have a look at the nginx code I have and see if thats the problem.
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;
 
    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 15G;
        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;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
        location ~* \.(?:jpg|gif|ico|png|css|js|svg)$ {
            expires max; add_header Cache-Control public;
        }
    }
}
 
 
 
}


I deleted quite much that I thougt I didn't needed. Those blocks was marked with #(bypassed?) and made some errors when I was trying to start the nginx server. Maybe I deleted to much? I have tried to restart(start and stop) the jail with no success. Hope I have given you the info you need.
Sincerely
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
You read this thread? I already discussed this very recently. ;)
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I posted the complete contents of my nginx.conf
Check cyberjock's post to enable https
 

beltet

Dabbler
Joined
Sep 24, 2013
Messages
26
You read this thread? I already discussed this very recently. ;)
Thanks for pointing that out, I thought I had read everything but missed a post there you have to edit /usr/local/etc/php-fpm.conf and remove the ; marks in front of listen.owner and listen.group.
Now the HTTP works. But then I had some problems with SSL/HTTPS...

First of some of the commands in you post didn't work. Don't know if its only me or if it's a typo. But they were:
service stop nginx (quite certain its a typo, you changed the order in rest of you guide)
make /usr/ports/www/nginx install (did not work because make didn't know what to do when using that command on my machine)
I had to use:
Code:
cd /usr/ports/www/nginx
make install clean; rehash


After that everything worked and I could access ip/owncloud.
But after adding the SSL lines in nginx.conf I cant access it, and no errors comes up when loading nginx.conf.
Any thoughts? Adding nginx.conf with added SSL to let you look at:
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;
    ssl_certificate /usr/local/etc/nginx/server.crt;
ssl_certificate_key /usr/local/etc/nginx/server.key;
 
    server {
    listen 443 ssl;
    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 15G;
        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;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
        location ~* \.(?:jpg|gif|ico|png|css|js|svg)$ {
            expires max; add_header Cache-Control public;
        }
    }
}
 
 
 
}
 

beltet

Dabbler
Joined
Sep 24, 2013
Messages
26
Ok! Now I feel really dumb...
I got it working... What I had to do is put https:// in front of the ip.... Can be useful for someone with a smaller brain like me...
Another thing thats good to know is that if you have setup with Joshua's guide and the setup with Cyberjock's guide you can get an error that your account can have been modified. And you cannot log in. What I did was just to empty the cache in the browser and was up and running again.
Why I got the error had something to do with that I made some of the configuration on my phone. And then later do the rest on the computer. That's what I belive.

Anyway! Big Thanks To Joshua and Cyberjock for the fine guides!

Sincerely
 

JTT0

Explorer
Joined
Dec 21, 2013
Messages
82
Josh,

Still no success using your full NGINX.conf file. I will keep poking around, but there is something weird going on here. Any thoughts as to where else could be "blocking" the transmission of PHP?
 

Joshua Parker Ruehlig

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

Still no success using your full NGINX.conf file. I will keep poking around, but there is something weird going on here. Any thoughts as to where else could be "blocking" the transmission of PHP?
just a sanity check. have you been reloading your config 'service nginx reload'. can you clear you browser cache, then test while in private browsing mode.
 

JTT0

Explorer
Joined
Dec 21, 2013
Messages
82
just a sanity check. have you been reloading your config 'service nginx reload'. can you clear you browser cache, then test while in private browsing mode.

I wish it was that easy, :P

I have automatically clear cache/cookies on exit from Firefox and have been clearing it manually as I test. I have not run the service reload command before, so I ran that (Been running restart) and still the same results.

The only notable difference in my setup from yours is that I use www as the user, but have a specific group assigned to allow access to my FreeNAS storage area (Your "Tank"). Other than that I am just running a non-vanilla Standard Jail.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
it's still prompting you to download index.php? is the file actually being served correctly? that would indicate the php block isn't catching for some reason.
 

JTT0

Explorer
Joined
Dec 21, 2013
Messages
82
it's still prompting you to download index.php? is the file actually being served correctly? that would indicate the php block isn't catching for some reason.

Yes, I can successfully download/view the file.
 

neto_hugo

Explorer
Joined
Mar 6, 2012
Messages
87
Guys I'm having an odd problem here.

I got OCloud working. Then I rebooted the FreeNAS and started the tutorial to access OCloud with SSL (CJ tuto).

In the first step it says to access the OC by IP (http://ip/owncloud) so... has come to my surprise! Entered on screen requesting the FreeNAS login and password. :eek:

Example: my FreeNAS IP: 192.168.0.8
IP OC: 192.168.0.10/owncloud

When I type the second IP I access the OS!

To complete even further this weird problem when I enter the my DDNS address (ie http://myaddress.no-ip.etc) comes up on the screen a nginx warning:

Welcome to nginx!

"If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx."

Where will I had a mistake?! o_O

Thanks for the help!
 

mrMuppet

Contributor
Joined
Mar 14, 2014
Messages
192
Did you try your dyndns-adresss with "/owncloud/"? In my installation I have to use it. When I enter no subdirectory I get an error and when I use the subdirectory "/nginx/" I get the welcomescreen you see.

Gesendet von meinem Galaxy S3 mit Tapatalk.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I was testing the new owncloud on my webserver today and noticed the issue with sockets. The default config changed socket permissions from 666 to 660. I'll update the php-fpm.conf in the opening post to resolve the issue.
 
Joined
Jun 23, 2014
Messages
3
Hi. is it possible to make changes to owncloud pbi so it uses nginx and the other stuff.
or do i need to make my own jailplugin and install it,
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Hi. is it possible to make changes to owncloud pbi so it uses nginx and the other stuff.
or do i need to make my own jailplugin and install it,
we'd need to create a new pbi from scratch. possible and I can advise someone on it, but this method works the best in my opinion for this particular application.
 

norskman

Contributor
Joined
Sep 28, 2012
Messages
149
Considering all of the pain - I think it better to wait for the new release V7.0 and go from there......preferably with a real plugin.

key issues:
1. files need to be added through the owncloud Database - not by adding them to the directory and then doing a scan of that directory. This is very annoying when trying to add lots of files.
2. This point 1. makes upgrading or creating a new owncloud difficult as all the new files need to be added all over again.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Better yet skip the plugin idea and go with your own jail in whatever configuration makes you happy.
 
Joined
Jun 23, 2014
Messages
3
thx for the guide on how to install owncloud.
and thx for the ssl how to.

before it took like 2 days to upload 80Gb of photos/small files after this guide it took like 2h..
 

nasuser12

Dabbler
Joined
Feb 21, 2014
Messages
14
Just did a pkg-ng update and upgrade and nginx is now barfing all over itself with 'bad gateway' messages. :p

Going to investigate...

Did you find a solution to this problem? I thought I'd update the packages in my jail, but also now face 'bad gateway' messages. To anyone reading this: do not update the jail, since it might break nginx.
Cyberjock, did you find a way to roll back to the old situation? Or did you manage to fix this issue in some other way? I'm very interested if you have ;-)
 
Top