web.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # HTTP: Turn on a web server serving static files
  2. #################################################
  3. apt-get remove -q -y apache2
  4. apt-get install -q -y nginx php5-cgi
  5. rm -f /etc/nginx/sites-enabled/default
  6. STORAGE_ROOT_ESC=$(echo $STORAGE_ROOT|sed 's/[\\\/&]/\\&/g')
  7. PUBLIC_HOSTNAME_ESC=$(echo $PUBLIC_HOSTNAME|sed 's/[\\\/&]/\\&/g')
  8. # copy in the nginx configuration file and substitute some
  9. # variables
  10. cat conf/nginx.conf \
  11. | sed "s/\$STORAGE_ROOT/$STORAGE_ROOT_ESC/g" \
  12. | sed "s/\$PUBLIC_HOSTNAME/$PUBLIC_HOSTNAME_ESC/g" \
  13. > /etc/nginx/conf.d/local.conf
  14. cp conf/nginx-ssl.conf /etc/nginx/nginx-ssl.conf
  15. # make a default homepage
  16. mkdir -p $STORAGE_ROOT/www/static
  17. cp conf/www_default.html $STORAGE_ROOT/www/static/index.html
  18. chown -R $STORAGE_USER $STORAGE_ROOT/www/static/index.html
  19. # Create an init script to start the PHP FastCGI daemon and keep it
  20. # running after a reboot. Allows us to serve Roundcube for webmail.
  21. rm -f /etc/init.d/php-fastcgi
  22. ln -s $(pwd)/conf/phpfcgi-initscript /etc/init.d/php-fastcgi
  23. update-rc.d php-fastcgi defaults
  24. # Start services.
  25. service nginx restart
  26. service php-fastcgi restart
  27. # Open ports.
  28. ufw allow http
  29. ufw allow https