测试环境centos7 ip:192.168.0.50,lighttpd安装于/usr/local/lighttpd目录
开启防火墙

firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload

安装支持组件

yum install -y libev make wget automake gcc gcc-c++ pcre-devel zlib-devel libxml2 sqlite-devel openssl-devel libaio-devel libxml2-devel

创建lighttpd用户组和用户

groupadd -r lighttpd
useradd -g lighttpd -r -M -s /sbin/nologin lighttpd
下载lighttpd,你可以去http://www.lighttpd.net/download/下载最新版本,如果你已经安装了mysql,还应该在编译参数那里加入--with-mysql。

wget --no-check-certificate https://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.55.tar.gz
tar xzf lighttpd-1.4.55.tar.gz
cd lighttpd-1.4.55
./configure --prefix=/usr/local/lighttpd --disable-FEATURE --enable-shared --disable-static --disable-lfs --enable-ipv6 --without-PACKAGE --without-valgrind --without-openssl --without-kerberos5 --without-pcre --without-zlib --without-bzip2 --without-lua --with-pcre --with-sqlite --with-libxml --with-openssl
make
make install

这样就安装完成了
接下来把配置文件复制到/usr/local/lighttpd目录

cp -a doc/config /usr/local/lighttpd
mkdir /home/www
mkdir /usr/local/lighttpd/logs
mkdir /usr/local/lighttpd/cache
chown -R lighttpd:lighttpd /usr/local/lighttpd /home/www
编辑/usr/local/lighttpd/config/lighttpd.conf,修改成以下

var.log_root = "/usr/local/lighttpd/logs"
var.server_root = "/home/www"
var.state_dir = "/var/run"
var.home_dir = "/usr/local/lighttpd/sbin/lighttpd"
var.conf_dir = "/usr/local/lighttpd/config"

如你无IPv6还应该把server.use-ipv6 = "enable"改为"disable",即server.use-ipv6 = " disable "
把include_shell "/usr/share/lighttpd/use-ipv6.pl"注释即:##include_shell "/usr/share/lighttpd/use-ipv6.pl"
把var.cache_dir =后面改成 "/usr/local/lighttpd/cache",即var.cache_dir = "/usr/local/lighttpd/cache"
测试启动

cd /usr/local/lighttpd/sbin/
./lighttpd -f /usr/local/lighttpd/config/lighttpd.conf

成功

加入系统启动

cp /root/lighttpd-*/doc/systemd/lighttpd.service /lib/systemd/system/lighttpd.service

修改启动内容
vi /lib/systemd/system/lighttpd.service
把[Service]段下面修改成

[Service]
Type=simple
PIDFile=/var/run/lighttpd.pid
ExecStartPre=/usr/local/lighttpd/sbin/lighttpd -tt -f /usr/local/lighttpd/config/lighttpd.conf
ExecStart=/usr/local/lighttpd/sbin/lighttpd -D -f /usr/local/lighttpd/config/lighttpd.conf
ExecReload=/bin/kill -USR1 $MAINPID
Restart=on-failure

创建软连

ln -s /lib/systemd/system/lighttpd.service /etc/systemd/system/multi-user.target.wants/lighttpd

载入启动

systemctl daemon-reload

启动 lighttpd

systemctl start lighttpd

停止 lighttpd

systemctl stop lighttpd

加入系统启动

systemctl enable lighttpd
分类: Lighttpd使用方法 标签: 暂无标签

评论

暂无评论数据

暂无评论数据

目录