ncraspi
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Beide Seiten, vorherige ÜberarbeitungVorherige ÜberarbeitungNächste Überarbeitung | Vorherige Überarbeitung | ||
| ncraspi [2019/07/21 09:38] – noone | ncraspi [2022/03/24 23:56] (aktuell) – noone | ||
|---|---|---|---|
| Zeile 2: | Zeile 2: | ||
| ===0. Vorbereitung=== | ===0. Vorbereitung=== | ||
| - | aktuelles | + | aktuelles |
| ssh aktivieren\\ | ssh aktivieren\\ | ||
| RasPi starten | RasPi starten | ||
| Zeile 14: | Zeile 14: | ||
| * reboot | * reboot | ||
| * update/ | * update/ | ||
| - | * rpi-update | + | [[piwebmin|Webmin]] |
| - | sudo apt install rpi-update | ||
| - | sudo rpi-update | ||
| - | sudo reboot | ||
| Weitere Software installieren | Weitere Software installieren | ||
| - | sudo apt install mc htop | + | sudo apt install mc gpm htop |
| [[staticip|Feste IP-Adresse zuweisen]] | [[staticip|Feste IP-Adresse zuweisen]] | ||
| Zeile 30: | Zeile 27: | ||
| ===1. Webserver installieren=== | ===1. Webserver installieren=== | ||
| - | Webserver mit PHP installieren | + | sudo apt install |
| - | sudo apt install apache2 php7.3 php7.3-gd php7.3-curl php7.3-common | + | |
| + | mariadb-server\ | ||
| + | mariadb-client\ | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | php-imagick | ||
| + | libapache2-mod-php | ||
| - | | | | + | MariaDB absichern |
| + | sudo mysql_secure_installation | ||
| - | Root-Passwort | + | Datenbank |
| - | | + | sudo mysql -u root -p |
| - | Alle Nachfragen mit < | + | |
| - | PHP-Modul in Apache aktivieren | + | |
| - | sudo a2enmod php7.3 | + | |
| - | Apache neu starten | + | grant all on NextCloud.* to ' |
| - | sudo systemctl restart apache2 | + | |
| - | Datenbank und Datenbankuser anlegen | + | |
| - | mysql -u root -p | + | |
| - | | + | |
| - | | + | |
| - | grant all privileges | + | |
| flush privileges; | flush privileges; | ||
| - | exit; | + | quit |
| - | Binäres Logging in MariaDB aktivieren | + | |
| - | sudo nano / | + | |
| - | Folgende Zeilen hinzufügen | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | Anschliessend den mysql-Dämon neu starten | + | |
| - | sudo systemctl restart mysql | + | |
| - | ====NextCloud | + | NextCloud |
| + | cd ~/ | ||
| + | wget https:// | ||
| + | und entpacken | ||
| + | unzip latest.zip | ||
| + | Verzeichnis nextcloud in den Webserver verschieben und Benutzer anpassen | ||
| + | sudo mv nextcloud / | ||
| + | sudo chown -R www-data.www-data / | ||
| - | NextCloud herunterladen und installieren: | + | Konfiguration für virtuellen Host anlegen |
| - | cd /var/www/html | + | sudo nano /etc/apache2/sites-available/ |
| - | sudo wget https://download.nextcloud.com/server/releases/nextcloud-12.0.0.zip | + | mit dem Inhalt |
| - | sudo unzip nextcloud-*.zip | + | < |
| - | sudo rm nextcloud-*.zip | + | ServerName p37.ddnss.de |
| - | Eigentümer des Verzeichnisses | + | ServerAdmin pegasus37@gmx.net |
| - | sudo chown -R www-data:www-data /var/www/nextcloud | + | DocumentRoot |
| + | |||
| + | ErrorLog ${APACHE_LOG_DIR}/ | ||
| + | | ||
| + | |||
| + | < | ||
| + | Options +FollowSymlinks | ||
| + | | ||
| + | |||
| + | < | ||
| + | Dav off | ||
| + | </ | ||
| + | |||
| + | | ||
| + | | ||
| + | </ | ||
| + | </ | ||
| - | Für den SSL-Zugriff Git und Let's Encrypt installieren: | + | Webserver neustarten |
| - | | + | |
| - | cd /etc | + | |
| - | sudo git clone https:// | + | |
| - | Installationsscript für Let's Encrypt ausführen | + | |
| - | cd / | + | |
| - | sudo ./ | + | |
| - | Bei der Frage nach der Zugriffsart sicheren Zugriff auswählen. | + | |
| - | Apache anpassen: | + | ===2. Zertifikat einrichten=== |
| - | ServerSignature and ServerTokens in der security.conf ändern | + | |
| - | sudo nano / | + | |
| - | | + | |
| - | | + | |
| - | Apache neu starten: | + | |
| - | sudo service apache2 restart | + | |
| + | Pakete installieren | ||
| + | sudo apt install certbot python-certbot-apache | ||
| + | Zertifikat anfordern | ||
| + | **Achtung: | ||
| + | sudo certbot --apache | ||
| + | Automatische Zertifikas-Erneuerung anlegen | ||
| + | Mit | ||
| + | sudo crontab -e | ||
| + | die Cron-Tabelle öffnen und neuen Job eintragen | ||
| + | 0 3 * * * / | ||
| + | Nach dem Speichern wird das Zertifikat rechtzeitig vor Ablauf automatisch erneuert. | ||
| - | + | Für die Hintergrundarbeiten der NextCloud ist noch ein weiterer Cronjob anzulegen, diesmal für den Benutzer | |
| - | + | ||
| - | for faster performance also comment out “CustomLog ${APACHE_LOG_DIR}/ | + | |
| - | + | ||
| - | change apache2.conf: | + | |
| - | sudo nano / | + | |
| - | and add at the end: | + | |
| - | < | + | |
| - | | + | |
| - | </ | + | |
| - | + | ||
| - | sudo nano / | + | |
| - | add the following line | + | |
| - | | + | |
| - | + | ||
| - | one line above </ | + | |
| - | + | ||
| - | enable module headers: | + | |
| - | sudo a2enmod headers | + | |
| - | + | ||
| - | restart apache2: | + | |
| - | sudo service apache2 restart | + | |
| - | + | ||
| - | login to your nextcloud installation over your_no_ip.domain.com | + | |
| - | + | ||
| - | to remove the memory cache bug from admin panel: | + | |
| - | add in config.php the following line before “;” : | + | |
| - | sudo nano / | + | |
| - | + | ||
| - | ' | + | |
| - | + | ||
| - | restart apache2: | + | |
| - | sudo service apache2 restart | + | |
| - | + | ||
| - | setting strong directory permissions | + | |
| - | + | ||
| - | cd ~ | + | |
| - | touch set-nextcloud-permissions.sh | + | |
| - | chmod +x set-nextcloud-permissions.sh | + | |
| - | nano set-nextcloud-permissions.sh | + | |
| - | + | ||
| - | # | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | mkdir -p $ncpath/ | + | |
| - | mkdir -p $ncpath/ | + | |
| - | mkdir -p $ncpath/ | + | |
| - | + | ||
| - | | + | |
| - | find ${ncpath}/ -type f -print0 | xargs -0 chmod 0640 | + | |
| - | find ${ncpath}/ -type d -print0 | xargs -0 chmod 0750 | + | |
| - | + | ||
| - | | + | |
| - | chown -R ${rootuser}: | + | |
| - | chown -R ${htuser}: | + | |
| - | chown -R ${htuser}: | + | |
| - | chown -R ${htuser}: | + | |
| - | chown -R ${htuser}: | + | |
| - | chown -R ${htuser}: | + | |
| - | chown -R ${htuser}: | + | |
| - | + | ||
| - | chmod +x ${ncpath}/ | + | |
| - | + | ||
| - | | + | |
| - | if [ -f ${ncpath}/ | + | |
| - | then | + | |
| - | chmod 0644 ${ncpath}/ | + | |
| - | chown ${rootuser}: | + | |
| - | fi | + | |
| - | if [ -f ${ncpath}/ | + | |
| - | then | + | |
| - | chmod 0644 ${ncpath}/ | + | |
| - | chown ${rootuser}: | + | |
| - | fi | + | |
| - | + | ||
| - | run the script: | + | |
| - | sudo ./ | + | |
| - | rm set-nextcloud-permissions.sh | + | |
| - | if you are working in your own network try the_ip_of_your_pi (will be faster) | + | |
| - | + | ||
| - | do backgroundjobs with cron instead of AJAX | + | |
| - | + | ||
| - | login in to the adminpanel and change cronjobs from AJAX to Cron: | + | |
| - | edit the crontab of www-data: | + | |
| sudo crontab -u www-data -e | sudo crontab -u www-data -e | ||
| - | and add at the end: | + | */5 * * * * php -f / |
| - | */15 | + | |
| - | + | ||
| - | check the crontab of www-data: | + | |
| - | sudo crontab -u www-data -l | + | |
| - | + | ||
| - | 10) install your nextcloud clients on your devices (smartphone, | + | |
| - | for android: | + | |
| - | https:// | + | |
| - | + | ||
| - | linux pc: | + | |
| - | sudo apt-get install owncloud-client | + | |
| - | + | ||
| - | or use nextclouds appimage: | + | |
| - | https:// | + | |
| - | + | ||
| - | wget https:// | + | |
| - | chmod +x Nextcloud-*.AppImage | + | |
| - | + | ||
| - | more: | + | |
| - | https:// | + | |
| - | + | ||
| - | nextcloud calDAV, cardDAV: | + | |
| - | login into webinterface as admin and enable apps: calendar, contacts | + | |
| - | or: | + | |
| - | sudo -u www-data php / | + | |
| - | sudo -u www-data php / | + | |
| - | + | ||
| - | on android install davdroid: | + | |
| - | https:// | + | |
| - | + | ||
| - | in the app enter your address of your pi | + | |
| - | if you want to use it only in your local lan, use your local lan ip.. | + | |
| - | + | ||
| - | if you are migrating from google to nextcloud you can export your calendars: | + | |
| - | https:// | + | |
| - | + | ||
| - | 11) security: | + | |
| - | this is MOST important. BUT you also have to search for it YOURSELF. | + | |
| - | + | ||
| - | if you are not a security expert best REMOVE port forwarding for ports 80 and 443 from your router like recommended in 5) | + | |
| - | so it will ONLY be reachable from your LOCAL network over 192.168.x.x | + | |
| - | + | ||
| - | 11.0) upgrade nextcloud when a new release arrives | + | |
| - | UPGRADE, UPGRADE, UPGRADE ..otherwise you will miss fixed security bugs.. | + | |
| - | how to upgrade from an older installation is described in 13) | + | |
| - | you can check your security of your current nextcloud version at: | + | |
| - | https:// | + | |
| - | + | ||
| - | 11.1) check your ssl connection: | + | |
| - | https:// | + | |
| - | + | ||
| - | 11.2) enable fail2ban for logins: | + | |
| - | based on: https:// | + | |
| - | + | ||
| - | you can check manually for failed logins: | + | |
| - | sudo lastb | + | |
| - | + | ||
| - | install fail2ban: | + | |
| - | sudo apt install fail2ban | + | |
| - | + | ||
| - | create a nextcloud.conf: | + | |
| - | sudo nano / | + | |
| - | + | ||
| - | [Definition] | + | |
| - | failregex={" | + | |
| - | + | ||
| - | ignoreregex = | + | |
| - | + | ||
| - | create a jail.local: | + | |
| - | sudo nano / | + | |
| - | + | ||
| - | [nextcloud] | + | |
| - | enabled = true | + | |
| - | filter | + | |
| - | # select http, https or both, depending on which you use: | + | |
| - | port = http, | + | |
| - | # edit the logpath to your needs: | + | |
| - | logpath = / | + | |
| - | + | ||
| - | start/ reload fail2ban: | + | |
| - | sudo service fail2ban start | + | |
| - | sudo service fail2ban reload | + | |
| - | sudo service fail2ban status | + | |
| - | + | ||
| - | check fail2ban log: | + | |
| - | cat / | + | |
| - | + | ||
| - | manually check log files: | + | |
| - | Log files of Web Server: | + | |
| - | sudo nano / | + | |
| - | sudo nano / | + | |
| - | sudo nano / | + | |
| - | sudo zless / | + | |
| - | sudo zless -S / | + | |
| - | sudo nano / | + | |
| - | + | ||
| - | example to unzip a gz files: | + | |
| - | gunzip other_vhosts_access.log.2.gz | + | |
| - | + | ||
| - | clean a log file from unimportant lines (remove all lines from a file that start with “string”): | + | |
| - | sed -i '/ | + | |
| - | + | ||
| - | Log file of nextcloud: | + | |
| - | sudo nano / | + | |
| - | + | ||
| - | if you want to read only the last 10 entrys use: | + | |
| - | tail -10 / | + | |
| - | + | ||
| - | get the version of your nextcloud (simply add a /status.php at the end of the address): | + | |
| - | https:// | + | |
| - | + | ||
| - | see apache2 logs: | + | |
| - | sudo su | + | |
| - | cd / | + | |
| - | + | ||
| - | 11.5) run update && upgrade on a regular basis | + | |
| - | run the following code once a week or so: | + | |
| - | sudo apt-get update && sudo apt-get upgrade -y | + | |
| - | maybe do it with a cronjob. | + | |
| - | but be aware, sometimes new software might break your running system, so maybe run it manually so you you will be able to check it directly if it is still working. | + | |
| - | + | ||
| - | 12) daily backup nextcloud(rsync data and config directorys to usb-stick): | + | |
| - | this daily backup uses rsync, the bad about that is: | + | |
| - | do not use doubledots in filenames in owncloud | + | |
| - | do not use spaces at the end of a foldername | + | |
| - | if you have an idea to avoid rsync rescanning files with that properties let me know. | + | |
| - | + | ||
| - | create the folder usbdisk: | + | |
| - | sudo mkdir / | + | |
| - | + | ||
| - | make the user pi the owner of the folder: | + | |
| - | sudo chown -R pi:pi / | + | |
| - | + | ||
| - | add the usb-stick in fstab (so it will be mounted on boot): | + | |
| - | sudo nano / | + | |
| - | and add at the end of the file the following line, replace 02A2-C123 with your UUID | + | |
| - | + | ||
| - | UUID=02A2-C123 / | + | |
| - | + | ||
| - | create a backup script: | + | |
| - | cd | + | |
| - | touch backup-nextcloud2stick.sh | + | |
| - | chmod +x backup-nextcloud2stick.sh | + | |
| - | nano backup-nextcloud2stick.sh | + | |
| - | 1 | + | |
| - | 2 | + | |
| - | 3 | + | |
| - | 4 | + | |
| - | 5 | + | |
| - | 6 | + | |
| - | 7 | + | |
| - | 8 | + | |
| - | 9 | + | |
| - | 10 | + | |
| - | 11 | + | |
| - | 12 | + | |
| - | 13 | + | |
| - | 14 | + | |
| - | + | ||
| - | # | + | |
| - | #set nexcloud to maintaince mode, stop apache2, backup data and config folders, start apache, disable maintaince mode | + | |
| - | (date " | + | |
| - | sudo -u www-data php / | + | |
| - | sleep 5 | + | |
| - | sudo service apache2 stop && \ | + | |
| - | sleep 5 | + | |
| - | sudo rsync -rtuv / | + | |
| - | sudo rsync -rtuv / | + | |
| - | sleep 5 | + | |
| - | sudo service apache2 start && \ | + | |
| - | sleep 5 | + | |
| - | sudo -u www-data php / | + | |
| - | (date " | + | |
| - | + | ||
| - | add the script to crontab: (so it will run everyday at 1:30) | + | |
| - | crontab -e | + | |
| - | 1 | + | |
| - | + | ||
| - | 30 01 * * * / | + | |
| - | + | ||
| - | the calendars are a part of the sqlite database and will be backup in / | + | |
| - | + | ||
| - | 13) upgrade | + | |
| - | if you are using a very old version do not update directly to the latest version!!! | + | |
| - | ownCloud and the current Nextcloud releases do not have the the ability to skip releases. This means upgrades have to go through all major releases. | + | |
| - | Always start by upgrading to the latest bugfix/ | + | |
| - | To ensure app data is properly migrated you have to update and enable the apps after each step. They are automatically disabled to make sure the server does not break during the upgrade. | + | |
| - | Starting ownCloud 8.2.x or Nextcloud 9.0, you can use the new Nextcloud updater, skipping the steps below | + | |
| - | + | ||
| - | for more information about upgrading to a new major release have a look at: | + | |
| - | https:// | + | |
| - | + | ||
| - | 13.a) upgrade manually(if a new version is avaliable, for example from 11.0.1 to 11.0.2) | + | |
| - | based on: | + | |
| - | https:// | + | |
| - | https:// | + | |
| - | https:// | + | |
| - | https:// | + | |
| - | + | ||
| - | if you just have a small update you can try my steps (for example from 11.0.1 to 11.0.2): | + | |
| - | switch to maintaince mode: | + | |
| - | sudo -u www-data php / | + | |
| - | sudo -u www-data php / | + | |
| - | sudo -u www-data php / | + | |
| - | + | ||
| - | stop the webserver: | + | |
| - | sudo service apache2 stop | + | |
| - | + | ||
| - | rename the old nextcloud folder: | + | |
| - | cd /var/www/ | + | |
| - | sudo mv nextcloud nextcloud_old | + | |
| - | + | ||
| - | get latest nextcloud version: | + | |
| - | #sudo wget https:// | + | |
| - | #sudo wget https:// | + | |
| - | #sudo wget https:// | + | |
| - | #sudo wget https:// | + | |
| - | cd /var/www/ | + | |
| - | sudo wget https:// | + | |
| - | sudo unzip nextcloud-*.zip | + | |
| - | sudo rm nextcloud-*.zip | + | |
| - | + | ||
| - | move over the old config.php file and the data directory: | + | |
| - | sudo mv / | + | |
| - | sudo mv / | + | |
| - | + | ||
| - | create a script to set permissions for update: | + | |
| - | cd | + | |
| - | touch nextcloud_upgrade_perms.sh | + | |
| - | chmod +x nextcloud_upgrade_perms.sh | + | |
| - | nano nextcloud_upgrade_perms.sh | + | |
| - | 1 | + | |
| - | 2 | + | |
| - | 3 | + | |
| - | 4 | + | |
| - | 5 | + | |
| - | 6 | + | |
| - | 7 | + | |
| - | 8 | + | |
| - | + | ||
| - | # | + | |
| - | # Sets permissions of the Nextcloud instance for updating | + | |
| - | + | ||
| - | ncpath='/ | + | |
| - | htuser=' | + | |
| - | htgroup=' | + | |
| - | + | ||
| - | chown -R ${htuser}: | + | |
| - | + | ||
| - | change the permissions: | + | |
| - | sudo ./ | + | |
| - | rm nextcloud_upgrade_perms.sh | + | |
| - | + | ||
| - | start the webserver: | + | |
| - | sudo service apache2 start | + | |
| - | + | ||
| - | upgrade nextcloud: | + | |
| - | sudo -u www-data php / | + | |
| - | + | ||
| - | stop the webserver: | + | |
| - | sudo service apache2 stop | + | |
| - | + | ||
| - | set strong directory permissions: | + | |
| - | it is explained in step 8) | + | |
| - | + | ||
| - | start the webserver: | + | |
| - | sudo service apache2 start | + | |
| - | + | ||
| - | disable maintaince mode: | + | |
| - | sudo -u www-data php / | + | |
| - | sudo -u www-data php / | + | |
| - | sudo -u www-data php / | + | |
| - | sudo -u www-data php / | + | |
| - | + | ||
| - | if you have setup fail2ban with nextcloud 9.0.53 or previous as i explained it in 11.2), do not forget to do it again, cause the path of the logfile changed from owncloud.log to nextcloud.log | + | |
| - | + | ||
| - | if the update worked also remove the old nextcloud folder: | + | |
| - | sudo rm -r / | + | |
| - | + | ||
| - | 13.b) upgrade web based(if a new version is avaliable, for example from 10.0.1 to 10.0.2) | + | |
| - | based on: | + | |
| - | https:// | + | |
| - | + | ||
| - | on website login as with your admin account | + | |
| - | click on top right to get the menu | + | |
| - | 01-admin | + | |
| - | choose “Admin” | + | |
| - | + | ||
| - | 02-open-updater | + | |
| - | click “Open updater” | + | |
| - | 03-start-update | + | |
| - | click “Start update” | + | |
| - | it got the error | + | |
| - | 04-error-update | + | |
| - | logged into my pi over ssh | + | |
| - | then run: | + | |
| - | sudo -s | + | |
| - | cd / | + | |
| - | rm -r assets | + | |
| - | on website run the updater again “Retry update” | + | |
| - | got the error check write permissions | + | |
| - | 05-wrong-write-permissions | + | |
| - | best enable maintaince mode first.. so owncloud is not doing important stuff in background | + | |
| - | sudo -u www-data php / | + | |
| - | connect again over ssh and run in terminal the script nextcloud_upgrade_perms.sh [creating the script is explained in 13)a)] | + | |
| - | cd && sudo ./ | + | |
| - | and run the updater again “Retry update” | + | |
| - | took ~5 minutes on pi2 to get the following site | + | |
| - | 06-maintaince-mode-switch | + | |
| - | now set old perms on owncloud directory [creating the script is explained in 13)a)]: | + | |
| - | cd && sudo ./ | + | |
| - | then click on “No (for usage of the web based updater)” | + | |
| - | 07-finish-update | + | |
| - | then click on “Go to back to your Nextcloud instance to finish the update” | + | |
| - | 08-start-update | + | |
| - | “Start update” | + | |
| - | done. | + | |
| - | + | ||
| - | 14) nextcloud’s command line | + | |
| - | based on: https:// | + | |
| - | sudo su | + | |
| - | cd / | + | |
| - | + | ||
| - | rescan all files of all users: | + | |
| - | sudo -u www-data php occ files:scan --all -v | + | |
| - | + | ||
| - | cleanup nextclouds filecache: | + | |
| - | sudo -u www-data php occ files: | + | |
| - | + | ||
| - | cleanup all deleted files: | + | |
| - | sudo -u www-data php occ trashbin: | + | |
| - | + | ||
| - | cleanup files for a user: | + | |
| - | sudo -u www-data php occ trashbin: | + | |
| - | list all commands: | + | ===3. Nextcloud einrichten=== |
| - | sudo -u www-data php occ | + | |
| - | 15) other stuff | + | Webseite aufrufen |
| - | https:// | + | <ip des Raspberry Pi>/nextcloud |
| + | ===PHP-Optimierungen=== | ||
| + | OPCache aktivieren | ||
| + | sudo nano / | ||
| - | Dateigrösse für den Upload anpassen | + | Einträge aktivieren |
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| - | Die php.ini bearbeiten | + | Filegrössen |
| - | sudo nano / | + | |
| - | Die folgenden beiden Zeilen | + | |
| | | ||
| | | ||
| - | Speichern, schliessen, Apache neu starten | + | |
| - | sudo service apache2 restart | + | memory_limit = 512M |
| + | ===PHP-Memory-Cache=== | ||
| - | https:// | + | Redis-Server inklusive passendes PHP-Modul installieren |
| - | https:// | + | sudo apt install |
| - | https:// | + | |
ncraspi.1563694705.txt.gz · Zuletzt geändert: 2019/07/21 09:38 von noone
