Servereinrichtung: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
KKeine Bearbeitungszusammenfassung |
||
| (12 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 28: | Zeile 28: | ||
<li>cp /root/.ssh/authorized_keys .ssh/</li> | <li>cp /root/.ssh/authorized_keys .ssh/</li> | ||
<li>chown -R username:group.ssh/</li> | <li>chown -R username:group.ssh/</li> | ||
<li><p>nano /etc/ssh/sshd_config</p> | <li><p>nano /etc/ssh/sshd_config</p> | ||
<pre>PermitRootLogin no </pre></li> | <pre>PermitRootLogin no </pre></li> | ||
| Zeile 48: | Zeile 48: | ||
<li><p>ufw status verbose</p></li> | <li><p>ufw status verbose</p></li> | ||
<li><span id="dns-der-domain-angepasst-auf-die-ip-des-servers"></span>DNS der Domain angepasst auf die IP des Servers<li><p>apt install mariadb-server</p></li> | <li><span id="dns-der-domain-angepasst-auf-die-ip-des-servers"></span>DNS der Domain angepasst auf die IP des Servers<li><p>apt install mariadb-server</p></li> | ||
<li><p>mysql_secure_installation</p></li><li><p>SQL-Anbindung mit PHP prüfen siehe [https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mariadb-php-lemp-stack-on-debian-10 Digital Ocean] </p></li> | <li><p>mysql_secure_installation</p></li><li><p>SQL-Anbindung mit PHP prüfen siehe [https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mariadb-php-lemp-stack-on-debian-10 Digital Ocean] | ||
oder [https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-ubuntu-18-04-de hier mit Apache]</p></li> | |||
---- | ---- | ||
<li><p>apt install apache2 php libapache2-mod-php</p></li> | <li><p>apt install apache2 php libapache2-mod-php</p></li> | ||
| Zeile 76: | Zeile 77: | ||
<ul> | <ul> | ||
<li>systemctl restart fail2ban | <li>systemctl restart fail2ban | ||
<li>fail2ban-client status sshd | |||
---- | |||
<li><p>apt install snapd</p></li> | <li><p>apt install snapd</p></li> | ||
<li><p>snap install | <li><p>snap install --classic certbot</p></li> | ||
<li><p>ln -s /snap/bin/certbot /usr/bin/certbot</p></li> | <li><p>ln -s /snap/bin/certbot /usr/bin/certbot</p></li> | ||
<li><p>certbot | <li><p>certbot --apache</p></li> | ||
<li><p>certbot | <li><p>certbot --apache –register-unsafely-without-email</p></li> | ||
<li><p>letsencrypt | <li><p>letsencrypt --apache -d sitename.de,www.sitename.de,webmin.sitename.de</p></li> | ||
<li><p>certbot renew | <li><p>certbot renew --dry-run</p></li> | ||
<li><p>sudo certbot certificates</p></li> | |||
<li><p>systemctl list-timers</p> | <li><p>systemctl list-timers</p> | ||
</li> | </li> | ||
| Zeile 106: | Zeile 110: | ||
<pre> ✍ deb https://download.webmin.com/download/repository sarge contrib </pre> | <pre> ✍ deb https://download.webmin.com/download/repository sarge contrib </pre> | ||
<li><p>wget https://download.webmin.com/jcameron-key.asc</p></li> | <li><p>wget https://download.webmin.com/jcameron-key.asc</p></li> | ||
<li><p>cat jcameron-key.asc | gpg | <li><p>cat jcameron-key.asc | gpg --dearmor >/etc/apt/trusted.gpg.d/jcameron-key.gpg</p></li> | ||
<li><p>apt install apt-transport-https</p></li> | <li><p>apt install apt-transport-https</p></li> | ||
<li><p>apt update</p></li> | <li><p>apt update</p></li> | ||
| Zeile 117: | Zeile 121: | ||
<p>⚠ der Downloadlink stimmt nicht in der Webmin-Oberfläche: “www...” muss mit “http://download.webmin.com/download/modules” ersetzt werden</p></li></ul> | <p>⚠ der Downloadlink stimmt nicht in der Webmin-Oberfläche: “www...” muss mit “http://download.webmin.com/download/modules” ersetzt werden</p></li></ul> | ||
<span id="snapshot-ncubunua20230204s001"></span> | <span id="snapshot-ncubunua20230204s001"></span> | ||
==Snapshot | ==Snapshot ncubuntua20230204s001== | ||
*Datenbank astroneth mit Berechtigung erstellt: | |||
CREATE DATABASE astroneth; | |||
SELECT user FROM mysql.user; | |||
CREATE USER 'holger'@'localhost' IDENTIFIED BY 'sicheresPasswort'; | |||
GRANT ALL PRIVILEGES ON *.* TO 'holger'@'localhost'; | |||
CREATE USER 'holast'@'localhost' IDENTIFIED BY 'sicheresPasswort'; | |||
GRANT ALL PRIVILEGES ON astroneth . * TO 'holast'@'localhost'; | |||
FLUSH PRIVILEGES; | |||
*Tabellen über Webmin importiert | |||
*Datenbank anwiki mit Berechtigung erstellt: | |||
CREATE DATABASE anwiki; | |||
SELECT user FROM mysql.user; | |||
CREATE USER 'holwiki'@'localhost' IDENTIFIED BY 'sicheresPasswort'; | |||
GRANT ALL PRIVILEGES ON anwiki . * TO 'holwiki'@'localhost'; | |||
FLUSH PRIVILEGES; | |||
*Tabellen über Webmin importiert | |||
*Wiki kopiert und localsettings.php angepasst | |||
*Virtual-Hosts-Sites astroneth (001-anhome.conf) und holgerneth (001-mediawiki.conf) erstellt | |||
==Snapshot ncubunua20230407s001== | |||
==ToDo== | ==ToDo== | ||
<ul> | <ul> | ||
<li></li> | <li></li> | ||
<li> | <li></li> | ||
</li> | |||
<li>✍️ ToDo: [https://www.digitalocean.com/community/tutorials/how-to-configure-apache-to-use-custom-error-pages-on-ubuntu-14-04 eigene Fehlerseiten]</li> | <li>✍️ ToDo: [https://www.digitalocean.com/community/tutorials/how-to-configure-apache-to-use-custom-error-pages-on-ubuntu-14-04 eigene Fehlerseiten]</li> | ||
<li>✍️ ToDo: fail2ban und | <li> ✍️ ToDo: fail2ban und SSH-Port prüfen</li></ul> | ||
{{Hauptseite}} | {{Hauptseite}} | ||
[[Kategorie:Server]] | [[Kategorie:Server]] | ||
Aktuelle Version vom 21. Januar 2024, 11:19 Uhr
Servereinrichtung (mit Ubuntu und Apache)
Start Timeline
ssh-Zugriff mit root einrichten
root .bashrc ändern
#my own PS1="\[\e[1;31m\]PROD\[\e[0m\] $PS1 " mycpsave() { cp $1 $1.$(date +"%Y%m%d.%H%M%S%N"); }; export -f mycpsaveroot neues Passwort erstellt
useradd -m -s /bin/bash -c “Vorname Nachname” username
usermod -aG sudo username
passwd username
userhome .bashrc ändern
#my own PS1="\[\e[1;31m\]TEST\[\e[0m\] $PS1 " mycpsave() { cp $1 $1.$(date +"%Y%m%d.%H%M%S%N"); }; export -f mycpsave export PATH=~/bin:$PATH- mkdir .ssh
- cp /root/.ssh/authorized_keys .ssh/
- chown -R username:group.ssh/
nano /etc/ssh/sshd_config
PermitRootLogin no
dpkg-reconfigure dash
timedatectl
⚠ Zeitsynchronisation überprüfen systemctl status systemd-timesyncd timedatectl set-ntp true
apt install mc
apt install net-tools
apt update
apt dist-upgrade
apt install ufw
ufw app list
ufw allow OpenSSH
ufw enable
ufw status verbose
- DNS der Domain angepasst auf die IP des Servers
apt install mariadb-server
mysql_secure_installation
SQL-Anbindung mit PHP prüfen siehe Digital Ocean oder hier mit Apache
apt install apache2 php libapache2-mod-php
a2enmod ssl
apachectl configtest
systemctl restart apache2
usermod -aG www-data username
nano 001-sitename.de.conf
a2ensite 001-sitename.de.conf
ein paar Verzeichnisse erstellt in html und sitename.de/html
phpinfo.php erstellt
chown -R user:www-data /var/www/
apt install fail2ban
systemctl status fail2ban
cd /etc/fail2ban
cp jail.conf jail.local
nano jail.local
bantime = 30m findtime = 15m maxretry = 3 . . . [apache-auth][apache-badbots] enabled = true . . .
ℹ️ im home-Verzeichnis von username.
ℹ️ Erst SSH erlauben, bevor die Firewall arbeitet....
- systemctl restart fail2ban
- fail2ban-client status sshd
apt install snapd
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
certbot --apache
certbot --apache –register-unsafely-without-email
letsencrypt --apache -d sitename.de,www.sitename.de,webmin.sitename.de
certbot renew --dry-run
sudo certbot certificates
systemctl list-timers
apt install libapache2-mod-wsgi-py3
nano /etc/apache2/conf-available/mod-wsgi.conf
WSGIScriptAlias /test /var/www/sitename.de/html/test_wsgi.py
nano test_wsgi.py
im Website-Stammverzeichnis: def application(environ,start_response): status = '200 OK' html = b'<html>\n' \ b'<body>\n' \ b' Hooray, mod_wsgi is working\n' \ b'</body>\n' \ b'</html>\n' response_header = [('Content-type','text/html')] start_response(status,response_header) return [html]a2enmod wsgi
apachectl configtest
- systemctl reload apache2
nano /etc/apt/sources.list
✍ deb https://download.webmin.com/download/repository sarge contrib
cat jcameron-key.asc | gpg --dearmor >/etc/apt/trusted.gpg.d/jcameron-key.gpg
apt install apt-transport-https
apt update
apt install webmin
systemctl status webmin
ufw allow 10000
Webmin Installationshilfe oder bei Digital Ocean
Webmin Modul “certmgr” installiert
⚠️ der Downloadlink stimmt nicht in der Webmin-Oberfläche: “www...” muss mit “http://download.webmin.com/download/modules” ersetzt werden.
⚠ der Downloadlink stimmt nicht in der Webmin-Oberfläche: “www...” muss mit “http://download.webmin.com/download/modules” ersetzt werden
Snapshot ncubuntua20230204s001
- Datenbank astroneth mit Berechtigung erstellt:
CREATE DATABASE astroneth;
SELECT user FROM mysql.user;
CREATE USER 'holger'@'localhost' IDENTIFIED BY 'sicheresPasswort';
GRANT ALL PRIVILEGES ON *.* TO 'holger'@'localhost';
CREATE USER 'holast'@'localhost' IDENTIFIED BY 'sicheresPasswort';
GRANT ALL PRIVILEGES ON astroneth . * TO 'holast'@'localhost';
FLUSH PRIVILEGES;
- Tabellen über Webmin importiert
- Datenbank anwiki mit Berechtigung erstellt:
CREATE DATABASE anwiki;
SELECT user FROM mysql.user;
CREATE USER 'holwiki'@'localhost' IDENTIFIED BY 'sicheresPasswort';
GRANT ALL PRIVILEGES ON anwiki . * TO 'holwiki'@'localhost';
FLUSH PRIVILEGES;
- Tabellen über Webmin importiert
- Wiki kopiert und localsettings.php angepasst
- Virtual-Hosts-Sites astroneth (001-anhome.conf) und holgerneth (001-mediawiki.conf) erstellt
Snapshot ncubunua20230407s001
ToDo
- ✍️ ToDo: eigene Fehlerseiten
- ✍️ ToDo: fail2ban und SSH-Port prüfen
zurück zur ==> Hauptseite