Servereinrichtung
Servereinrichtung (mit Ubuntu und Apache)
Start Timeline
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ℹ im home-Verzeichnis von username
- 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
⚠️ Erst SSH erlauben, bevor die Firewall arbeitet...
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
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 . . .
- systemctl restart fail2ban
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 astroneth.eu,www.astroneth.eu,webmin.astroneth.eu
certbot renew –dry-run
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
Snapshot ncubunua20230204s001
-
- ✍️ ToDo: eigene Fehlerseiten
- ✍️ ToDo: fail2ban und port 40777 prüfen
zurück zur ==> Hauptseite