PHP Applications - NGINX + PHP-FPM (+MySQL) - Jail Install and Setup

Status
Not open for further replies.

Joshua Parker Ruehlig

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

here is the sockstat:

owncloud# sockstat
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
www-ajaxplorer php-fpm4292 0 stream /var/run/php-fpm-ajaxplorer.sock
www-ajaxplorer php-fpm4291 0 stream /var/run/php-fpm-ajaxplorer.sock
www php-fpm 4290 0 tcp4 127.0.0.1:9000 *:*
www php-fpm 4289 0 tcp4 127.0.0.1:9000 *:*
root php-fpm 4288 10 stream -> ??
root php-fpm 4288 11 stream -> ??
root php-fpm 4288 12 tcp4 127.0.0.1:9000 *:*
root php-fpm 4288 13 stream /var/run/php-fpm-ajaxplorer.sock
www nginx 4281 5 stream -> ??
www nginx 4281 6 tcp4 *:80 *:*
mysql mysqld 4138 13 tcp4 6 *:3306 *:*
mysql mysqld 4138 15 stream /tmp/mysql.sock
root cron 3472 4 dgram -> /var/run/logpriv
root nginx 3291 4 stream -> ??
root nginx 3291 5 stream -> ??
root nginx 3291 6 tcp4 *:80 *:*
root syslogd 3102 4 dgram /var/run/log
root syslogd 3102 5 dgram /var/run/logpriv
owncloud#

Did you follow the owncloud guide or the ajaxplorer guide? Your socket is residing at "/var/run/php-fpm-ajaxplorer.sock"
 

Scareh

Contributor
Joined
Jul 31, 2012
Messages
182
just wondering Joshua, for the moment ajaxplorer runs at jailip/ajaxplorer.
Is it possible to make it run at jailip: portnumber?
Our ISP is blocking all ports under 1024, so it would be easier for me to forward a port to my intern network this way.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
just wondering Joshua, for the moment ajaxplorer runs at jailip/ajaxplorer.
Is it possible to make it run at jailip: portnumber?
Our ISP is blocking all ports under 1024, so it would be easier for me to forward a port to my intern network this way.

sure, in you nginx server block add 'listen portnumber;'
You can optionally remove the '/ajaxplorer' subdirectory..

Anything is possible, it's a webserver. =]
 

Scareh

Contributor
Joined
Jul 31, 2012
Messages
182
what do you mean by "remove the subdirectory"?
as in place the files that are now under /ajaxplorer directly in the "www"-folder?

I added the listen *portnumber* in the domain.conf and that seems to work.

Do I point the location to the www-directory now?

Code:
server {
	root /usr/local;
      listen 35535;
	location ^~ /www {
		index index.php;
		try_files $uri $uri/ /index.php?$args;
		client_max_body_size 512M; #Increase max upload size
		location ~ ^/www/(conf|data/(files|personal|logs|plugins|tmp|cache)|\.htaccess|plugins/editor.zoho/agent/files) {
			deny all;
		}
		location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|svg)$ {
			expires max;
		}
		location ~ \.php$ {
			try_files $uri =404;
			fastcgi_pass unix:/var/run/php-fpm-ajaxplorer.sock;
			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
			include fastcgi_params;
		}
	}
}




edit:

nvm found it myself ^^

Code:
server {
	root /usr/local/www;
      listen 35535;
	location ^~ / {
		index index.php;
		try_files $uri $uri/ /index.php?$args;
		client_max_body_size 512M; #Increase max upload size
		location ~ ^/www/(conf|data/(files|personal|logs|plugins|tmp|cache)|\.htaccess|plugins/editor.zoho/agent/files) {
			deny all;
		}
		location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|svg)$ {
			expires max;
		}
		location ~ \.php$ {
			try_files $uri =404;
			fastcgi_pass unix:/var/run/php-fpm-ajaxplorer.sock;
			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
			include fastcgi_params;
		}
	}
}


guess i should look a bit further before posting questions...
its just so tempting to ask and get answers from you guys, much faster and less prone to breaking stuff :p
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I updated the owncloud guide to work with owncloud 5 series. I tested it with owncloud 5.0.4 on php 5.4 and everything sees to work perfectly.

I am also going to soon add compiling php-fpm/mariadb from ports, and using mysql with owncloud.
 

Scareh

Contributor
Joined
Jul 31, 2012
Messages
182
if you're at it, can you add the SSL you were talking about it in your first post(s)?
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
if you're at it, can you add the SSL you were talking about it in your first post(s)?

I actually don't do SSL through nginx.. I am planning on using HAProxy on my PfSense router. I can try adding it eventually though, but it will be untested.
 

Atomic

Contributor
Joined
Oct 20, 2012
Messages
160
Hi,

I had ownCloud 5.0.4 working, but since I updated to 5.0.5 it just shows "ownCloud is in maintenance mode". :(

Bildschirmfoto 2013-04-21 um 06.32.19.jpg

What happened?
 

Bjarke

Cadet
Joined
Apr 21, 2013
Messages
1
edit /usr/local/www/owncloud/config/config.php and change maintenance from true to false, save the file and then just to be sure do

service nginx restart

then just reload the page, and it should complete the upgrade and everything is fine :smile:
 

Atomic

Contributor
Joined
Oct 20, 2012
Messages
160
Hi,

the "maintenance" seams to be resolve. But now I can't log in any more, ownCloud alway rejects me login. :confused:

Bildschirmfoto 2013-04-21 um 13.17.05.jpg

And the /usr/local/www/owncloud/config/config.php says 'version' => '5.0.6', but version 5.0.5 is installed.


<?php
$CONFIG = array (
'instanceid' => '517312dd55c97',
'passwordsalt' => '18092f97ba66cb8995ad54197dd350',
'datadirectory' => '/usr/local/www/owncloud/data',
'dbtype' => 'sqlite3',
'version' => '5.0.6',
'installed' => true,
'maintenance' => false,
);
 

mcolinp

Explorer
Joined
Jan 30, 2013
Messages
84
I tried this yesterday and ran into some problems. I successfully got the Jail to install. and As well I seemed to get nginx installed (Though uncertain if it is usable yet).
After I followed the step: "pkg_add -r nginx" the first time it seemed to not like something, then after a reboot; it said it was already installed. Now when I go in the Jail to check options in the "nginx.conf" file; I have no priveledges to do anything with it. I have copied it to a client machine and made changes, thinking I could just replace the old one with the edited version; No-Go.

What am I missing here? I am willing to admit that code (text - command line) based interaction is not my strong point; yet I am not intimidated by it either.

My overall gaol is to have my FreeNAS box equiped with the following:

AjaXplorer for remote access, and remote multi user management

Through my research, it seems that the Jail needs to have nginx and php at minimum for this to work.

I also will eventually be looking to install postgreSQL as a primary databse for xTuple erp/crm.

Any help that will get me pointed in the right direction is greatly appreciated. In other forum posts; it seems there may be a bug or recent oversight error as far as permissions within the jail.
If anyone can shed some light on this; please join the conversation.

Thanks



I thought it would be good to have a single place to link setup guides for popular PHP applications.
If anyone has an application setup guide please post it and I'll link it here.
Also, if you want to edit my install guide below I'm open to suggestions.

Do all of the command in your Plugins Jail's userland, you can enter it from the FreeNAS userland with..
Code:
jls # find you jail's id number
jexec ID csh # replace 'ID' with your jail's id number


NGINX INSTALL
Code:
pkg_add -r nginx

/usr/local/etc/nginx/nginx.conf
Code:
worker_processes  2; #Your number of threads
events {
worker_connections  1024;
}
http {
include		mime.types;
default_type	application/octet-stream;
	sendfile	off; #Disable for files served from zfs
	gzip		on;
	include	domain.conf; #This is where I will put my server block(s)
}
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
You rebooted your FreeNAS OS or the jail? you never should have to reboot to install a program. What does 'service nginx start' in your jail output?

I tried this yesterday and ran into some problems. I successfully got the Jail to install. and As well I seemed to get nginx installed (Though uncertain if it is usable yet).
After I followed the step: "pkg_add -r nginx" the first time it seemed to not like something, then after a reboot; it said it was already installed. Now when I go in the Jail to check options in the "nginx.conf" file; I have no priveledges to do anything with it. I have copied it to a client machine and made changes, thinking I could just replace the old one with the edited version; No-Go.

What am I missing here? I am willing to admit that code (text - command line) based interaction is not my strong point; yet I am not intimidated by it either.

My overall gaol is to have my FreeNAS box equiped with the following:

AjaXplorer for remote access, and remote multi user management

Through my research, it seems that the Jail needs to have nginx and php at minimum for this to work.

I also will eventually be looking to install postgreSQL as a primary databse for xTuple erp/crm.

Any help that will get me pointed in the right direction is greatly appreciated. In other forum posts; it seems there may be a bug or recent oversight error as far as permissions within the jail.
If anyone can shed some light on this; please join the conversation.

Thanks



I thought it would be good to have a single place to link setup guides for popular PHP applications.
If anyone has an application setup guide please post it and I'll link it here.
Also, if you want to edit my install guide below I'm open to suggestions.

Do all of the command in your Plugins Jail's userland, you can enter it from the FreeNAS userland with..
Code:
jls # find you jail's id number
jexec ID csh # replace 'ID' with your jail's id number


NGINX INSTALL
Code:
pkg_add -r nginx

/usr/local/etc/nginx/nginx.conf
Code:
worker_processes  2; #Your number of threads
events {
worker_connections  1024;
}
http {
include		mime.types;
default_type	application/octet-stream;
	sendfile	off; #Disable for files served from zfs
	gzip		on;
	include	domain.conf; #This is where I will put my server block(s)
}
 

mcolinp

Explorer
Joined
Jan 30, 2013
Messages
84
Thanks for the response Joshua,

I decided to scrap my USB and reinstall FreeNAS clean and start over with the jail using Ports this time. I will post back later.
 

mcolinp

Explorer
Joined
Jan 30, 2013
Messages
84
Joshua,

I would be interested in your feedback about the preferred setup for the Jail itself; as I am suspicious that my first attempt may have been less than ideal.

I have a 1.8TB Raid 5 (4 disks) format = ZFS

The main directory where I would share files is a couple folders deep; mnt/Volume/Shared (for example).
There are more folders in the main root "Volume"; mnt/Volume = contains these folders;
Confidential
Jail
Software

So as you can see I originally tried to just make a directory for the "Jail" that was outside of normal user access. As well, I made a separate directory for the software which would run in the jail; as I thought this was what the documentation was wanting me to do.

Further info to note; the actual FreeNAS runs on a seperate USB stick; not the 1.8tb ZFS Pool.

So my question is should I be creating separate ZFS Volume; like somehow splitting another partition from the existing one, (or two even).

I am open to trying anything; but if you think my original directory Jail install was a potential for issues; please give me advice as to what is the safest route to success.

Thanks

[added edit]: Also, I thought of trying to use additional USB thumb drives (for the Jail); but research seemed to warn against this setup. I have quite a few large thumb drives; Like 32 & 64gb.
 

mcolinp

Explorer
Joined
Jan 30, 2013
Messages
84
Ok, I am really stuck here:

I have tried multiple ways of deleting the Jail and its associated directories since doing a fresh install. NO GO!

It wants me to reinstall a new Jail; and it won't let me use the same directories; and it won't let me delete them (from the old Jail) either!! Very FRUSTRATED!!!
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Ok, I am really stuck here:

I have tried multiple ways of deleting the Jail and its associated directories since doing a fresh install. NO GO!

It wants me to reinstall a new Jail; and it won't let me use the same directories; and it won't let me delete them (from the old Jail) either!! Very FRUSTRATED!!!

I'm confused, you can't just delete the datasets the jail and plugins reside on?
 

mcolinp

Explorer
Joined
Jan 30, 2013
Messages
84
Well what happened is I did not realize I should have deleted the Jail before doing a clean re-install of FreeNAS. If I had, I would have been able to delete it using the GUI.

I have a single large 4-disk RAID Pool (ZFS); I wasn't clear on the preferred setup for the Jail. It seemed obvious that you wouldn't want it on the same drive as the FreeNAS OS (A USB thumb drive in my case). So on my first attempt to install the Jail, I decided to just install the jail and the software for the Jail in two seperate folders
In the root directory of my main 2TB Raid. I chose this because I leave the root directory as unexplorable for normal browsing; only sharing one main folder directory for normal file browsing.

So; since I decided to do a fresh install of the freeNAS; it now does not have any "authority" or even knowledge of the previously installed Jail. I tried to install a Jail again, pointing it to the existing directories; it refused to install and complained that a jail was already there.

at this point I started doing a cp -r copy of everything to a single 2TB hard drive; in anticipation that breaking up the RAID array and wiping the data may be my last option.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Well what happened is I did not realize I should have deleted the Jail before doing a clean re-install of FreeNAS. If I had, I would have been able to delete it using the GUI.

I have a single large 4-disk RAID Pool (ZFS); I wasn't clear on the preferred setup for the Jail. It seemed obvious that you wouldn't want it on the same drive as the FreeNAS OS (A USB thumb drive in my case). So on my first attempt to install the Jail, I decided to just install the jail and the software for the Jail in two seperate folders
In the root directory of my main 2TB Raid. I chose this because I leave the root directory as unexplorable for normal browsing; only sharing one main folder directory for normal file browsing.

So; since I decided to do a fresh install of the freeNAS; it now does not have any "authority" or even knowledge of the previously installed Jail. I tried to install a Jail again, pointing it to the existing directories; it refused to install and complained that a jail was already there.

at this point I started doing a cp -r copy of everything to a single 2TB hard drive; in anticipation that breaking up the RAID array and wiping the data may be my last option.

If you are using ZFS then you should be using datasets. you can use them to keep certain data seperate from each other, and keep snapshots of specific datasets. If you can, I would just reinstall you plugins jail on a dataset and delete the old one. There are videos + a wiki that outline the steps to install your plugins jail on freenas, and I beieve they tell you to use a dataset. Once you got everything working, take a snapshot so you can always revert back.
 

mcolinp

Explorer
Joined
Jan 30, 2013
Messages
84
Thanks Joshua.

I have begun doing more research on "datasets". I was previously unaware of the difference of a dataset vs a volume. It's starting to make sense now.
 
Status
Not open for further replies.
Top