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

Chakalov

Explorer
Joined
Feb 9, 2015
Messages
53
I have a probably pretty stupid questions but anyhow: how do I perform an occ update from 8.0.2 to the latest at the moment 8.1.2? I'm asking because when I type

Code:
php /usr/local/www/owncloud/occ upgrade


It says "Console has to be executed with the same user as the web server is operated Current user: root Web server user: www"

Also do I have to take care of other stuff other than the line:

fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;

Thank you in advance!
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I have a probably pretty stupid questions but anyhow: how do I perform an occ update from 8.0.2 to the latest at the moment 8.1.2? I'm asking because when I type

Code:
php /usr/local/www/owncloud/occ upgrade


It says "Console has to be executed with the same user as the web server is operated Current user: root Web server user: www"

Also do I have to take care of other stuff other than the line:

fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;

Thank you in advance!
su www
but first you needs to change the users shell
chsh -s /bin/sh www
I'm not sure what the second part of your question is asking
 

Chakalov

Explorer
Joined
Feb 9, 2015
Messages
53
Sorry for the last part of my post that was pretty unclear. What I wanted to say was regarding this (since I'm using 8.0.1):

Not much need to be changed. Just make sure to remove this line until owncloud 8.0.4 or 8.1 is released.
Code:
fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Sorry for the last part of my post that was pretty unclear. What I wanted to say was regarding this (since I'm using 8.0.1):
That change was only needed for a few versions. I think 8.0.0-8.0.2

I try to keep the OP up tp date so you can refrence that to see what your nginx.conf should look like.
 

Michael Sparks

Explorer
Joined
Apr 23, 2014
Messages
56
Thanks for the tutorial Joshua Parker Ruehlig, when I get to the step were i need to edit the nginx.conf, after running the command "/usr/local/etc/nginx/nginx.conf" I get permission denied, I followed all steps exactly above as mentioned. Running freenas 9.3.1 thanks for assistance.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Thanks for the tutorial Joshua Parker Ruehlig, when I get to the step were i need to edit the nginx.conf, after running the command "/usr/local/etc/nginx/nginx.conf" I get permission denied, I followed all steps exactly above as mentioned. Running freenas 9.3.1 thanks for assistance.
thats not meant to be a command, but a file that you edit.
 

Michael Sparks

Explorer
Joined
Apr 23, 2014
Messages
56
thats not meant to be a command, but a file that you edit.

Joshua Parker Ruehlig, thank you for pointing that out. I dont use command prompt that often. I have however run into another issue, I am unable to find "apc.enable_cli=" in the php.ini (edit /usr/local/etc/php.ini), I used the find command to find the other two but was unable to find the apc line. Other than that everything else was followed and when I tried to access owncloud via http I received "502 Bad Gateway" error. Any idea? Thanks for help as always I cannot wait to use this over dropbox.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Joshua Parker Ruehlig, thank you for pointing that out. I dont use command prompt that often. I have however run into another issue, I am unable to find "apc.enable_cli=" in the php.ini (edit /usr/local/etc/php.ini), I used the find command to find the other two but was unable to find the apc line. Other than that everything else was followed and when I tried to access owncloud via http I received "502 Bad Gateway" error. Any idea? Thanks for help as always I cannot wait to use this over dropbox.
It doesn't exist, you add that line anywhere in the PHP section
 

Michael Sparks

Explorer
Joined
Apr 23, 2014
Messages
56
It doesn't exist, you add that line anywhere in the PHP section

Thanks! I have added the line in. Now im stumped because I am still getting a 502 Bad Gateway (nginx/1.80) error when trying to access the owncloud webpage (http://192.168.12.7/owncloud). I'm guessing it has to do something with the nginx.conf, I had just copy and pasted the one posted in the installation steps. Has anyone else encounter this issue? Thank you for your assistance!
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Thanks! I have added the line in. Now im stumped because I am still getting a 502 Bad Gateway (nginx/1.80) error when trying to access the owncloud webpage (http://192.168.12.7/owncloud). I'm guessing it has to do something with the nginx.conf, I had just copy and pasted the one posted in the installation steps. Has anyone else encounter this issue? Thank you for your assistance!
if you followed the steps perfectly it should work. I'm assuming you problem lies in your nginx config, php-fpm config, or that your php-fpm isn't listening
 

Michael Sparks

Explorer
Joined
Apr 23, 2014
Messages
56
if you followed the steps perfectly it should work. I'm assuming you problem lies in your nginx config, php-fpm config, or that your php-fpm isn't listening

Yah, I cut pasted the exact nginx.conf, and changed everything else as posted in the installation, replaced all lines in the php-fpm config exactly. Wish I could get it working but I understand its hard to trouble shoot blindly from your end. Unfortunately I'm a follow the steps person when it comes to bsd or freenas. Thanks for your help, mabye it has something to do wiht the new freenas update, I have no idea.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Yah, I cut pasted the exact nginx.conf, and changed everything else as posted in the installation, replaced all lines in the php-fpm config exactly. Wish I could get it working but I understand its hard to trouble shoot blindly from your end. Unfortunately I'm a follow the steps person when it comes to bsd or freenas. Thanks for your help, mabye it has something to do wiht the new freenas update, I have no idea.
I can guarantee it has nothing to do with the freenas update. the jails are ridiculously isolated from the freenas install. mind showing the output of 'sockstat'
 

Michael Sparks

Explorer
Joined
Apr 23, 2014
Messages
56
I would glady do anything you need to help me figure this out. what command do I run? also it shouldnt matter that ive been doing all this in putty vs the freenas shell webgui right?
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I would glady do anything you need to help me figure this out. what command do I run? also it shouldnt matter that ive been doing all this in putty vs the freenas shell webgui right?
it shouldn't matter, though I use neither so I'm not sure. the command is 'sockstat' it will show if php is listening
 

Michael Sparks

Explorer
Joined
Apr 23, 2014
Messages
56
root@owncloud:/ # sockstat
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
root cron 97834 4 dgram -> /var/run/logpriv
mysql mysqld 97808 16 stream /tmp/mysql.sock
www nginx 97691 3 stream -> ??
www nginx 97691 7 tcp4 *:80 *:*
www nginx 97691 9 stream -> ??
www nginx 97691 11 stream -> ??
www nginx 97691 14 stream -> ??
www nginx 97689 3 stream -> ??
www nginx 97689 7 tcp4 *:80 *:*
www nginx 97689 8 stream -> ??
www nginx 97689 9 stream -> ??
www nginx 97689 12 stream -> ??
www nginx 97688 3 stream -> ??
www nginx 97688 7 tcp4 *:80 *:*
www nginx 97688 8 stream -> ??
www nginx 97688 9 stream -> ??
www nginx 97688 10 stream -> ??
www nginx 97687 3 stream -> ??
www nginx 97687 7 tcp4 *:80 *:*
www nginx 97687 8 stream -> ??
www nginx 97687 10 stream -> ??
www nginx 97687 11 stream -> ??
root nginx 97686 3 stream -> ??
root nginx 97686 7 tcp4 *:80 *:*
root nginx 97686 8 stream -> ??
root nginx 97686 9 stream -> ??
root nginx 97686 10 stream -> ??
root nginx 97686 11 stream -> ??
root nginx 97686 12 stream -> ??
root nginx 97686 13 stream -> ??
root nginx 97686 14 stream -> ??
www php-fpm 97681 0 stream /var/run/php-fpm.sock
www php-fpm 97680 0 stream /var/run/php-fpm.sock
root php-fpm 97679 8 stream -> ??
root php-fpm 97679 10 stream -> ??
root php-fpm 97679 11 stream /var/run/php-fpm.sock
root syslogd 97631 4 dgram /var/run/log
root syslogd 97631 5 dgram /var/run/logpriv
root syslogd 97631 6 udp6 *:514 *:*
root syslogd 97631 7 udp4 *:514 *:*
root@owncloud:/ # root@owncloud:/ # sockstat
root nginx 97686 11 stream -> ??
root nginx 97686 12 stream -> ??
root nginx 97686 13 stream -> ??
root nginx 97686 14 stream -> ??
www php-fpm 97681 0 stream /var/run/php-fpm.sock
www php-fpm 97680 0 stream /var/run/php-fpm.sock
root php-fpm 97679 8 stream -> ??
root php-fpm 97679 10 stream -> ??
root@owncloud:/: Command not found.
root php-fpm 97679 11 stream /var/run/php-fpm.sock
root syslogd 97631 4 dgram /var/run/log
root syslogd 97631 5 dgram /var/run/logpriv
root syslogd 97631 6 udp6 *:514 *:*
root syslogd 97631 7 udp4 *:514 *:*
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
root@owncloud:/ # sockstat
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
root cron 97834 4 dgram -> /var/run/logpriv
mysql mysqld 97808 16 stream /tmp/mysql.sock
www nginx 97691 3 stream -> ??
www nginx 97691 7 tcp4 *:80 *:*
www nginx 97691 9 stream -> ??
www nginx 97691 11 stream -> ??
www nginx 97691 14 stream -> ??
www nginx 97689 3 stream -> ??
www nginx 97689 7 tcp4 *:80 *:*
www nginx 97689 8 stream -> ??
www nginx 97689 9 stream -> ??
www nginx 97689 12 stream -> ??
www nginx 97688 3 stream -> ??
www nginx 97688 7 tcp4 *:80 *:*
www nginx 97688 8 stream -> ??
www nginx 97688 9 stream -> ??
www nginx 97688 10 stream -> ??
www nginx 97687 3 stream -> ??
www nginx 97687 7 tcp4 *:80 *:*
www nginx 97687 8 stream -> ??
www nginx 97687 10 stream -> ??
www nginx 97687 11 stream -> ??
root nginx 97686 3 stream -> ??
root nginx 97686 7 tcp4 *:80 *:*
root nginx 97686 8 stream -> ??
root nginx 97686 9 stream -> ??
root nginx 97686 10 stream -> ??
root nginx 97686 11 stream -> ??
root nginx 97686 12 stream -> ??
root nginx 97686 13 stream -> ??
root nginx 97686 14 stream -> ??
www php-fpm 97681 0 stream /var/run/php-fpm.sock
www php-fpm 97680 0 stream /var/run/php-fpm.sock
root php-fpm 97679 8 stream -> ??
root php-fpm 97679 10 stream -> ??
root php-fpm 97679 11 stream /var/run/php-fpm.sock
root syslogd 97631 4 dgram /var/run/log
root syslogd 97631 5 dgram /var/run/logpriv
root syslogd 97631 6 udp6 *:514 *:*
root syslogd 97631 7 udp4 *:514 *:*
root@owncloud:/ # root@owncloud:/ # sockstat
root nginx 97686 11 stream -> ??
root nginx 97686 12 stream -> ??
root nginx 97686 13 stream -> ??
root nginx 97686 14 stream -> ??
www php-fpm 97681 0 stream /var/run/php-fpm.sock
www php-fpm 97680 0 stream /var/run/php-fpm.sock
root php-fpm 97679 8 stream -> ??
root php-fpm 97679 10 stream -> ??
root@owncloud:/: Command not found.
root php-fpm 97679 11 stream /var/run/php-fpm.sock
root syslogd 97631 4 dgram /var/run/log
root syslogd 97631 5 dgram /var/run/logpriv
root syslogd 97631 6 udp6 *:514 *:*
root syslogd 97631 7 udp4 *:514 *:*
looks like php is listening at the correct place. you might want to double check your nginx config is perfect. and restart nginx/php-fpm if you have changed their configs.
service nginx restart
 

Michael Sparks

Explorer
Joined
Apr 23, 2014
Messages
56
This is my nginx.conf

Code:
    worker_processes 4;

    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 {
                index index.php;
                try_files $uri $uri/ /owncloud/index.php$is_args$args;
                fastcgi_intercept_errors on;
                error_page 403 /owncloud/core/templates/403.php;
                error_page 404 /owncloud/core/templates/404.php;
                client_max_body_size 512M;
                location ~ ^/owncloud/(?:\.|data|config|db_structure\.xml|README) {
                    deny all;
                }
                location ~ \.php(?:$|/) {
                    fastcgi_split_path_info ^(.+\.php)(/.*)$;
                    fastcgi_pass unix:/var/run/php-fpm.sock;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_param PATH_INFO $fastcgi_path_info;
                    include fastcgi_params;
                    fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
                }
                location ~* \.(?:jpg|gif|ico|png|css|js|svg)$ {
                    expires 30d; add_header Cache-Control public;
                }
                location ^~ /owncloud/data {
                    internal;
                    alias /mnt/files;
                }
            }
        }
    }
 

Michael Sparks

Explorer
Joined
Apr 23, 2014
Messages
56
I have restarted as mentioned, still same result 502 bad gateway. I have also completely stopped the jail, then started it again, same result :(
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I have restarted as mentioned, still same result 502 bad gateway. I have also completely stopped the jail, then started it again, same result :(
can you show the output of the below, this time in a code block.
'sockstat | grep php'
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
also please show the output of "ls -l /var/run/php-fpm.sock"
 
Top