mirror of
https://github.com/mtan93/install-nextcloud.git
synced 2026-03-19 13:21:00 +00:00
@@ -1,7 +1,7 @@
|
|||||||
# install-nextcloud
|
# install-nextcloud
|
||||||
Install, optimize and harden your self hosted Nextcloud (based on Ubuntu 16.04.x LTS 64Bit) using two shell scripts only.
|
Install, optimize and harden your self hosted Nextcloud (based on Ubuntu 16.04.x LTS 64Bit) using two shell scripts only.
|
||||||
|
|
||||||
The initial script called "install-nextcloud.sh" will install your self hosted Nextcloud within few minutes fully automated. Your server will be built of:
|
The initial script (install-nextcloud.sh) will install your self hosted Nextcloud within few minutes fully automated. Your server will be built of:
|
||||||
|
|
||||||
MariaDB
|
MariaDB
|
||||||
Nextcloud 13.0.1
|
Nextcloud 13.0.1
|
||||||
@@ -12,8 +12,8 @@ The initial script called "install-nextcloud.sh" will install your self hosted N
|
|||||||
|
|
||||||
The only precondition for this script is to use Ubuntu 16.04.4 LTS 64Bit as your server OS.
|
The only precondition for this script is to use Ubuntu 16.04.4 LTS 64Bit as your server OS.
|
||||||
|
|
||||||
If you have configured your Nextcloud in your preferred browser issue the second script called "optimizations.sh" to optimize your Nextcloud instance (cache, previews, cron etc.) and install & configure fail2ban with ufw to harden your Nextcloud instance.
|
Configure your Nextcloud in your preferred browser and participate of the opportunity to issue the second script called "optimizations.sh", which will optimize your Nextcloud (cache, previews, cron etc.) and install + configure fail2ban and ufw to harden your Nextcloud server. At least you may request a ssl certificate from letsencrypt by issuing the third script called "ssl-certificat.sh".
|
||||||
|
|
||||||
Cheers, Carsten Rieger IT-Services
|
Ready to go? Let's start:
|
||||||
|
|
||||||
Find out more information: <a href="https://www.c-rieger.de/spawn-your-nextcloud-server-using-one-shell-script/" target="_blank">Build your Nextcloud Server using shell scripts only</a>
|
Find out more information: <a href="https://www.c-rieger.de/spawn-your-nextcloud-server-using-one-shell-script/" target="_blank">Build your Nextcloud Server using shell scripts only</a>
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
#######################################################
|
||||||
# Carsten Rieger IT-Services
|
# Carsten Rieger IT-Services
|
||||||
# INSTALL-NEXTCLOUD.SH
|
# INSTALL-NEXTCLOUD.SH
|
||||||
# Version 1.1
|
# Version 1.1
|
||||||
# added funtions to make code cleaner, thx @techandme.se
|
|
||||||
# April 19th, 2018
|
# April 19th, 2018
|
||||||
|
# version 1.1: added functions
|
||||||
|
# Version 1.0: initial script
|
||||||
|
#######################################################
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
function update_and_clean() {
|
function update_and_clean() {
|
||||||
apt update
|
apt update
|
||||||
@@ -382,4 +385,4 @@ echo " https://$(hostname)"
|
|||||||
echo ""
|
echo ""
|
||||||
echo " and confirm the upcoming ssl warning caused by the self-signed certificates. "
|
echo " and confirm the upcoming ssl warning caused by the self-signed certificates. "
|
||||||
echo "###############################################################################"
|
echo "###############################################################################"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
#######################################################
|
||||||
# Carsten Rieger IT-Services
|
# Carsten Rieger IT-Services
|
||||||
# OPTIMIZATIONS.SH
|
# OPTIMIZATIONS.SH
|
||||||
# Version 1.1
|
# Version 1.1
|
||||||
# added funtions to make code cleaner, thx @techandme.se
|
|
||||||
# April 19th, 2018
|
# April 19th, 2018
|
||||||
|
# version 1.1: added functions
|
||||||
|
# Version 1.0: initial script
|
||||||
|
#######################################################
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
function update_and_clean() {
|
function update_and_clean() {
|
||||||
apt update
|
apt update
|
||||||
@@ -115,4 +118,4 @@ quit
|
|||||||
EOF
|
EOF
|
||||||
restart_all_services
|
restart_all_services
|
||||||
nextcloud_scan_data
|
nextcloud_scan_data
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -1,24 +1,32 @@
|
|||||||
|
#######################################################
|
||||||
# Carsten Rieger IT-Services
|
# Carsten Rieger IT-Services
|
||||||
# SSL-CERTIFICATE.SH
|
# SSL-CERTIFICATE.SH
|
||||||
# Version 1.0
|
# Version 1.0
|
||||||
# April 20th, 2018
|
# April 20th, 2018
|
||||||
|
# Version 1.0: initial script
|
||||||
|
#######################################################
|
||||||
|
#!/bin/bash
|
||||||
|
###global function to update and cleanup the environment
|
||||||
function update_and_clean() {
|
function update_and_clean() {
|
||||||
apt update
|
apt update
|
||||||
apt upgrade -y
|
apt upgrade -y
|
||||||
apt autoclean -y
|
apt autoclean -y
|
||||||
apt autoremove -y
|
apt autoremove -y
|
||||||
}
|
}
|
||||||
|
###global function to restart all cloud services
|
||||||
function restart_all_services() {
|
function restart_all_services() {
|
||||||
/usr/sbin/service nginx restart
|
/usr/sbin/service nginx restart
|
||||||
/usr/sbin/service mysql restart
|
/usr/sbin/service mysql restart
|
||||||
/usr/sbin/service redis-server restart
|
/usr/sbin/service redis-server restart
|
||||||
/usr/sbin/service php7.2-fpm restart
|
/usr/sbin/service php7.2-fpm restart
|
||||||
}
|
}
|
||||||
|
###global function to create backups of the effected files
|
||||||
function copy4SSL() {
|
function copy4SSL() {
|
||||||
cp /etc/nginx/conf.d/nextcloud.conf /etc/nginx/conf.d/nextcloud.conf.orig
|
cp /etc/nginx/conf.d/nextcloud.conf /etc/nginx/conf.d/nextcloud.conf.orig
|
||||||
cp /etc/nginx/ssl.conf /etc/nginx/ssl.conf.orig
|
cp /etc/nginx/ssl.conf /etc/nginx/ssl.conf.orig
|
||||||
cp /var/www/nextcloud/config/config.php /var/www/nextcloud/config/config.php.orig
|
cp /var/www/nextcloud/config/config.php /var/www/nextcloud/config/config.php.orig
|
||||||
}
|
}
|
||||||
|
###global function to show an error message if the certificate request would fail
|
||||||
function errorSSL() {
|
function errorSSL() {
|
||||||
clear
|
clear
|
||||||
echo "*** ERROR while requeting your certificate(s) ***"
|
echo "*** ERROR while requeting your certificate(s) ***"
|
||||||
@@ -27,24 +35,39 @@ echo "Verify that both ports (80 + 443) are forwarded to this server!"
|
|||||||
echo "And verify, your dyndns points to your IP either!"
|
echo "And verify, your dyndns points to your IP either!"
|
||||||
echo "Then retry..."
|
echo "Then retry..."
|
||||||
}
|
}
|
||||||
|
#add the letsencrypt repository to the server
|
||||||
add-apt-repository ppa:certbot/certbot -y
|
add-apt-repository ppa:certbot/certbot -y
|
||||||
update_and_clean
|
update_and_clean
|
||||||
|
#install letsencrypt
|
||||||
apt install letsencrypt -y
|
apt install letsencrypt -y
|
||||||
|
#ensure lower cases
|
||||||
declare -l DYNDNSNAME
|
declare -l DYNDNSNAME
|
||||||
declare -l YOURSERVERNAME
|
declare -l YOURSERVERNAME
|
||||||
|
#read the current hostname
|
||||||
YOURSERVERNAME=$(hostname)
|
YOURSERVERNAME=$(hostname)
|
||||||
|
#ask the user what would be the domain name to request the certificate for
|
||||||
read -p "Your domain: " DYNDNSNAME
|
read -p "Your domain: " DYNDNSNAME
|
||||||
|
#request the certificate for the entered domain name
|
||||||
letsencrypt certonly -a webroot --webroot-path=/var/www/letsencrypt --rsa-key-size 4096 -d $DYNDNSNAME
|
letsencrypt certonly -a webroot --webroot-path=/var/www/letsencrypt --rsa-key-size 4096 -d $DYNDNSNAME
|
||||||
|
#in case of any errors
|
||||||
if [ ! -d "/etc/letsencrypt/live" ]; then
|
if [ ! -d "/etc/letsencrypt/live" ]; then
|
||||||
errorSSL
|
errorSSL
|
||||||
|
#if no error appeared
|
||||||
else
|
else
|
||||||
copy4SSL
|
copy4SSL
|
||||||
|
#remove the entry for the self signed certificates
|
||||||
sed -i '/ssl-cert-snakeoil/d' /etc/nginx/ssl.conf
|
sed -i '/ssl-cert-snakeoil/d' /etc/nginx/ssl.conf
|
||||||
|
#apply the new server/domain name to the NGINX vhost for Nextcloud
|
||||||
sed -i "s/server_name.*;/server_name $DYNDNSNAME;/" /etc/nginx/conf.d/nextcloud.conf
|
sed -i "s/server_name.*;/server_name $DYNDNSNAME;/" /etc/nginx/conf.d/nextcloud.conf
|
||||||
|
#change the placeholder values to the exact letsencrypt ones
|
||||||
sed -in 's/YOUR.DEDYN.IO/'$DYNDNSNAME'/' /etc/nginx/ssl.conf
|
sed -in 's/YOUR.DEDYN.IO/'$DYNDNSNAME'/' /etc/nginx/ssl.conf
|
||||||
|
# remove the '#' to enable these certificates/keys
|
||||||
sed -i s/\#\ssl/\ssl/g /etc/nginx/ssl.conf
|
sed -i s/\#\ssl/\ssl/g /etc/nginx/ssl.conf
|
||||||
|
#ensure that dhparam is commented as long it was not generated
|
||||||
sed -i s/ssl_dhparam/\#ssl_dhparam/g /etc/nginx/ssl.conf
|
sed -i s/ssl_dhparam/\#ssl_dhparam/g /etc/nginx/ssl.conf
|
||||||
|
#adjust Nextclous config.php to the new domain name
|
||||||
sudo -u www-data sed -in 's/'$YOURSERVERNAME'/'$DYNDNSNAME'/' /var/www/nextcloud/config/config.php
|
sudo -u www-data sed -in 's/'$YOURSERVERNAME'/'$DYNDNSNAME'/' /var/www/nextcloud/config/config.php
|
||||||
|
#restart the cloud environment
|
||||||
restart_all_services
|
restart_all_services
|
||||||
clear
|
clear
|
||||||
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
@@ -53,4 +76,4 @@ echo " Call: https://$DYNDNSNAME and enjoy your Nextcloud"
|
|||||||
echo ""
|
echo ""
|
||||||
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user