Skip to content

Instantly share code, notes, and snippets.

@lspg
Last active December 21, 2015 15:08
Show Gist options
  • Select an option

  • Save lspg/643f8b10ce4c0c5a3b27 to your computer and use it in GitHub Desktop.

Select an option

Save lspg/643f8b10ce4c0c5a3b27 to your computer and use it in GitHub Desktop.
Install ownCloud 8.2 on Debian 8 Jessie (Apache2 + PHP 7 + Redis)
#!/bin/bash
setHostname() {
HOST=`hostname -f` && echo $HOST > /etc/hostname && /etc/init.d/hostname.sh start
}
export DEBIAN_FRONTEND=noninteractive
UH=$USER
if [ $USER != 'root' ]; then
UH="/home/"$USER
fi
cat <<EOF > /home/vagrant/.aliases
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ll='ls -CF'
alias l='ls -lA'
EOF
sed -i 's/# en_US.UTF-8/en_US.UTF-8/g' /etc/locale.gen
sed -i 's/# fr_FR.UTF-8/fr_FR.UTF-8/g' /etc/locale.gen
locale-gen && dpkg-reconfigure locales tzdata
# DotDeb repo
wget https://www.dotdeb.org/dotdeb.gpg
apt-key add dotdeb.gpg
echo "deb http://packages.dotdeb.org jessie all" > /etc/apt/sources.list.d/dotdeb.list
echo "deb-src http://packages.dotdeb.org jessie all" >> /etc/apt/sources.list.d/dotdeb.list
setHostname
apt-get update
apt-get -y -q upgrade
apt-get -y -q dist-upgrade
# Tools
apt-get -y -q install cron curl ssl-cert unzip git dialog screenfetch
# MariaDb
echo "mysql-server-5.5 mysql-server/root_password password root" | debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password_again password root" | debconf-set-selections
apt-get install -y -q mariadb-server
sed -i 's/bind-address/#bind-address/g' /etc/mysql/my.cnf
sed -i "s/skip-external-locking/skip-external-locking\nskip-innodb\ndefault-storage-engine = myisam\nlog_slow_queries = \/var\/log\/mysql\/mysql-slow.log\nlong_query_time = 1\nlog-bin = \/var\/log\/mysql\/mysql-bin.log\nsync_binlog = 1/g" /etc/mysql/my.cnf
/etc/init.d/mysql restart
# phpMyAdmin
apt-get install -y -q phpmyadmin
# PHP 7
apt-get install -y -q libapache2-mod-php7.0 libphp7.0-embed php7.0 php7.0-cgi php7.0-cli php7.0-common php7.0-curl php7.0-dbg php7.0-dev php7.0-fpm php7.0-gd php7.0-imap php7.0-intl php7.0-json php7.0-ldap php7.0-mcrypt php7.0-modules-source php7.0-mysql php7.0-odbc php7.0-opcache php7.0-pgsql php7.0-phpdbg php7.0-pspell php7.0-readline php7.0-recode php7.0-sqlite3 php7.0-sybase php7.0-tid
# Apache 2
apt-get install -y -q apache2 apache2-utils libapache2-mod-php7.0 libapache2-mod-proxy-html libapache2-mod-fastcgi
a2enmod proxy cgi rewrite ssl vhost_alias
a2dissite 000-default
# Redis
wget https://github.com/phpredis/phpredis/archive/php7.zip
unzip php7.zip
cd phpredis-php7
phpize
make
make install
echo "extension=redis.so" > /etc/php/mods-available/redis.ini
ln -s /etc/php/mods-available/redis.ini /etc/php/7.0/apache2/conf.d/20-redis.ini
# ownCloud
#echo "deb http://download.owncloud.org/download/repositories/8.2/Debian_8.0/ /" > /etc/apt/sources.list.d/owncloud.list
#apt-get update
cd /var/www
wget https://download.owncloud.org/community/owncloud-8.2.1.tar.bz2
tar xf owncloud-8.2.1.tar.bz2
rm -f owncloud-8.2.1.tar.bz2
mv $UH/install_scripts/owncloud-vhost /etc/apache2/sites-available/owncloud.conf
a2ensite owncloud
service apache2 restart
echo "<?php\nphpinfo();\n" > /var/www/html/info.php
chown www-data:www-data /var/www/html/info.php
echo "screenfetch" > ~/.bashrc
<VirtualHost *:80>
ServerAdmin admin@localhost
ServerName localhost
Redirect permanent / https://localhost/
ErrorLog /var/log/apache2/owncloud.error.log
CustomLog /var/log/apache2/owncloud.access.log common
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin@localhost
ServerName localhost
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
</IfModule>
DocumentRoot /var/www/owncloud
<Directory /var/www/owncloud/>
Options +FollowSymLinks
AllowOverride All
#Order allow,deny
#Allow from all
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/owncloud
SetEnv HTTP_HOME /var/www/owncloud
</Directory>
<Directory "/var/www/owncloud/data/">
# just in case if .htaccess gets disabled
Require all denied
</Directory>
## Please enable this manually, if needed. See also
## https://doc.owncloud.org/server/8.2/admin_manual/issues/index.html#apple-ios
Redirect 301 /.well-known/carddav /owncloud/remote.php/carddav
Redirect 301 /.well-known/caldav /owncloud/remote.php/caldav
SSLEngine on
SSLCertificateFile "/etc/ssl/private/selfsigned.cert"
SSLCertificateKeyFile "/etc/ssl/private/selfsigned.key"
SSLCACertificatePath /etc/ssl/certs/
ErrorLog /var/log/apache2/owncloud-ssl.error.log
CustomLog /var/log/apache2/owncloud-ssl.access.log common
</VirtualHost>
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "deb/jessie-amd64"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 80, host: 8088
config.vm.network "forwarded_port", guest: 443, host: 8089
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
#config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "1024"
end
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get -y -q install git
git clone https://gist.github.com/643f8b10ce4c0c5a3b27.git ~/install_scripts
sh ~/install_scripts/bootstrap.sh
#mv ~/install_scripts/bootstrap.sh /home/vagrant/bootstrap.sh
#chown vagrant:vagrant /home/vagrant/bootstrap.sh
#echo "sudo /home/vagrant/./bootstrap.sh" >> /home/vagrant/.bashrc
#chmod +x /home/vagrant/bootstrap.sh
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment