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?

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.

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

Ok, you can get it from http://download.webmin.com/download/plugins/virtualmin-nginx-1.21.wbm.gz

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

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.

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?

Your code without code tag :slight_smile: 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

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"

Yes this works.

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!