Debian編譯lighttpd-1.4.32

Debian編譯lighttpd-1.4.32

做者:root@\Debian :~#
網站:http://www.52d.mephp

好吧,我想說,
我喜歡root@\Debian:~#這個霸氣的名字,惋惜啊,開源中國不支持超過10字符。mysql

話說,原本想搞個lighttpd+mysql+php輕量Web服務器在本地作一些測試的。
最後按官方的方法編譯安裝,好吧,最後發現跟本就成功不了。
最後排查,發現,利馬坑爹啊。
官方包裏的那個開機腳本 [doc/initscripts/rc.lighttpd] 啊!是那裏來的啊!~sql

好吧,不吐槽了,看個人編譯過程吧。shell

一鍵下載解壓

<!-- lang: shell -->
curl --progress http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.32.tar.gz | tar xz

進入目錄

<!-- lang: shell -->
cd lighttpd-1.4.32

創建用戶組與用戶

<!-- lang: shell -->
groupadd www
useradd -s /sbin/nologin -g www www

查看配置幫助 / 本身擼就須要看一下

<!-- lang: shell -->
# ./configure --help

編譯前配置

<!-- lang: shell -->
./configure  --prefix=/app/lighttpd --disable-ipv6 --with-pcre  --with-zlib  --with-bzip2

編譯

<!-- lang: shell -->
[ "`cat /proc/cpuinfo |grep 'processor'|wc -l`" = "1" ] && make
[ "`cat /proc/cpuinfo |grep 'processor'|wc -l`" != "1" ] && make -j`cat /proc/cpuinfo |grep 'processor'|wc -l`

編譯安裝

<!-- lang: shell -->
make install

設置開機腳本

<!-- lang: shell -->
# Debian一系禁用這一段 / 這是一段錯誤的配置 / 本段來自官方
# 通過屢次測試 / 各類錯誤
# CentOS
# cp doc/initscripts/rc.lighttpd.redhat   /etc/init.d/lighttpd
# Debian
# sed -e 's/FOO/lighttpd/g' doc/initscripts/rc.lighttpd > /etc/init.d/lighttpd
# chmod a+rx /etc/init.d/lighttpd
# 修改BIN文件路徑
# sed -i 's#/usr/sbin/lighttpd#/app/lighttpd/sbin/lighttpd#g' /etc/init.d/lighttpd

創建配置

<!-- lang: shell -->
mkdir -p /app/lighttpd/etc/
cp -R doc/config/conf.d/  doc/config/vhosts.d/ doc/config/*.conf /app/lighttpd/etc/

配置

<!-- lang: shell -->
sed -i 's#server.username  = "lighttpd"#server.username  = "www"#g' /app/lighttpd/etc/lighttpd.conf
sed -i 's#server.groupname = "lighttpd"#server.groupname = "www"#g' /app/lighttpd/etc/lighttpd.conf
sed -i 's#var.server_root = "/srv/www"#var.server_root = "/home/wwwroot"#g' /app/lighttpd/etc/lighttpd.conf
sed -i 's#server_root + "/htdocs"#server_root + "/default"#g' /app/lighttpd/etc/lighttpd.conf
sed -i 's#server.use-ipv6 = "enable"#server.use-ipv6 = "disable"#g' /app/lighttpd/etc/lighttpd.conf

創建目錄

<!-- lang: shell -->
mkdir /var/log/lighttpd
mkdir -p /home/wwwroot/default

創建日誌

<!-- lang: shell -->
touch /var/log/lighttpd/access.log
touch /var/log/lighttpd/error.log

賦權

<!-- lang: shell -->
chown -R www:www /var/log/lighttpd/
chown -R www:www /home/wwwroot
chown -R www:www /home/wwwroot/default

啓動

<!-- lang: shell -->
# 啓動 / 因爲上面開機腳本錯誤 / 沒有配置 / 因此 / 本命令無效
# /etc/init.d/lighttpd start
# 啓動lighttpd
ln -s /app/lighttpd/sbin/lighttpd /usr/local/sbin/lighttpd
/app/lighttpd/sbin/lighttpd -f /app/lighttpd/etc/lighttpd.conf

查看端口

<!-- lang: shell -->
netstat -ntlp

查看程式啓動

<!-- lang: shell -->
ps -A | grep lighttpd

開機啓動

<!-- lang: shell -->
# 因開機腳本錯誤 / 本句失效
# insserv lighttpd
相關文章
相關標籤/搜索