Forum

PHP Fast CGI- 503 Service Unavailable

Prit
10 July 2009, 19:24
Hiawatha version: 6.14
Operating System: Ubuntu 9.04

Hi Hugo,

Firstly, I should say thank you for creating this awesome web server. I came to know about this from the Puppy community. If Barry K introduces something, then I know that it should be something different and really efficient.

The Puppy community has a Hiawatha pet package that installs and runs like a breeze.

I was testing another server setup lately. This is in Ubuntu 9.04 server edition. This has apache running by default and I do a proxy through apache to reach 8080 port that is served by Hiawatha.

On hiawatha, these are some of the things I've used in the config files:
CGIhandler = /usr/bin/php5-cgi:php,php5
VirtualHost {
...
ExecuteCGI = yes
}
FastCGIserver {
FastCGIid = PHP5
ConnectTo = 127.0.0.1:2005
Extension = php
}

I am able to see html files on the server correctly. But, when it comes to PHP, it gives me 503 - Service Unavailable. You can see this here - http://me.prit.us/index.php and http://me.prit.us/index.html.

I am not even sure how to enable or check if Fast CGI is working correctly. Any help is greatly appreciated.
Hugo Leisink
10 July 2009, 21:46
Have you started PHP as a FastCGI daemon? Use the tool php-fcgi to do so. Also, read the HOWTO on this website.
Prit
10 July 2009, 21:56
Thanks for the quick reponse. I ran /usr/local/sbin/php-fcgi -k from the console and get this message
"read /usr/local/var/run/php-fcgi.pid: No such file or directory" (Maybe because pid directory is /var/run, but hiawatha is using /usr/local.
How can I verify if the Fast CGI daemon is correctly started and working?
Hugo Leisink
10 July 2009, 22:12
Why did you use the -k option? That's to kill FastCGI daemons. Please, reread the HOWTO. You can change the location of php-fcgi.pid via php-fcgi.conf.

To check if the PHP FastCGI daemon is running, simply use 'ps'.
Prit
10 July 2009, 22:16
Thanks a lot Hugo. Now my php Hiawatha site works in Ubuntu.

Do I have to add something so that the FastCGI daemon starts automatically when I boot?
Hugo Leisink
10 July 2009, 23:10
If you create a Debian package (see the HOWTO) and install that one, it's all taken care of.
Prit
10 July 2009, 23:13
I could not create a debian package because the make deb was giving some errors. Hence, I did a make install and it is working now. Can I just add the php-fcgi daemon to /etc/init.d?

Do you know how to read the full output of apache benchmark tool? I ran this between the apache and hiawatha installation and you can see the outputs here:
http://me.prit.us/apache.txt
http://me.prit.us/hiawatha.txt
Hugo Leisink
10 July 2009, 23:48
Please, post the errors you recieved during make deb.

For init.d scripts, look in the extra/ directory in the source package.

I don't know much about the 'ab' tool.
Prit
11 July 2009, 00:35
Thanks Hugo. I modified the scripts in extra/ directory to reflect the /usr/local path and installed them in init.d to start automatically.

This is the error I get when doing "make deb" in Ubuntu 9.04.

cp -f ChangeLog debian/changelog
dpkg-buildpackage -rfakeroot
/bin/bash: dpkg-buildpackage: command not found
make: *** [deb] Error 127
Hugo Leisink
11 July 2009, 00:44
If that's the error you get, you haven't read the HOWTO...
Prit
11 July 2009, 01:01
I apologize Hugo. Thanks for helping me out. I have now installed the deb and it is in the default Ubuntu directories as I wanted.

When restarting the php-fcgi, I keep getting:
kill -15 17878: No such process

Any ideas?

Hugo Leisink
11 July 2009, 05:08
Have you defined any FastCGI servers in /etc/hiawatha/php-fcgi.conf?
Prit
11 July 2009, 08:45
Yeah. I have the following lines (uncommented)
PidFile = /var/run/php-fcgi.pid
Server = /usr/bin/php5-cgi ; 127.0.0.1:2005 ; www-data

Also, whenever I restart, I can see that the pid file has the new process id.
Hugo Leisink
11 July 2009, 10:37
Has PHP actually started as a FastCGI daemon? Several php-cgi's should be visible in your process list. That's probably not the case. Likely, you have an error in your php.ini.
Prit
11 July 2009, 10:42
i can see the php-fcgi processes in the process list "ps auxf"
Hugo Leisink
11 July 2009, 10:48
Is the PID of the parent PHP process the same as the number in php-fcgi.pid?
Prit
11 July 2009, 10:57
It is definitely killing the process. I do a "ps auxf" after the php-fcgi stop and there are no processes. So maybe the error message is incorrect.
Hugo Leisink
11 July 2009, 10:58
Oke, I will install Ubuntu 9.04 in VMware and see if I can reproduce the error. Thanks.
Prit
12 July 2009, 08:32
You know what. After I installed Ubuntu 9.04 + Hiawatha 6.15 (using make deb) on a new VM, I don't see this error. Maybe because I had done make install once and then make deb later, something was probably messed up somewhere. Thanks!
Prit
12 July 2009, 10:31
Sorry about the confusion. But, I started getting this "kill -15 15641: No such process" message again.
Hugo Leisink
12 July 2009, 11:38
I've installed Ubuntu in a VM myself, but everything works as it should. Is it possible you give me access to that VM so I can see for myself? (sounds like your VM is just a test VM)
Prit
12 July 2009, 19:24
I sent you the details to get to my VM on your email. Anyway, here is what I found.

This problem comes only when you have multiple servers running. I have two servers setup on my /etc/hiawatha/php-fcgi.conf.
127.0.0.1:2005
127.0.0.1:2006


But, when the /etc/init.d/php-fcgi starts, it creates 3 pid's in the pid file. First 2 are the same and the 3rd one is different. This is why the kill process fails when it tries to kill the 1st one again.

I tried using 1 server and it works great. No error messages. Actually, this is not an issue. Just an extra error message.
Hugo Leisink
13 July 2009, 00:29
The 'multiple servers' was the kind of information I needed. I was able to reproduce the problem. Thanks.
Prit
13 July 2009, 07:17
Thanks a lot Hugo. That file fixed it.
This topic has been closed.