一、安装epel仓库

yum install epel-release

二、安装lightttd

Centos系统下

yum update
yum install lighttpd

如果是Ubuntu

apt-get update
apt-get install lighttpd

源码安装先网上下载对应的源码包,如下载1.4.39版本

# cd /tmp/
# wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.39.tar.gz

解压

tar -zxvf lighttpd-1.4.39.tar.gz

编译安装

# cd lighttpd-1.4.39
# ./configure
# make
# make install

三、lighttpd配置文件

默认yum安装,配置文件的位置在/etc/lighttpd/lighttpd.conf
对配置文件相关参数进行了修改,可以使用如下语法进行检查

lighttpd -t -f /etc/lighttpd/lighttpd.conf

启动lighttpd服务

systemctl start lighttpd

关闭lighttpd服务

systemctl stop lighttpd

设置开机自启动(enable) 禁用(disable)

systemctl enable lighttpd

默认的欢迎页index.html

[root@localhost lighttpd]# pwd
/var/www/lighttpd
[root@localhost lighttpd]# ls
favicon.ico  index.html  light_button.png  light_logo.png  poweredby.png

由于我虚拟机上80端口被占用了,所以我修改了lighttpd.conf的端口配置

server.port = 8077

启动lightttpd服务之后,使用ip加端口并不能访问,在linux访问本机curl localhost:8077却可以访问,原因是绑定主机为设置:

server.bind="192.168.86.134"

如果依然不能访问,则应该是防火墙的问题。

# firewall-cmd --permanent --add-service=http
success
# firewall-cmd --reload
success

访问lighttpd的欢迎页如下:
linux下安装lighttpd web服务器_Linux