[HOWTO] Make lighttpd work with apache custombuild.

chrda

Verified User
Joined
Apr 21, 2007
Messages
23
[HOWTO] Make lighttpd work beside custombuilds apache.

Forum Administrator's Note: Be sure to read the entire thread before using this How-To

This is at your own RISK

Prerequisite:
  • Custombuild with php5-cgi option Link
  • DirectAdmin
You can check this by typing this in your shell: php-cgi -v
You should get this :
Code:
PHP 5.2.4 (cgi-fcgi) (built: Oct  9 2007 00:28:27)
Copyright (c) 1997-2007 The PHP Group
This may not be a perfect solution, but it works very nice for me.
So any suggestion is welcome

Step 1:
1.1 - Decide for what ip you are going to use as shared-ip for lighttpd
1.2 - Make sure its free in the directadmin admins´s ip-managment.
1.3 - Go to Admin´s reseller and then ip-managment. find the lighttpd ip
1.4 - Make the ip shared.

Step 1.2 to 1.4 isnt the way i have done it. It just was logical for me.
Gimme inputs.

Step 2:
Disable Listen 80 in the /etc/httpd/conf/httpd.conf
And add Listen IP1:80, Listen IP2:80 for the ips that use Apache.
The Lighttpd IP must not be here.

Example:
Code:
Listen 82.10.10.10:80
Listen 82.10.10.11:80
Listen 82.10.10.12:80


Step 3: Download and compiling Lighttpd

Code:
cd /usr/local/src
wget [URL]http://www.lighttpd.net/download/lighttpd-1.4.18.tar.gz[/URL]
tar -zxvf lighttpd-1.4.18.tar.gz
cd lighttpd-1.4.18
Code:
./configure --host=i686-redhat-linux-gnu \
--build=i686-redhat-linux-gnu \
--target=i386-redhat-linux \
--program-prefix= --prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--datadir=/usr/share \
--includedir=/usr/include \
--libdir=/usr/lib \
--libexecdir=/usr/libexec \
--localstatedir=/var \
--sharedstatedir=/usr/com \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--with-openssl \
--with-pcre \
--with-zlib \
--with-bzip2 \
--disable-ipv6 \
--with-PACKAGE=mod_redirect \
--with-rewrite \
--with-redirect \
--with-ssi


Step 4: Installing lighttpd

Code:
make
make install
Step 5: Adding the lighttpd service user
Code:
groupadd lighttpd
useradd -g lighttpd -d /var/www/html -s /sbin/nologin lighttpd
Step 6: Creating directories and downloading config files
Code:
mkdir /etc/lighttpd/
mkdir /var/log/lighttpd
chown lighttpd:lighttpd /var/log/lighttpd
cd /etc/lighttpd
wget http://blorp.info/files/conf/lighttpd/lighttpd.conf
chown lighttpd:lighttpd  /etc/lighttpd/lighttpd.conf
mkdir vhosts
cd vhosts
wget http://blorp.info/files/conf/lighttpd/lighttpd.vhost.conf
Locate server.bind = and change it to your "lighttpd shared-ip"

Step 7: Setting up lighttpd as a service
Code:
cd /etc/init.d/
wget http://blorp.info/files/conf/init.d/lighttpd
chmod +x lighttpd
Step 8: Creating log for your "vhost"
Code:
mkdir /var/log/lighttpd/some.net/
chown lighttpd:lighttpd /var/log/lighttpd/some.net/
* This must match the logfolders you set in the domain.vhost.conf

Step 9: Files to check that match your systems setup
/etc/httpd/conf/httpd.conf
/etc/lighttpd.conf
/etc/lighttpd.conf/vhosts/*.vhost.conf
/etc/init.d/lighttpd

I guess i be editing this a little when i see errors, hopefully i get some nice inputs from you guys
 
Last edited:

Rich-Boy

Verified User
Joined
Jan 24, 2006
Messages
223
I followed your tutorial (thanks by the way!) and all is working correctly. However is there any way to enable http://my.domain.com/~username ?

Edit:
Another thing; is there any way for /home/someuser/public_html/ to be readable by both lighttpd and apache?
 
Last edited:

Rich-Boy

Verified User
Joined
Jan 24, 2006
Messages
223
I decided to upgrade to lighttpd 1.5 latest build due to some errors with fcgi connections not closing properly (staying as handle-req for hundreds of seconds) i havn't confirmed 1.5 fixes these errors yet but heres how to upgrade to 1.5 once you've got 1.4 installed and running with fcgi.

First configure and install 1.5 using the same configure script and steps as above then...
nano /etc/lighttpd/lighttpd.conf
Remove mod_fastcgi module and add the following modules;
server.modules = (
[...]
# "mod_fastcgi",
"mod_proxy_core",
"mod_proxy_backend_fastcgi",
[...]
Comment out the whole of the fastcgi.server section which should be about 7-10 lines then add these lines;
$HTTP["url"] =~ "\.php$" {
proxy-core.balancer = "round-robin"
proxy-core.allow-x-sendfile = "enable"
proxy-core.check-local = "enable"
proxy-core.protocol = "fastcgi"
proxy-core.backends = ( "unix:/tmp/php-fastcgi.sock" )
proxy-core.max-pool-size = 16
}
Next swap spawn php using spawn-fcgi, you may need to edit the location of php-cgi;
# /usr/bin/spawn-fcgi -s /tmp/php-fastcgi.sock -f \
/usr/local/php5/bin/php-cgi -u lighttpd -g lighttpd -C 5 -P \
/var/run/spawn-fcgi.pid
Kill all lighttpd and php-cgi processes (use ps -U lighttpd to see these) and finally start lighttpd back up.
lighttpd -f /etc/lighttpd/lighttpd.conf
 
Last edited:

chrda

Verified User
Joined
Apr 21, 2007
Messages
23
Regarding the configs and downloads needed. I was revamping the site
And forgot about those files.. so i am sorry about that.

I will update this when i got the time.
 

joewen7

New member
Joined
Apr 18, 2008
Messages
2
Hi, it it's alright with you, can you share with us what settings you changed/added into your customized lighttpd.conf and lighttpd.vhost.conf?

I've been dying to get this to work.. Thank you very much!
 

chrda

Verified User
Joined
Apr 21, 2007
Messages
23
Sorry i dont got a active directadmin these days, and i made a little mistake so the files are lost.
I will be making something here later. got enough projects running :)
 

umbrucul

New member
Joined
Feb 11, 2010
Messages
4
I am just starting to try this out, but seeing other requests here for the conf files, I am worried about whether I will be able to get this working

can anyone with the knowledge of this stuff give a hint or something about how to solve the conf file situation here?

if not, any other suggestions on getting lighttpd to work alongside apache with directadmin?
 

umbrucul

New member
Joined
Feb 11, 2010
Messages
4
anybody help please?

where can I find something to use for these "conf" files that are 404ing in the original post in this thread?

"cd /etc/lighttpd
wget http://blorp.info/files/conf/lighttpd/lighttpd.conf
chown lighttpd:lighttpd /etc/lighttpd/lighttpd.conf
mkdir vhosts
cd vhosts
wget http://blorp.info/files/conf/lighttpd/lighttpd.vhost.conf"


need something that might work here for lighttpd.conf and lighttpd.vhost.conf


thanks for any hints
 

duke28

Verified User
Joined
Oct 30, 2005
Messages
303
Location
Montreal - Canada
do you have another link http for download lighttpd.conf and lighttpd.vhost.conf for directadmin please ???

error 404 when we try to download this..
 

HipHopServers

Verified User
Joined
May 17, 2010
Messages
12
That script requires a config file at /etc/sysconfig/lighttpd. Here’s one I found at www.coderseye.com:

Code:
LIGHTTPD_CONF_PATH=/etc/lighttpd/lighttpd.conf
LIGHTTPD_PID_FILE=/var/run/lighttpd.pid
LIGHTTPD_BIN=/usr/local/sbin/lighttpd
Hope this helps everyone out
 

HipHopServers

Verified User
Joined
May 17, 2010
Messages
12
How to Make a Config file

Here some information I found from google searches. The info is posted on r0xarena.

Next thing to do is to configure lighttpd.

To configure lighttpd, create a directory to store the lighttpd.conf file.
A good location would be in /etc/lighttpd, and we need to create it:
Code:
[root@localhost /]# mkdir /etc/lighttpd
Copy the default lighttpd.conf to the /etc/lighttpd folder
Code:
[root@localhost lighttpd]# cp /usr/src/lighttpd/lighttpd-1.4.xx/doc/lighttpd.conf /etc/lighttpd/
The location for lighttpd.conf is correct if you follow the steps from the tutorial. If not, you have to find for the lighttpd.conf file.

To find for the file use the find command, (| more is to pause the page if there’s a lot of results):
Code:
[root@localhost /]# find / | grep lighttpd.conf | more
Now it’s time to edit the lighttpd.conf before we can start lighttpd:
Code:
[root@localhost r0xarena]# vi /etc/lighttpd/lighttpd.conf
Things to change:

In server.modules = (
Uncomment:
Code:
                               “mod_fastcgi”,
                               “mod_compress”,
Disable mod_access by commenting it:
Code:
#                               “mod_access”,
set the static document-root, in this example I use /home/r0xarena/www:
Code:
server.document-root        = “/home/r0xarena/www”
set the lighttpd server error log path:
Code:
server.errorlog             = “/home/r0xarena/www/logs/lighttpd.log”
Set the server port to run lighttpd, If you are running apache on same shared IP then 81 was chosen so that it won’t conflict with the apache which will be running on port 80:
Code:
## bind to port (default: 80)
server.port                = 81
Set the IP address to bind to, if you have a public ip address, you can bind it to the public ip address:
Code:
## bind to localhost (default: all interfaces)
server.bind                = “192.168.1.1″
 

HipHopServers

Verified User
Joined
May 17, 2010
Messages
12
make vhost.config

Here is some info on make a vhost.conf file for on cyberciti.biz

Create required directories:
Code:
# mkdir -p /home/lighttpd/domain1.com/http
# mkdir -p /home/lighttpd/domain1.com/logs
Open /etc/lighttpd/domain1.com.conf file:
Code:
# vi /etc/lighttpd/domain1.com.conf
Add following configuration directive:

Code:
$HTTP["host"] =~ "domain1\.com" {server.document-root = "/home/lighttpd/domain1.com/http"
            accesslog.filename         = "/home/lighttpd/domain1.com/logs/access.log"
}
Save and close the file.
 

HipHopServers

Verified User
Joined
May 17, 2010
Messages
12
Missing /etc/init.d/lighttpd

You have to fix this code to load the file mention for the location of the doc directory of your decompess copy of the code.

Code:
cp doc/rc.lighttpd /etc/init.d/lighttpd
 

chrda

Verified User
Joined
Apr 21, 2007
Messages
23
Files gone..

I recommend Litespeed webserver if you have problems with load due apache.

Works out of the box with directadmin
 
Top