● lighttpd.service - Lighttpd Daemon
Loaded: loaded (/lib/systemd/system/lighttpd.service; enabled; vendor preset:
Active: active (running) since Sun 2018-12-30 10:10:00 JST; 8min ago
Main PID: 2250 (lighttpd)
CGroup: /system.slice/lighttpd.service
mq2250 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
Dec 30 10:10:00 rcpm-r51 systemd[1]: Starting Lighttpd Daemon...
Dec 30 10:10:00 rcpm-r51 systemd[1]: Started Lighttpd Daemon.
ls -al /var/www
drwxr-xr-x 2 root root 4096 Jan 15 2017 cgi-bin
drwxr-xr-x 2 root root 4096 Dec 30 10:09 html
ブラウザーにアクセスしても、、、
という事で、標準インストールは、OK
(2) 最新版のビルド
最初にbuildに必要なモジュールのインストール
sudo apt-get install libpcre3-dev bzip2 libbz2-dev
https://www.lighttpd.net/ からダウンロード。因みに1.4.52でした。
展開し、ディレクトリーに入って
./configure
make
sudo make install
sudo systemctl restart lighttpd
念の為に、、、、え???
$ lighttpd -v
lighttpd/1.4.45 (ssl) - a light and fast webserver
Build-Date: Jan 14 2017 21:07:19
$ cat /lib/systemd/system/lighttpd.service
[Unit]
Description=Lighttpd Daemon
After=network.target
[Service]
Type=simple
ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf
ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
make install でインストールされる場所は、
/usr/local/sbin
buildした定義は
[Unit]
Description=Lighttpd Daemon
After=network-online.target
[Service]
Type=simple
PIDFile=/var/run/lighttpd.pid
ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf
ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
ExecReload=/bin/kill -USR1 $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
という事で、最初のlighttpd.serviceを使うとして
/usr/sbinを/usr/local/sbinに変更
$ sudo systemctl daemon-reload
$ sudo systemctl restart lighttpd
$ lighttpd -v
lighttpd/1.4.45 (ssl) - a light and fast webserver
Build-Date: Jan 14 2017 21:07:19
???
$ /usr/local/sbin/lighttpd -v
lighttpd/1.4.52 - a light and fast webserver
意味不明なので、、、
残骸を消して
$ sudo rm r- /usr/lib/lighttpd
$ sudo reboot
$ lighttpd -v
lighttpd/1.4.52 - a light and fast webserver
本当に意味不明、、、、、でも時間が無いのでよし!
(3) 環境設定
/etc/lighttpd/lighttpd.conf
これはそのまま、、、
$ cd /etc/lighttpd/conf-available
$ vi 10-cgi.conf
$ cat 10-cgi.conf
# /usr/share/doc/lighttpd/cgi.txt
server.modules += ( "mod_cgi" )
$HTTP["url"] =~ "^/cgi-bin/" {
cgi.assign = ( "" => "" )
}
$HTTP["url"] =~ "^/api/" {
cgi.assign = ( "" => "" )
}
## Warning this represents a security risk, as it allow to execute any file
## with a .pl/.py even outside of /usr/lib/cgi-bin.
#
#cgi.assign = (
# ".pl" => "/usr/bin/perl",
# ".py" => "/usr/bin/python",
#)
$ cd ../conf-enabled
$ sudo ln -s ../conf-available/10-cgi.conf
$ ls -al
10-cgi.conf -> ../conf-available/10-cgi.conf
$ sudo mkdir /var/www/api
・エラーが起こった
さぁこれで! アドレスにアクセスするとエラー
動いていない
$ systemctl status lighttpd
Dec 30 13:57:21 rcpm-r51 systemd[1]: Starting Lighttpd Daemon...
Dec 30 13:57:21 rcpm-r51 systemd[1]: Started Lighttpd Daemon.
Dec 30 13:57:21 rcpm-r51 lighttpd[863]: 2018-12-30 13:57:21: (server.c.748) opening errorlog '/var/log/lighttpd/error.log' failed: No such file or directory
Dec 30 13:57:21 rcpm-r51 lighttpd[863]: 2018-12-30 13:57:21: (server.c.1454) Opening errorlog failed. Going down.
Dec 30 13:57:21 rcpm-r51 systemd[1]: lighttpd.service: Main process exited, code=exited, status=255/n/a
Dec 30 13:57:21 rcpm-r51 systemd[1]: lighttpd.service: Unit entered failed state.
Dec 30 13:57:21 rcpm-r51 systemd[1]: lighttpd.service: Failed with result 'exit-code'.
Dec 30 13:57:21 rcpm-r51 systemd[1]: lighttpd.service: Service hold-off time over, scheduling restart.
Dec 30 13:57:21 rcpm-r51 systemd[1]: Stopped Lighttpd Daemon.
つまり、/var/log/lighttpd/error.log が無い
$ sudo mkdir /var/log/lighttpd
$ sudo chown www-data:www-data /var/log/lighttpd
$ sudo chmod 750 /var/log/lighttpd
でも、なんでかなぁ、、、
$ sudo systemctl restart lighttpd
$ sudo systemctl status lighttpd
$ systemctl status lighttpd
● lighttpd.service - Lighttpd Daemon
Loaded: loaded (/lib/systemd/system/lighttpd.service; enabled; vendor preset:
Active: active (running) since Sun 2018-12-30 14:15:08 JST; 9min ago
Process: 1343 ExecStartPre=/usr/local/sbin/lighttpd -tt -f /etc/lighttpd/light
Main PID: 1351 (lighttpd)
CGroup: /system.slice/lighttpd.service
mq1351 /usr/local/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
Dec 30 14:15:08 rcpm-r51 systemd[1]: Starting Lighttpd Daemon...
Dec 30 14:15:08 rcpm-r51 systemd[1]: Started Lighttpd Daemon.
Peace!!