---
title: 运行和验证
description: "1. 修改lighttpd.conf文件。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengwebs/ecosystemEnable/Lighttpd/kunpenglighttpd_02_0013.html
sourcePath: /source/zh/kunpengwebs/ecosystemEnable/Lighttpd/kunpenglighttpd_02_0013.html
indexId: 1f12d5a243c295284246345998453ee736c7b015d98902803a4bc26891c5c2f776
---
# 运行和验证

1. 修改lighttpd.conf文件。

  a. 打开文件。
    1 vi /usr/local/lighttpd/config/lighttpd.conf

  b. 修改如下内容。

    - 修改第16-20行为：
      1 2 3 4 5 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"

    - 修改第61行为：
      1 var.cache_dir = "/usr/local/lighttpd/cache"

    - 注释掉第93行：
      1 #server.use-ipv6 = "enable"

    - 修改第104-105行为：
      1 2 server.username = "lighttpd1" server.groupname = "lighttpd"

      该项为操作权限，不建议使用root。

    - 修改第115行（访问页面存放路径）为：
      1 server.document-root = server_root + "/webpages"

    - 修改第246行（缓存模式，默认为simple，官方解释fam要优于simple）为：
      1 server.stat-cache-engine = "fam"

    - 在第182行添加如下内容（该项为配置多进程模式，Lighttpd默认单进程，数值可根据实际需求修改） ：
      1 server.max-worker = 4

  c. 退出并保存。
    Esc退出编辑模式，:wq保存文件。

2. 创建用户及组Lighttpd。

  - 创建组：
    1 groupadd lighttpd

  - 创建用户：
    1 useradd -g lighttpd lighttpd1

3. 修改文件夹的所有权。
  1 chown lighttpd1 /usr/local/lighttpd/log

4. 在“/usr/local/lighttpd/webpages”目录下编写测试网页。
```
cd /usr/local/lighttpd/webpages
```


  a. 新建html文件。
    1 vim index.html

  b. 按“i”进入编辑模式，添加以下内容并保存。
    1 2 3 4 5 6 7 8 <html> <head> <title>lighttpd test</title> </head> <body> <p>this is a testing</p> </body> </html>

  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
5. 启动Lighttpd。
  1 /usr/local/lighttpd/sbin/lighttpd -f /usr/local/lighttpd/config/lighttpd.conf

6. 查看Lighttpd进程。
  1 ps -ef | grep lighttpd

7. 验证Lighttpd。
  打开浏览器在url处输入：http://IP:80/index.html，可以看到index.html的页面“this is a testing”，则说明运行成功。

  停止Lighttpd命令如下，业务运行中不需要执行该命令。 1 pkill lighttpd 查看日志。 1 2 vi /usr/local/lighttpd/log/error.log vi /usr/local/lighttpd/log/access.log 查看侦听端口。 1 netstat -anpt | grep 80
