2013-09-01 14:24:49 +00:00
|
|
|
# HTTP: Turn on a web server serving static files
|
|
|
|
#################################################
|
|
|
|
|
2014-06-03 11:12:38 +00:00
|
|
|
source setup/functions.sh # load our functions
|
2014-05-01 19:13:00 +00:00
|
|
|
|
|
|
|
apt_install nginx php5-cgi
|
2013-09-01 14:24:49 +00:00
|
|
|
|
2013-09-07 20:53:25 +00:00
|
|
|
rm -f /etc/nginx/sites-enabled/default
|
|
|
|
|
|
|
|
STORAGE_ROOT_ESC=$(echo $STORAGE_ROOT|sed 's/[\\\/&]/\\&/g')
|
|
|
|
PUBLIC_HOSTNAME_ESC=$(echo $PUBLIC_HOSTNAME|sed 's/[\\\/&]/\\&/g')
|
2013-09-01 14:24:49 +00:00
|
|
|
|
2013-09-08 09:55:58 +00:00
|
|
|
# copy in the nginx configuration file and substitute some
|
|
|
|
# variables
|
2013-09-01 14:24:49 +00:00
|
|
|
cat conf/nginx.conf \
|
2013-09-07 20:53:25 +00:00
|
|
|
| sed "s/\$STORAGE_ROOT/$STORAGE_ROOT_ESC/g" \
|
|
|
|
| sed "s/\$PUBLIC_HOSTNAME/$PUBLIC_HOSTNAME_ESC/g" \
|
|
|
|
> /etc/nginx/conf.d/local.conf
|
2014-04-18 00:27:52 +00:00
|
|
|
cp conf/nginx-ssl.conf /etc/nginx/nginx-ssl.conf
|
2013-09-07 20:53:25 +00:00
|
|
|
|
2013-09-08 09:55:58 +00:00
|
|
|
# make a default homepage
|
2013-09-07 20:53:25 +00:00
|
|
|
mkdir -p $STORAGE_ROOT/www/static
|
2013-09-08 09:55:58 +00:00
|
|
|
cp conf/www_default.html $STORAGE_ROOT/www/static/index.html
|
|
|
|
chown -R $STORAGE_USER $STORAGE_ROOT/www/static/index.html
|
2013-09-07 20:53:25 +00:00
|
|
|
|
2014-03-17 01:46:47 +00:00
|
|
|
# Create an init script to start the PHP FastCGI daemon and keep it
|
|
|
|
# running after a reboot. Allows us to serve Roundcube for webmail.
|
|
|
|
rm -f /etc/init.d/php-fastcgi
|
|
|
|
ln -s $(pwd)/conf/phpfcgi-initscript /etc/init.d/php-fastcgi
|
|
|
|
update-rc.d php-fastcgi defaults
|
2013-09-01 14:24:49 +00:00
|
|
|
|
2014-03-17 01:46:47 +00:00
|
|
|
# Start services.
|
|
|
|
service nginx restart
|
|
|
|
service php-fastcgi restart
|
2013-09-01 14:24:49 +00:00
|
|
|
|
2014-03-17 01:46:47 +00:00
|
|
|
# Open ports.
|
2014-05-01 19:35:18 +00:00
|
|
|
ufw_allow http
|
|
|
|
ufw_allow https
|
2013-09-01 14:24:49 +00:00
|
|
|
|