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

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I restarted Freenas just to make sure it nextcloud would work again, and to my surprise when I went to the URL is says:
Code:
502 Bad Gateway
nginx/1.10.2


so I went into the jail shell and did the following:
Code:
root@nextcloud_1:/ # service nginx restart																						
Performing sanity check on nginx configuration:																					
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok														
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful														
Stopping nginx.																													
Waiting for PIDS: 33869.																											
Performing sanity check on nginx configuration:																					
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok														
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful														
Starting nginx.																													
root@nextcloud_1:/ # sockstat -l																									
USER	 COMMAND	PID   FD PROTO  LOCAL ADDRESS		 FOREIGN ADDRESS														
www	  nginx	  34005 7  tcp4   *:80				  *:*																	
www	  nginx	  34004 7  tcp4   *:80				  *:*																	
root	 nginx	  34003 7  tcp4   *:80				  *:*																	
mysql	mysqld	 33091 70 stream /tmp/mysql.sock																				
www	  php-fpm	32983 0  tcp4   127.0.0.1:9000		*:*																	
www	  php-fpm	32982 0  tcp4   127.0.0.1:9000		*:*																	
root	 php-fpm	32981 7  tcp4   127.0.0.1:9000		*:*																	
redis	redis-serv 32977 4  stream /tmp/redis.sock																				
root	 syslogd	32916 4  dgram  /var/run/log																					
root	 syslogd	32916 5  dgram  /var/run/logpriv																				
root	 syslogd	32916 6  udp6   *:514				 *:*																	
root	 syslogd	32916 7  udp4   *:514				 *:*																	
root@nextcloud_1:/ #											



I checked the nginx.conf and www.conf files and they look the same like I left them before the restart.
What can it be now ?
your php isn't running. it should have been enabled when your did the 'sysrc' command.
 

msvuze

Dabbler
Joined
Dec 11, 2016
Messages
45
your php isn't running. it should have been enabled when your did the 'sysrc' command.
Code:
root@nextcloud_1:/ # sysrc 'nginx_enable=YES' 'php_fpm_enable=YES' 'mysql_enable=YES' 'redis_enable=YES'							
nginx_enable: YES -> YES																											
php_fpm_enable: YES -> YES																										
mysql_enable: YES -> YES																											
redis_enable: YES -> YES																											
root@nextcloud_1:/ # service php-fpm start																						 
php_fpm already running?  (pid=32981).																							 
root@nextcloud_1:/ #
 
Last edited:

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Code:
root@nextcloud_1:/ # sysrc 'nginx_enable=YES' 'php_fpm_enable=YES' 'mysql_enable=YES' 'redis_enable=YES'							
nginx_enable: YES -> YES																											
php_fpm_enable: YES -> YES																										
mysql_enable: YES -> YES																											
redis_enable: YES -> YES																											
root@nextcloud_1:/ # service php-fpm start																						
php_fpm already running?  (pid=32981).																							
root@nextcloud_1:/ #
it was already enabled apparently, the question is why it didn't start. does it start when you run 'service php-fpm start'
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
No :( it say's its already running and it looks like it is but It's not ?
maybe it has a stslr pidfil in /var/run. this shouldn't happen though, but maybe php-fpm crashed last time it started
 

msvuze

Dabbler
Joined
Dec 11, 2016
Messages
45
maybe it has a stslr pidfil in /var/run. this shouldn't happen though, but maybe php-fpm crashed last time it started
Sorry, I'm lost how do I check that ?
Code:
root@nextcloud_1:/ # cd /var/run																									
root@nextcloud_1:/var/run # ls																									 
clean_var			   ld-elf.so.hints		 nginx.pid			   syslog.pid			  wpa_supplicant					 
cron.pid				ld-elf32.so.hints	   php-fpm.pid			 syslogd.sockets											 
cups					log					 ppp					 tpm														 
dbus					logpriv				 redis				   utx.active												 
root@nextcloud_1:/var/run #
[/code[
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Sorry, I'm lost how do I check that ?
Code:
root@nextcloud_1:/ # cd /var/run																									
root@nextcloud_1:/var/run # ls																									
clean_var			   ld-elf.so.hints		 nginx.pid			   syslog.pid			  wpa_supplicant					
cron.pid				ld-elf32.so.hints	   php-fpm.pid			 syslogd.sockets											
cups					log					 ppp					 tpm														
dbus					logpriv				 redis				   utx.active												
root@nextcloud_1:/var/run #
[/code[
I suggest you delete php-fpm.pid
'rm /var/run/php-fpm.pid'
 

msvuze

Dabbler
Joined
Dec 11, 2016
Messages
45
I suggest you delete php-fpm.pid
'rm /var/run/php-fpm.pid'
Deleted php-fpm.pid, Restarted Freenas and still the same :(
Code:
root@nextcloud_1:/ # service php-fpm start																						 
php_fpm already running?  (pid=4539).																							   
root@nextcloud_1:/ # sockstat -l																									
USER	 COMMAND	PID   FD PROTO  LOCAL ADDRESS		 FOREIGN ADDRESS														   
www	  nginx	  14022 7  tcp4   *:80				  *:*																	   
www	  nginx	  14021 7  tcp4   *:80				  *:*																	   
root	 nginx	  14020 7  tcp4   *:80				  *:*																	   
mysql	mysqld	 4657  70 stream /tmp/mysql.sock																				 
www	  php-fpm	4541  0  tcp4   127.0.0.1:9000		*:*																	   
www	  php-fpm	4540  0  tcp4   127.0.0.1:9000		*:*																	   
root	 php-fpm	4539  7  tcp4   127.0.0.1:9000		*:*																	   
redis	redis-serv 4535  4  stream /tmp/redis.sock																				 
root	 syslogd	4474  4  dgram  /var/run/log																					
root	 syslogd	4474  5  dgram  /var/run/logpriv																				
root	 syslogd	4474  6  udp6   *:514				 *:*																	   
root	 syslogd	4474  7  udp4   *:514				 *:*																	   
root@nextcloud_1:/ #  
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Deleted php-fpm.pid, Restarted Freenas and still the same :(
Code:
root@nextcloud_1:/ # service php-fpm start																						
php_fpm already running?  (pid=4539).																							  
root@nextcloud_1:/ # sockstat -l																									
USER	 COMMAND	PID   FD PROTO  LOCAL ADDRESS		 FOREIGN ADDRESS														  
www	  nginx	  14022 7  tcp4   *:80				  *:*																	  
www	  nginx	  14021 7  tcp4   *:80				  *:*																	  
root	 nginx	  14020 7  tcp4   *:80				  *:*																	  
mysql	mysqld	 4657  70 stream /tmp/mysql.sock																				
www	  php-fpm	4541  0  tcp4   127.0.0.1:9000		*:*																	  
www	  php-fpm	4540  0  tcp4   127.0.0.1:9000		*:*																	  
root	 php-fpm	4539  7  tcp4   127.0.0.1:9000		*:*																	  
redis	redis-serv 4535  4  stream /tmp/redis.sock																				
root	 syslogd	4474  4  dgram  /var/run/log																					
root	 syslogd	4474  5  dgram  /var/run/logpriv																				
root	 syslogd	4474  6  udp6   *:514				 *:*																	  
root	 syslogd	4474  7  udp4   *:514				 *:*																	  
root@nextcloud_1:/ # 
lol, your www.conf is messed up again. how did you manage to do that?
 

msvuze

Dabbler
Joined
Dec 11, 2016
Messages
45
lol, your www.conf is messed up again. how did you manage to do that?
This is how it looks (for the most part, its super long let me know if you want me to include the entire file.)
Code:
root@nextcloud_1:/ # vi /usr/local/etc/php-fpm.d/www.conf  


; Start a new pool named 'www'.																									
; the variable $pool can be used in any directive and will be replaced by the													  
; pool name ('www' here)																											
[www]																															  
																																   
; Per pool prefix																												  
; It only applies on the following directives:																					  
; - 'access.log'																													
; - 'slowlog'																													  
; - 'listen' (unixsocket)																										  
; - 'chroot'																														
; - 'chdir'																														
; - 'php_values'																													
; - 'php_admin_values'																											  
; When not set, the global prefix (or /usr/local) applies instead.																  
; Note: This directive can also be relative to the global prefix.																  
; Default Value: none																											  
;prefix = /path/to/pools/$pool																									  
																																   
; Unix user/group of processes																									  
; Note: The user is mandatory. If the group is not set, the default user's group													
;	   will be used.																											  
user = www																														  
group = www																														
																																   
; The address on which to accept FastCGI requests.																				  
; Valid syntaxes are:																											  
;   'ip.add.re.ss:port'	- to listen on a TCP socket to a specific IPv4 address on												
;							a specific port;																					  
;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on												
;							a specific port;																					  
;   'port'				 - to listen on a TCP socket to all addresses															
;							(IPv6 and IPv4-mapped) on a specific port;															
;   '/path/to/unix/socket' - to listen on a unix socket.																			
; Note: This value is mandatory.																									
;listen = 127.0.0.1:9000																											
;listen = 127.0.0.1:9000																											
; Set listen(2) backlog.																											
; Default Value: 511 (-1 on FreeBSD and OpenBSD)																					
;listen.backlog = 511																											  
																																   
; Set permissions for unix socket, if one is used. In Linux, read/write															
; permissions must be set in order to allow connections from a web server. Many													
; BSD-derived systems allow connections regardless of permissions.																  
; Default Values: user and group are set as the running user																		
;				 mode is set to 0660																							  
																																   
listen.mode = 0660																												  
																																   
;NEW TEST INSERT START																											  
listen = /var/run/php-fpm.sock																									  
listen.owner = www																												  
listen.group = www																												  
env[PATH] = /usr/local/bin:/usr/bin:/bin																							
;NEW TEST INSERT END																												
																																   
; When POSIX Access Control Lists are supported you can set them using															  
; these options, value is a comma separated list of user/group names.															  
; When set, listen.owner and listen.group are ignored																			  
;listen.acl_users =																												
;listen.acl_groups =																												
																																   
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.													
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original													  
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address													
; must be separated by a comma. If this value is left blank, connections will be													
; accepted from any ip address.																									
; Default Value: any																												
;listen.allowed_clients = 127.0.0.1																								
																																   
; Specify the nice(2) priority to apply to the pool processes (only if set)														
; The value can vary from -19 (highest priority) to 20 (lower priority)															
; Note: - It will only work if the FPM master process is launched as root														  
;	   - The pool processes will inherit the master process priority															  
;		 unless it specified otherwise																							
; Default Value: no set																											
; process.priority = -19																											
																																   
; Choose how the process manager will control the number of child processes.														
; Possible Values:																												  
;   static  - a fixed number (pm.max_children) of child processes;																  
;   dynamic - the number of child processes are set dynamically based on the	

and so on.......
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
This is how it looks (for the most part, its super long let me know if you want me to include the entire file.)
Code:
root@nextcloud_1:/ # vi /usr/local/etc/php-fpm.d/www.conf 


; Start a new pool named 'www'.																									
; the variable $pool can be used in any directive and will be replaced by the													 
; pool name ('www' here)																											
[www]																															 
																																  
; Per pool prefix																												 
; It only applies on the following directives:																					 
; - 'access.log'																													
; - 'slowlog'																													 
; - 'listen' (unixsocket)																										 
; - 'chroot'																														
; - 'chdir'																														
; - 'php_values'																													
; - 'php_admin_values'																											 
; When not set, the global prefix (or /usr/local) applies instead.																 
; Note: This directive can also be relative to the global prefix.																 
; Default Value: none																											 
;prefix = /path/to/pools/$pool																									 
																																  
; Unix user/group of processes																									 
; Note: The user is mandatory. If the group is not set, the default user's group													
;	   will be used.																											 
user = www																														 
group = www																														
																																  
; The address on which to accept FastCGI requests.																				 
; Valid syntaxes are:																											 
;   'ip.add.re.ss:port'	- to listen on a TCP socket to a specific IPv4 address on												
;							a specific port;																					 
;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on												
;							a specific port;																					 
;   'port'				 - to listen on a TCP socket to all addresses															
;							(IPv6 and IPv4-mapped) on a specific port;															
;   '/path/to/unix/socket' - to listen on a unix socket.																			
; Note: This value is mandatory.																									
;listen = 127.0.0.1:9000																											
;listen = 127.0.0.1:9000																											
; Set listen(2) backlog.																											
; Default Value: 511 (-1 on FreeBSD and OpenBSD)																					
;listen.backlog = 511																											 
																																  
; Set permissions for unix socket, if one is used. In Linux, read/write															
; permissions must be set in order to allow connections from a web server. Many													
; BSD-derived systems allow connections regardless of permissions.																 
; Default Values: user and group are set as the running user																		
;				 mode is set to 0660																							 
																																  
listen.mode = 0660																												 
																																  
;NEW TEST INSERT START																											 
listen = /var/run/php-fpm.sock																									 
listen.owner = www																												 
listen.group = www																												 
env[PATH] = /usr/local/bin:/usr/bin:/bin																							
;NEW TEST INSERT END																												
																																  
; When POSIX Access Control Lists are supported you can set them using															 
; these options, value is a comma separated list of user/group names.															 
; When set, listen.owner and listen.group are ignored																			 
;listen.acl_users =																												
;listen.acl_groups =																												
																																  
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.													
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original													 
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address													
; must be separated by a comma. If this value is left blank, connections will be													
; accepted from any ip address.																									
; Default Value: any																												
;listen.allowed_clients = 127.0.0.1																								
																																  
; Specify the nice(2) priority to apply to the pool processes (only if set)														
; The value can vary from -19 (highest priority) to 20 (lower priority)															
; Note: - It will only work if the FPM master process is launched as root														 
;	   - The pool processes will inherit the master process priority															 
;		 unless it specified otherwise																							
; Default Value: no set																											
; process.priority = -19																											
																																  
; Choose how the process manager will control the number of child processes.														
; Possible Values:																												 
;   static  - a fixed number (pm.max_children) of child processes;																 
;   dynamic - the number of child processes are set dynamically based on the	

and so on.......
looks correct to me. I don't know why php isn't following that config file. maybe you somehow installed an older version of php that doesn't use that file? what does your 'pkg info | grep php' give you?

what did you do after getting this working, just reboot?
 

msvuze

Dabbler
Joined
Dec 11, 2016
Messages
45
looks correct to me. I don't know why php isn't following that config file. maybe you somehow installed an older version of php that doesn't use that file? what does your 'pkg info | grep php' give you?

what did you do after getting this working, just reboot?
I just reinstalled php7 and it worked!!!!
Code:
pkg install 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-APCu php70-redis


I was trying to enable DOC/DOCX editing and document previews and it told me it was done, then I rebooted and went back to php5.6 ?.

SO HAPPY IT WORKS AGAIN! THANKS A 1,000,000 :)
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I just reinstalled php7 and it worked!!!!
Code:
pkg install 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-APCu php70-redis


I was trying to enable DOC/DOCX editing and document previews.
SO HAPPY IT WORKS AGAIN! THANKS A 1,000,000 :)
hmm, I'm guessing libreoffice is downgrading php. freebsds package system not acting properly.

glad you got it working
 

msvuze

Dabbler
Joined
Dec 11, 2016
Messages
45
hmm, I'm guessing libreoffice is downgrading php. freebsds package system not acting properly.

glad you got it working
Yea, now it's using over 1.5GB's+
I don't even need it really, it was an option so I was like why not.

Now I have to find out how to remove it.

Thanks for the help again.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Yea, now it's using over 1.5GB's+
I don't even need it really, it was an option so I was like why not.

Now I have to find out how to remove it.

Thanks for the help again.
yeah libreoffice is heavy. still better than Microsoft office taking like 4GB+

pkg remove libreoffice
pkg autoremove
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
What is the proper way to upgrade from nextcloud 11 to 11.01? Open updater from the admin panel GUI doesn't do anything.
 

Joshua Parker Ruehlig

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

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
you can use these steps, replacing the archive for nextcloud.
https://forums.freenas.org/index.ph...x-php-fpm-and-mysql.17786/page-47#post-257456

the nextcloud updater had a bug that causes it to not work on freebsd. this is fixed in 11.0.2+
https://github.com/nextcloud/serverinfo/pull/76

Joshua thanks for the links. I was able to upgrade.

mv /usr/local/www/nextcloud /usr/local/www/nextcloud-bak
fetch "https://download.nextcloud.com/server/releases/nextcloud-11.0.1.tar.bz2"
tar jxf nextcloud-*.tar.bz2 -C /usr/local/www
cp /usr/local/www/nextcloud-bak/config/config.php /usr/local/www/nextcloud/config
chown -R www:www /usr/local/www/nextcloud
su -m www -c 'php /usr/local/www/nextcloud/occ upgrade'
rm -r nextcloud-*.tar.bz2 /usr/local/www/nextcloud-bak


I did try to search this large thread for "upgrade". I don't know why but when I try to search the tread for the word upgrade it shows the entire site not the thread even with the search this thread only option ticked.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
yeah I think I get the same issue with the search. I should probably generalize those steps and link them in the first page.
 
Top