Running and Verifying Lighttpd
- Modify the lighttpd.conf file.
- Open the file.
1vi /usr/local/lighttpd/config/lighttpd.conf - Modify the following content.
- Modify lines 16 to 20 as follows:
var.log_root = "/usr/local/lighttpd/log" var.server_root = "/usr/local/lighttpd" var.state_dir = "/usr/local/lighttpd" var.home_dir = "/usr/local/lighttpd" var.conf_dir = "/usr/local/lighttpd/config"

- Modify line 61 as follows:
var.cache_dir = "/usr/local/lighttpd/cache"

- Comment out line 93.
#server.use-ipv6 = "enable"

- Modify lines 104 and 105 as follows:
server.username = "lighttpd1" server.groupname = "lighttpd"

This parameter indicates the operation permission. The root user is not recommended.
- Modify line 115 (path for storing the access page) as follows:
server.document-root = server_root + "/webpages"

- Modify line 246 (cache mode) as follows: (The default value is simple. According to the official explanation, fam is better than simple.)
server.stat-cache-engine = "fam"

- Add the following content to line 182. (This configuration item is used to configure the multi-process mode. The lighttpd process is a single process by default. You can change the value based on the site requirements.)
server.max-worker = 4

- Modify lines 16 to 20 as follows:
- Save the settings and exit.
Press Esc to exit the edit mode and run :wq to save the file.
- Open the file.
- Create a lighttpd user and a lighttpd user group.
- Create the group:
1groupadd lighttpd - Create the user:
1useradd -g lighttpd lighttpd1
- Create the group:
- Change the ownership of the directory.
1chown lighttpd1 /usr/local/lighttpd/log
- Compile a test web page in the /usr/local/lighttpd/webpages directory.
1cd /usr/local/lighttpd/webpages
- Create an HTML file.
1vi index.html - Add the following content and save the file:
<html> <head> <title>lighttpd test</title> </head> <body> <p>this is a testing</p> </body> </html>
- Create an HTML file.
- Start Lighttpd.
1/usr/local/lighttpd/sbin/lighttpd -f /usr/local/lighttpd/config/lighttpd.conf
- Check the Lighttpd process.
1ps -ef | grep lighttpd

- Verify Lighttpd.
Open the browser and enter http://IP address:80/index.html in the address box. If "this is a testing page" is displayed, the test is successful.
- Run the following command to stop Lighttpd:
1pkill lighttpd- View the logs:
1 2
vi /usr/local/lighttpd/log/error.log vi /usr/local/lighttpd/log/access.log
- View the listening port:
1netstat -anpt | grep 80
Parent topic: Lighttpd Porting Guide