LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-11-2011, 07:41 AM   #1
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Rep: Reputation: 56
lighttpd - setup virtual hosting question


Hi folks,

host - ubuntu 1010 desktop 64bit
virtualizer - Orcle VirtualBox
VM (guest) - ubuntu 1010 server 64.


Lighttpd is now running on the guest. On host browser evoking ip_address (intranet address) starts the webpage

Then I followed;
Lighttpd virtualhost configuration ~ name-based virtual hosting
How do I configure Lighttpd for name-based virtual hosting?
http://www.cyberciti.biz/faq/howto-l...configuration/

to setup virtual hosting. All steps went through without complaint except the last step:

$ sudo chown -R lighttpd:lighttpd /home/lighttpd/
[sudo] password for satimis:
Code:
chown: invalid user: `lighttpd:lighttpd'
$ sudo chown -R data-www:data-www /home/lighttpd
Code:
chown: invalid user: `data-www:data-www'
Please help. TIA

B.R.
satimis
 
Old 04-11-2011, 08:36 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
Blog Entries: 1

Rep: Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073
Quote:
sudo chown -R data-www:data-www /home/lighttpd
Code:

chown: invalid user: `data-www:data-www'
It should be www-data:www-data not the other way around
 
Old 04-11-2011, 09:13 AM   #3
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by bathory View Post
It should be www-data:www-data not the other way around
Hi,

I see. Sorry I made a mistake. I got it done.

Why lighttpd:lighttpd didn't work?

A further question where shall I keep "index.html" file? TIA

B.R.
satimis
 
Old 04-11-2011, 09:40 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
Blog Entries: 1

Rep: Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073
Quote:
Why lighttpd:lighttpd didn't work?
That is because there is no lighttpd user and group in ubuntu. The default user and group in your distro is www-data for both


Quote:
A further question where shall I keep "index.html" file?
Since you're configuring virtual hosts, there should be an index.html in every virtual host's docroot (i.e. the directory you define with server.document-root=..)
 
Old 04-11-2011, 10:02 AM   #5
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by bathory View Post
- snip -
Since you're configuring virtual hosts, there should be an index.html in every virtual host's docroot (i.e. the directory you define with server.document-root=..)
Thanks. I'll come back to this later.

Now I encounter another problem on connecting the public IP.

On /etc/lighttpd/lighttpd.conf
If
Code:
server.port = 80
server.bind = "local IP"(Intranet)
$ sudo /etc/init.d/lighttpd restart
works without problem


If
Code:
server.port = 80
server.bind = "public IP'

$ sudo /etc/init.d/lighttpd restart
[sudo] password for satimis:
Code:
 * Stopping web server lighttpd                  [ OK ] 
Syntax OK
 * Starting web server lighttpd                                                 2011-04-11 21:42:01: (network.c.345) can't bind to 
port: xxx.xxx.xxx.xxx 80 Cannot assign requested address 
                                              [fail]
ports 80 and 8080 have been forwarded to this VM

$ lsof -i :80
No output.

Any advice. TIA

B.R.
satimis
 
Old 04-11-2011, 12:01 PM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
Blog Entries: 1

Rep: Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073
You cannot make a server listen on an IP that is not present on your system. Public IP is the IP of your router, not your ubuntu box.
So leave the server.bind commented out, or use
Quote:
server.bind = "local IP"
If your forwarding works, then when someone hits xxx.xxx.xxx.xxx:80, he will be forwarded to your lighttpd server

Regards
 
Old 04-11-2011, 12:47 PM   #7
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by bathory View Post
You cannot make a server listen on an IP that is not present on your system. Public IP is the IP of your router, not your ubuntu box.
So leave the server.bind commented out, or use

If your forwarding works, then when someone hits xxx.xxx.xxx.xxx:80, he will be forwarded to your lighttpd server
Changing:
server.bind = "public_IP"

back to:
server.bind = "local_IP"

$ sudo /etc/init.d/lighttpd restart
Code:
 * Stopping web server lighttpd                                          [ OK ] 
Syntax OK
 * Starting web server lighttpd                                          [ OK ]
Now it works. Thanks


$ sudo cp /var/www/index.html /home/lighttpd/satimis.com/http/index.html
$ sudo cp /var/www/index.html /home/lighttpd/default/http/index.html
$ sudo rm /var/www/index.html

On host's browser
Code:
http://public_IP
starts the the first webpage.

However I can't resolve it needs 2 "index.html" files. If deleting /home/lighttpd/default/http/index.html it can't work.

B.R.
satimis

Edit:

I must keep;
/var/www/index.html

Otherwise it can't work. Why it needs 3 identical files

Last edited by satimis; 04-11-2011 at 12:58 PM.
 
Old 04-11-2011, 01:08 PM   #8
dr_agon
Member
 
Registered: Sep 2007
Location: Poland
Distribution: Ubuntu LTS
Posts: 105
Blog Entries: 12

Rep: Reputation: 26
Quote:
Originally Posted by satimis View Post

$ sudo cp /var/www/index.html /home/lighttpd/satimis.com/http/index.html
$ sudo cp /var/www/index.html /home/lighttpd/default/http/index.html
$ sudo rm /var/www/index.html

On host's browser
Code:
http://public_IP
starts the the first webpage.

However I can't resolve it needs 2 "index.html" files. If deleting /home/lighttpd/default/http/index.html it can't work.
Because http://public_IP does not get redirected to satimis.com/http/index.html and falls back to default home page /var/www/index.html. When you reference your server by IP it cannot guess which virtual host you want (normally, you have many virtual hosts on single IP).

You might try http://<some_testing_hostname>.satimis.com if you have DNS set up for your particular configuration.

You can easily set one virtual host as default to get rid of extra index.html files.
 
Old 04-11-2011, 09:46 PM   #9
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Hi dr_agon,

Thanks for your advice.

Quote:
Originally Posted by dr_agon View Post
- snip -
You might try http://<some_testing_hostname>.satimis.com if you have DNS set up for your particular configuration.
I don't run DNS server, using Service-Provider's DNS instead.

Whether you meant subdomain? I'll add them for testing later. What about other domain? e.g.aaa.com, bbb.com etc. Would the steps creating them the same? Thanks.

Quote:
You can easily set one virtual host as default to get rid of extra index.html files.
Could you please explain in detail? Thanks

A side question:
OS - Ubuntu 1010 server edition

lighttpd won't start at boot. I must run
Code:
# etc/init.d/lighttpd start
to evoke it.

Shall I add
Code:
/etc/rc.d/init.d/lighttpd start
on /etc/rc.d/rc.local file? Or there is a lighttpd way?

B.R.
satimis
 
Old 04-12-2011, 03:15 AM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
Blog Entries: 1

Rep: Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073
Quote:
Shall I add
Code:

/etc/rc.d/init.d/lighttpd start

on /etc/rc.d/rc.local file? Or there is a lighttpd way?
The ubuntu way is to run:
Code:
update-rc.d lighttpd defaults
Regards
 
Old 04-12-2011, 08:15 AM   #11
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by bathory View Post
The ubuntu way is to run:
Code:
update-rc.d lighttpd defaults
Regards
Hi,

It didn't work.

$ update-rc.d lighttpd defaults
Code:
System start/stop links for /etc/init.d/lighttpd already exist.
Died at /usr/sbin/update-rc.d line 57.
line 57
Code:
open(FILE, ">", "$archive/${script}.new") || die;
I found similar problem on Internet;
http://forum.lighttpd.net/topic/277

B.R.
satimis
 
Old 04-12-2011, 08:38 AM   #12
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
Blog Entries: 1

Rep: Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073
You should run the update-rc.d script as root, or at least use sudo.
Anyway in your case it's not needed as the symlinks already exist. I guess they were created when you installed the lighttpd package.
Just check if the startup script is executable, because you said that lighttpd is not starting on boot:
Code:
sudo chmod +x /etc/init.d/lighttpd
 
Old 04-12-2011, 12:39 PM   #13
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by bathory View Post
You should run the update-rc.d script as root, or at least use sudo.
Anyway in your case it's not needed as the symlinks already exist. I guess they were created when you installed the lighttpd package.
Just check if the startup script is executable, because you said that lighttpd is not starting on boot:
Code:
sudo chmod +x /etc/init.d/lighttpd
Something strange happens here.

# update-rc.d lighttpd defaults
Code:
 System start/stop links for /etc/init.d/lighttpd already exist.
$ sudo chmod +x /etc/init.d/lighttpd
No printout

$ ls -al /etc/init.d/lighttpd
Code:
-rwxr-xr-x 1 root root 2519 2010-07-16 02:25 /etc/init.d/lighttpd
Rebooted OS. lighttpd can't be started at boot.

sudo nano /etc/rc.locat
adding following line
Code:
/etc/init.d/lighttpd start
Rebooted the OS, still unable to start lighttpd. I must start it manually running
$ sudo /etc/init.d/lighttpd start
Code:
[sudo] password for satimis: 
Syntax OK
 * Starting web server lighttpd                                          [ OK ]
Edit:

$ sudo tail /var/log/lighttpd/error.log
Code:
2011-04-13 00:06:53: (server.c.954) WARNING: unknown config-key: accesslog.filename (ignored) 
2011-04-13 00:17:19: (server.c.1503) server stopped by UID = 0 PID = 1290 
2011-04-13 00:19:20: (log.c.166) server started 
2011-04-13 00:19:20: (server.c.954) WARNING: unknown config-key: accesslog.filename (ignored) 
2011-04-13 00:20:58: (server.c.1503) server stopped by UID = 0 PID = 1235 
2011-04-13 00:22:25: (log.c.166) server started 
2011-04-13 00:22:25: (server.c.954) WARNING: unknown config-key: accesslog.filename (ignored) 
2011-04-13 00:23:17: (server.c.1503) server stopped by UID = 0 PID = 1245 
2011-04-13 00:29:02: (log.c.166) server started 
2011-04-13 00:29:02: (server.c.954) WARNING: unknown config-key: accesslog.filename (ignored)
satimis

Last edited by satimis; 04-12-2011 at 12:52 PM.
 
Old 04-12-2011, 01:53 PM   #14
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
Blog Entries: 1

Rep: Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073Reputation: 2073
I cannot tell what's wrong with the update-rc.d script. Check /var/log/messages to see if you find something relevant.
Other things you can do is:
Remove the symlinks and recreate them:
Code:
update-rc.d -f lighttpd remove
update-rc.d lighttpd defaults
Check if /etc/rc.local is executable and use the following instead of "/etc/init.d/lighttpd start"
Code:
/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf

Quote:
2011-04-13 00:06:53: (server.c.954) WARNING: unknown config-key: accesslog.filename (ignored)
This is also strange. The accesslog.filename option is defined in access_log.conf. What gives:
grep accesslog.filename /etc/lighttpd/lighttpd.conf
 
Old 04-13-2011, 12:23 AM   #15
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Solved

Hi bathory,

$ sudo /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
Code:
2011-04-13 12:04:23: (configfile.c.1210) base-docroot doesn't exist: home/lighttpd/default/http/ 
2011-04-13 12:04:23: (server.c.613) setting default values failed
$ ls /home/lighttpd/default/http/
Code:
index.html
I sorted out the cause. on /etc/lighttpd/lighttpd.conf
leave the server.bind blank without adding any line here.

Now lighttpd starts at boot.

Thanks for your assistance.

B.R.
satimis
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual domain hosting with dns setup cool47 Linux - Networking 5 01-18-2010 02:16 PM
Question About Virtual Hosting scotty5000 Linux - Server 2 08-03-2009 09:24 AM
Virtual Hosting Setup. Markness Linux - Software 13 05-04-2006 03:36 AM
Virtual hosting question idot Linux - Software 4 08-08-2005 03:28 PM
Virtual hosting/ domain question Kovacs Linux - Networking 2 11-23-2004 06:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration