Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of setting VirtualHosts in Lighttpd Server

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

How to set VirtualHosts in Lighttpd Server? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

VirtualHosting is an implementation that hosts multiple domains on a single server. It can take advantage of the maximum resources of the server and reduce consumption. Now, most Web servers support virtual host environments.

In our previous article, we introduced installing a Lighttpd server on CentOS / RHEL. This article will introduce you to setting up VirtualHosts in a Lighttpd server.

For example, we use the following domain name:

Site1.php.cn

Site2.php.cn

Step 1: create the server document root directory

First create a folder for the two domains (if they do not exist)

# mkdir-p / sites/vhosts/site1.php.cn/www# mkdir-p / sites/vhosts/site2.php.cn/www

For testing purposes, we created the index.html file in two document root directories

# echo "Welcome to Site1" > / sites/vhosts/site1.php.cn/www/index.html# echo "Welcome to Site2" > / sites/vhosts/site2.php.cn/www/index.html

Step 2: update the main profile

Now edit the Lighttpd main configuration file / etc/lighttpd/lighttpd.conf and enable the file that contains the virtual host. Uncomment the following line by removing the starting # symbol.

Include_shell "cat / etc/lighttpd/vhosts.d/*.conf"

Step 3: create a VirtualHost profile

Now start creating virutalhost profiles for two domains or subdomains, first for site1.php.cn

# vim / etc/lighttpd/vhosts.d/site1.php.cn.conf$HTTP ["host"] = = "site1.php.cn" {server.document-root = "/ sites/vhosts/site1.php.cn/public" server.errorlog = "/ var/log/lighttpd/site1.php.cn.error.log" accesslog.filename = "/ var/log/lighttpd/site1.php.cn.access.log"}

Now create a configuration file for site2.php.cn

# vim / etc/lighttpd/vhosts.d/site2.php.cn.conf$HTTP ["host"] = = "site2.php.cn" {server.document-root = "/ sites/vhosts/site2.php.cn/public" server.errorlog = "/ var/log/lighttpd/site2.php.cn.error.log" accesslog.filename = "/ var/log/lighttpd/site2.php.cn.access.log"}

Step 4: verify the configuration and restart lighttpd

First verify the syntax of all configuration files, including the main configuration file

# lighttpd-t-f / etc/lighttpd/lighttpd.confSyntax OK

If you find that all the syntax is normal, let's restart the service.

# service lighttpd restart

When you are done, test your two fields in the browser and check to see if you have obtained the correct content on the page created in step 1.

Thank you for reading! After reading the above, do you have a general idea of how to set up VirtualHosts in Lighttpd Server? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report