ヒアドキュメントのエスケープシーケンスは'\'でした。
lighttpd 最新版のチェックはしてください。
URLは、こちら
Peace!!
#!/bin/bash
HOME=/home/pi
VER=1.4.54
if [ -e $HOME/tmp ]; then
cd $HOME/tmp
else
mkdir $HOME/tmp
cd $HOME/tmp
fi
##########################
# 1. build lighttpd
##########################
wget https://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-$VER.tar.gz
tar xvf lighttpd-$VER.tar.gz
cd lighttpd-$VER
sudo apt-get -y install libpcre3-dev bzip2 libbz2-dev
./configure
make
sudo make install
sudo ldconfig
##########################
# 2. setup config
##########################
sed -i -e "s/srv/var/g" doc/config/lighttpd.conf
sed -i -e "s/server.use-ipv6/\#server.use-ipv6/g" doc/config/lighttpd.conf
sed -i -e "s/server.username = \"lighttpd\"/server.username = \"www-data\"/g" doc/config/lighttpd.conf
sed -i -e "s/server.groupname = \"lighttpd\"/server.groupname = \"www-data\"/g" doc/config/lighttpd.conf
sed -i -e "s/server_root + \"\/htdocs\"/server_root/g" doc/config/lighttpd.conf
sed -i -e "s:\#include \"conf.d/cgi:include \"conf.d/cgi:g" doc/config/modules.conf
sudo mkdir /etc/lighttpd
sudo cp doc/config/lighttpd.conf /etc/lighttpd
sudo cp doc/config/modules.conf /etc/lighttpd
sudo cp -r doc/config/conf.d /etc/lighttpd
sudo mv /etc/lighttpd/conf.d/cgi.conf /etc/lighttpd/conf.d/cgi.conf.org
cat << EOF > /tmp/cgi.conf
#######################################################################
##
## CGI modules
## ---------------
##
## See https://redmine.lighttpd.net/projects/lighttpd/wiki/docs_modcgi
##
server.modules += ( "mod_cgi" )
##
## Plain old CGI handling
##
## For PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini.
##
#cgi.assign = ( ".pl" => "/usr/bin/perl",
# ".cgi" => "/usr/bin/perl",
# ".rb" => "/usr/bin/ruby",
# ".erb" => "/usr/bin/eruby",
# ".py" => "/usr/bin/python" )
#
##
## to get the old cgi-bin behavior of apache
##
## Note: make sure that mod_alias is loaded if you uncomment the
## next line. (see modules.conf)
##
#alias.url += ( "/cgi-bin" => server_root + "/cgi-bin" )
alias.url += ( "/api" => server_root + "/api" )
\$HTTP["url"] =~ "^/api" {
cgi.assign = ( "" => "" )
}
############################
############################
EOF
sudo cp /tmp/cgi.conf /etc/lighttpd/conf.d
##########################
# 3. setup systemd
##########################
sudo mkdir /var/log/lighttpd
sudo chown www-data:www-data /var/log/lighttpd
cp doc/systemd/lighttpd.service doc/systemd/lighttpd.org
sed -i -e "s/sbin/local\/sbin/g" doc/systemd/lighttpd.service
sudo cp doc/systemd/lighttpd.service /lib/systemd/system
sudo systemctl enable lighttpd.service
sleep 1
sudo systemctl start lighttpd.service
##########################
# 3. test lighttpd
##########################
sudo mkdir /var/www
sudo mkdir /var/www/api
cat << EOF > index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>lighttpd alive</title>
</head>
<body>
<p>lighttpd server success.</p>
</body>
</html>
EOF
sudo cat << EOF > tst.c
#include <stdio.h>
void main(){
printf("Content-type: text/plain\n\n");
printf("Hello, World!");
return;
}
EOF
gcc tst.c -o tst
sudo mv index.html /var/www
sudo mv tst.c /var/www/api
sudo mv tst /var/www/api
sudo chown -R www-data:www-data /var/www
exit 0
0 件のコメント:
コメントを投稿