Rate This Document
Findability
Accuracy
Completeness
Readability

Running and Verifying Lighttpd

  1. Modify the lighttpd.conf file.
    1. Open the file.
      1
      vi /usr/local/lighttpd/config/lighttpd.conf
      
    2. 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

    3. Save the settings and exit.

      Press Esc to exit the edit mode and run :wq to save the file.

  2. Create a lighttpd user and a lighttpd user group.
    • Create the group:
      1
      groupadd  lighttpd
      
    • Create the user:
      1
      useradd -g lighttpd  lighttpd1
      
  3. Change the ownership of the directory.
    1
    chown lighttpd1  /usr/local/lighttpd/log
    
  4. Compile a test web page in the /usr/local/lighttpd/webpages directory.
    1
    cd /usr/local/lighttpd/webpages
    
    1. Create an HTML file.
      1
      vi index.html
      
    2. Add the following content and save the file:
      <html>
      <head>
      <title>lighttpd test</title>
      </head>
      <body>
      <p>this is  a testing</p>
      </body>
      </html>
  5. Start Lighttpd.
    1
    /usr/local/lighttpd/sbin/lighttpd -f /usr/local/lighttpd/config/lighttpd.conf
    
  6. Check the Lighttpd process.
    1
    ps -ef | grep lighttpd
    

  7. 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:
    1
    pkill lighttpd
    
    • View the logs:
    1
    2
    vi /usr/local/lighttpd/log/error.log
    vi /usr/local/lighttpd/log/access.log
    
    • View the listening port:
    1
    netstat -anpt | grep 80