#!/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/ # APTINSTALL="apt-get install -y --no-install-recommends" export DEBIAN_FRONTEND=noninteractive install() { apt-get update # INSTALL ########################################## $APTINSTALL apt-utils $APTINSTALL cron $APTINSTALL apache2 $APTINSTALL php7.0 php7.0-curl php7.0-gd php7.0-fpm php7.0-cli php7.0-opcache php7.0-mbstring php7.0-xml php7.0-zip php7.0-fileinfo php7.0-mcrypt mkdir -p /run/php # Randomize mariaDB password # Suggested by @enoch85 and taken from the nextcloud vm ( https://github.com/nextcloud/vm/blob/master/lib.sh#L46 ) DBPASSWD=$(tr -dc "a-zA-Z0-9@#*=" < /dev/urandom | fold -w "$(shuf -i 30-35 -n 1)" | head -n 1) 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 php7.0-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/7.0/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 ) sed -i '/\[mysqld\]/ainnodb_large_prefix=on' /etc/mysql/mariadb.conf.d/50-server.cnf sed -i '/\[mysqld\]/ainnodb_file_per_table=1' /etc/mysql/mariadb.conf.d/50-server.cnf sed -i '/\[mysqld\]/ainnodb_file_format=barracuda' /etc/mysql/mariadb.conf.d/50-server.cnf # launch mariadb if not already running (for docker build) [[ "$DOCKERBUILD" == 1 ]] && { mysqld & } # wait for mariadb while :; do [[ -S /var/run/mysqld/mysqld.sock ]] && break sleep 0.5 done mysql_secure_installation <