# Can't stop/start lighttpd

**URL:** <https://www.ruby-forum.com/t/cant-stop-start-lighttpd/102051>\
**Category:** Rails\
**Created:** [February 7, 2006, 4:40pm UTC](https://www.ruby-forum.com/t/cant-stop-start-lighttpd/102051 "2006-02-07T16:40:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![n1c](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ec8ea/32.png) [@n1c](https://www.ruby-forum.com/u/n1c)\
**Post date:** [February 7, 2006, 4:40pm UTC](https://www.ruby-forum.com/t/cant-stop-start-lighttpd/102051/1 "2006-02-07T16:40:24Z")

</div>

Hello everyone,

Iâ??ve been working with Ruby on Rails for about 2 months now and have  
really enjoyed the ease of use of it. Iâ??m only been doing development  
on it so Iâ??ve been using WeBrick. Recently, I have built a server  
running Debian Linux, with ruby 1.8.2, rails 1.0.0, lighty 1.4.3, and  
Mysql 5.0.18. I used WeBrick to generate a lighttpd.conf file for me, I  
changed the paths in the file to absolute paths. I’m not even sure is  
all is working because I discovered thant when I start lighty then try  
to restart the server, I get an error saying that the port that Iâ??m  
using is already in use. Here is my lighttpd.conf file:

server.port = 80  
server.username = “www-data”  
server.groupname = “www-data”  
server.pid-file = “/var/run/lighttpd.pid”

server.modules = ( “mod\_rewrite”, “mod\_accesslog”,  
“mod\_fastcgi” )  
server.error-handler-404 = “/var/coar/public/dispatch.cgi”  
server.document-root = “/var/coar/public/”

server.errorlog = “/var/log/error.log”  
accesslog.filename = “/var/log/access.log”

url.rewrite = ( “^/$” =\> “index.html”, “^([^.]+)$” =\>  
“$1.html” )

# Change \*-procs to 2 if you need to use Upload Progress or other tasks

that

# _need_ to execute a second request while the first is still pending.

fastcgi.server = ( “.fcgi” =\>  
( “localhost” =\>  
(  
“min-procs” =\> 1,  
“max-procs” =\> 5,  
“socket” =\> “/var/log/fcgi.socket”,  
“bin-path” =\> “/var/coar/public/dispatch.fcgi”,  
“bin-environment” =\> ( “RAILS\_ENV” =\> “development” )  
)  
)  
)

mimetype.assign = (  
“.css” =\> “text/css”,  
“.gif” =\> “image/gif”,  
“.htm” =\> “text/html”,  
“.html” =\> “text/html”,  
“.jpeg” =\> “image/jpeg”,  
“.jpg” =\> “image/jpeg”,  
“.js” =\> “text/javascript”,  
“.png” =\> “image/png”,  
“.swf” =\> “application/x-shockwave-flash”,  
“.txt” =\> “text/plain”  
)

---

<div class="post-metadata">

**Author:** ![n1c](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ec8ea/32.png) [@n1c](https://www.ruby-forum.com/u/n1c)\
**Post date:** [February 7, 2006, 4:46pm UTC](https://www.ruby-forum.com/t/cant-stop-start-lighttpd/102051/2 "2006-02-07T16:46:08Z")

</div>

On 07/02/06, Nick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> when I start lighty then try  
> to restart the server, I get an error saying that the port that I’m  
> using is already in use.

That’s probably port 80. Are you sure you’re shutting it down correctly?

> server.port = 80

–  
Rasputin :: Jack of All Trades - Master of Nuns  
[http://number9.hellooperator.n](http://number9.hellooperator.n)

---

<div class="post-metadata">

**Author:** ![n1c](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ec8ea/32.png) [@n1c](https://www.ruby-forum.com/u/n1c)\
**Post date:** [February 7, 2006, 4:58pm UTC](https://www.ruby-forum.com/t/cant-stop-start-lighttpd/102051/3 "2006-02-07T16:58:42Z")

</div>

> That’s probably port 80. Are you sure you’re shutting it down correctly?

I’m pretty sure, I’m using:

/etc/init.d/lighttpd start/stop/restart/reload/force-reload (not all at  
once 🙂 )

One other thing. when I click on “About your applicationâ??s environment”  
I get a 404 - Not Found instead of the typical “For security purposes,  
this information is only available to local requests.”

Nick

---

<div class="post-metadata">

**Author:** ![n1c](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ec8ea/32.png) [@n1c](https://www.ruby-forum.com/u/n1c)\
**Post date:** [February 7, 2006, 5:45pm UTC](https://www.ruby-forum.com/t/cant-stop-start-lighttpd/102051/4 "2006-02-07T17:45:29Z")

</div>

Nick C. wrote:

> > That’s probably port 80. Are you sure you’re shutting it down correctly?
> 
> I’m pretty sure, I’m using:
> 
> /etc/init.d/lighttpd start/stop/restart/reload/force-reload (not all at  
> once 🙂 )
> 
> One other thing. when I click on “About your applicationâ??s environment”  
> I get a 404 - Not Found instead of the typical “For security purposes,  
> this information is only available to local requests.”

If you’re using firefox 1.5 try clearing all your cache files. I know  
this sounds dumb, but I had a similar problem and it was solved by doing  
that.

Jeroen

---

<div class="post-metadata">

**Author:** ![n1c](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ec8ea/32.png) [@n1c](https://www.ruby-forum.com/u/n1c)\
**Post date:** [February 7, 2006, 7:54pm UTC](https://www.ruby-forum.com/t/cant-stop-start-lighttpd/102051/5 "2006-02-07T19:54:30Z")

</div>

Nick-

```
The /etc/init.d/lighttpd command on debian doesn't seem to shut down

```

the dispacth fcgi processes very well and sometimes not even lighty  
either. I am assuming you installed lighty from a .deb package from  
somewhere. I have a brute force script that will work for you.

```
But before that there are a few issues I see in your conf file here.

```

server.error-handler-404 = “/var/coar/public/dispatch.cgi”  
should be  
server.error-handler-404 = “/dispatch.fcgi”

Also you are spawning 5 fcgi listeners with the min-max procs  
statements. Unless your site is getting around 80,000 hits a day you  
dont need anywhere near that amount of listeners. You should set  
bothe the min-procs and max-procs to either 1 or 2 and make sure they  
are both set to the same number of procs. The dynamic spawning is  
disabled in lighty in all newer versions so the min-procs doesn’t  
really do much. Start with 2 listeners, you will be bale to handle  
quite a bit of traffic with just 2.

```
And here is a script for you that will restart lighty and the

```

dispacthers for you. Put this in a file somehwere like this:  
in: /usr/local/bin/bounce

#!/usr/bin/ruby

lighty = `cat /var/run/lighttpd.pid`.strip  
dis = `ps axww | grep dispatch | grep -v grep | grep /var/coar/public/ dispatch.fcgi`  
dispatchers = dis.split(/\n/).map {|line| line.strip.scan(/\d\*/).first }

puts “\nLighttpd pid: #{lighty}”  
puts ‘=’\*25  
puts “dispatch.fcgi’s pids: #{dispatchers.join(” : “)}”  
if system “kill -9 #{lighty} #{dispatchers.join(’ ')}”  
# make sure to change the follwing line to point to the correct  
# lighttpd.conf file for your app.  
system “/usr/sbin/lighttpd -f /path/to/lighttpd.conf”  
puts “Restarted Lighttpd & Dispatchers…”  
else  
puts “Error occured. Please restart lighty by hand”  
end

```
Now you can restart your lighttpd and fcgi processes by typing:

```

$ bounce

```
Make sure to chmod +x the bounce file after you save it so its

```

executable.

Cheers-  
-Ezra

On Feb 7, 2006, at 7:40 AM, Nick C. wrote:

> to restart the server, I get an error saying that the port that I?m  
> server.document-root = “/var/coar/public/”
> 
> # _need_ to execute a second request while the first is still pending.
> 
> )  
> “.swf” =\> “application/x-shockwave-flash”,

-Ezra Z.  
Yakima Herald-Republic  
WebMaster

> **[yakimaherald.com | Yakima, Washington - We Tell Your Stories](https://www.yakimaherald.com/)**

509-577-7732  
removed\_email\_address@domain.invalid
