#!/bin/bash # Nextcloud LAMP base installation on Raspbian # # Copyleft 2017 by Ignacio Nunez Hernanz # GPL licensed (see end of file) * Use at your own risk! # # Usage: # # ./installer.sh lamp.sh () # # See installer.sh instructions for details # # Notes: # Upon each necessary restart, the system will cut the SSH session, therefore # it is required to save the state of the installation. See variable $STATE_FILE # It will be necessary to invoke this a number of times for a complete installation # # More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ # PHPVER=7.2 APTINSTALL="apt-get install -y --no-install-recommends" export DEBIAN_FRONTEND=noninteractive install() { # GET PHP 7.2 SOURCES ########################################## local RELEASE=stretch apt-get update $APTINSTALL apt-transport-https gnupg2 wget ca-certificates echo "deb https://packages.sury.org/php/ stretch main" > /etc/apt/sources.list.d/php.list wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add - # INSTALL ########################################## apt-get update $APTINSTALL apt-utils cron curl $APTINSTALL apache2 $APTINSTALL -t $RELEASE php${PHPVER} php${PHPVER}-curl php${PHPVER}-gd php${PHPVER}-fpm php${PHPVER}-cli php${PHPVER}-opcache \ php${PHPVER}-mbstring php${PHPVER}-xml php${PHPVER}-zip php${PHPVER}-fileinfo php${PHPVER}-ldap \ php${PHPVER}-intl php${PHPVER}-bz2 php${PHPVER}-json mkdir -p /run/php # mariaDB password local DBPASSWD="default" echo -e "[client]\npassword=$DBPASSWD" > /root/.my.cnf chmod 600 /root/.my.cnf debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password password $DBPASSWD" debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password_again password $DBPASSWD" $APTINSTALL mariadb-server php${PHPVER}-mysql mkdir -p /run/mysqld chown mysql /run/mysqld # CONFIGURE APACHE ########################################## cat >/etc/apache2/conf-available/http2.conf <> /etc/apache2/apache2.conf < Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" EOF # CONFIGURE PHP7 ########################################## cat > /etc/php/${PHPVER}/mods-available/opcache.ini <> /etc/apache2/apache2.conf # CONFIGURE LAMP FOR NEXTCLOUD ########################################## $APTINSTALL ssl-cert # self signed snakeoil certs # configure MariaDB (UTF8 4 byte support) cat > /etc/mysql/mariadb.conf.d/90-ncp.cnf < /etc/mysql/mariadb.conf.d/91-ncp.cnf </dev/null; then mysqld & fi # wait for mariadb while :; do [[ -S /run/mysqld/mysqld.sock ]] && break sleep 0.5 done cd /tmp mysql_secure_installation <