LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   lighttpd - setup virtual hosting question (https://www.linuxquestions.org/questions/linux-server-73/lighttpd-setup-virtual-hosting-question-874296/)

satimis 04-11-2011 06:41 AM

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

bathory 04-11-2011 07:36 AM

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 ;)

satimis 04-11-2011 08:13 AM

Quote:

Originally Posted by bathory (Post 4320921)
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

bathory 04-11-2011 08:40 AM

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=..)

satimis 04-11-2011 09:02 AM

Quote:

Originally Posted by bathory (Post 4320978)
- 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

bathory 04-11-2011 11:01 AM

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

satimis 04-11-2011 11:47 AM

Quote:

Originally Posted by bathory (Post 4321119)
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

dr_agon 04-11-2011 12:08 PM

Quote:

Originally Posted by satimis (Post 4321161)

$ 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.

satimis 04-11-2011 08:46 PM

Hi dr_agon,

Thanks for your advice.

Quote:

Originally Posted by dr_agon (Post 4321183)
- 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

bathory 04-12-2011 02:15 AM

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

satimis 04-12-2011 07:15 AM

Quote:

Originally Posted by bathory (Post 4321900)
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

bathory 04-12-2011 07:38 AM

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

satimis 04-12-2011 11:39 AM

Quote:

Originally Posted by bathory (Post 4322121)
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

bathory 04-12-2011 12:53 PM

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

satimis 04-12-2011 11:23 PM

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


All times are GMT -5. The time now is 09:35 AM.