Nginx FreeBSD rc script problem

11 posts / 0 new
Last post
#1 Sun, 02/05/2012 - 05:15
mali11011

Nginx FreeBSD rc script problem

My system is FreeBSD 7.4. I have installed nginx from ports. That worked. Configurated to serve virtualhosts. The problem is about php and php-cgi. virtualmin-nginx module creates a script and adds it to rc.conf. But the first problem is about name of script. FreeBSD dont recognise scripts start command.

Sample start command: php_fcgi_domain.tld_enable="YES"

I manually edited script (usr/local/etc/rc.d/php-fcgi-domain.tld.sh) and changed start name.

It worked but second problem is php-cgi port. Every php-cgi trying to run at same port. So only one php-cgi runs. If i run php-cgi without username all sites php works, but this cause permission problems. So i again manually edited script and changed port number. Like this;

domain1.tld --- 9001 domain2.tld --- 9002 domain3.tld --- 9003

So now it is working. But i have to manually edit all sites.

I am trying to edit module but i do know how to edit, which file to edit.

At the end asking how to edit and which file to edit?

Sun, 02/05/2012 - 21:10
JamieCameron

Thanks for pointing out these issues .. I will fix them in the next release, by changing any dots in the init script name to dashes, and improving free port detection.

Let me know if you'd like a pre-release patch.

''

Mon, 02/06/2012 - 06:27
mali11011

I want very much :) One more thing that i forget, nginx.conf must be same port.

Mon, 02/06/2012 - 13:57 (Reply to #3)
Tue, 02/07/2012 - 05:25
mali11011

I downloaded and installed. But it worked at debian system (port per user), not on FreeBSD. Still testing. I will post details.

Tue, 02/07/2012 - 10:22
mali11011

I find the problem. At the file

/usr/local/webmin/virtualmin-nginx/virtualmin-nginx-lib.pl

Line : 1629

-- last if (!$used{$port} && bind($s, sockaddr_in($port, INADDR_ANY)));
++ last if (!$used{$port} && bind($s, sockaddr_in($port, 127.0.0.1)));

This fixed the problem.

Last problem that i can not solve; when creating rc.script it adds this

stop_cmd="su t15 -c kill\ \`cat\ \/var\/php\-nginx\/13062900643024\.php\.pid\` ; sleep 1"

FreeBSD does not recognise \ \ after cat. I tryied but can not take out escape chars.

Tue, 02/07/2012 - 13:00 (Reply to #6)
JamieCameron

I see the real cause of the problem that your first fix solved, and will release an update shortly ..

Regarding that kill command, the \ \ is supposed to be an escaped space. If you run the command :

su t15 -c kill\ `cat\ \/var\/php-nginx\/13062900643024.php.pid` ; sleep 1

from the shell as root, does it work OK?

''

Tue, 02/07/2012 - 17:22
mali11011

Your code without code tag :) did not worked. Output is :

kill: illegal process id: cat
kill: illegal process id: /var/php-nginx/13062900643024.php.pid

This is the working command:

su t15 -c kill\ `cat /var\/php-nginx\/13062900643024.php.pid` ; sleep 1
Tue, 02/07/2012 - 19:29 (Reply to #8)
JamieCameron

Sorry, some bad escaping happened to my post .. the command I meant to write was :

su t15 -c "kill \`cat /var/php-nginx/13062900643024.php.pid\` ; sleep 1"

''

Wed, 02/08/2012 - 04:23
mali11011

Yes this works.

Wed, 02/08/2012 - 15:33 (Reply to #10)
JamieCameron

Could you email me the rc script Virtualmin creates as an attachment at jcameron@virtualmin.com ? There is too much escaping going on between the shell and the forum for me to be sure what it actually contains!

''

Topic locked