Installeer Debian 10 met Cinnamon Desktop, webserver en SSH server

 

Log in als root

open terminal en kijk of het hekje er staat.

Zo ja dan ben je root en hoef je niet meer eerst sudo te typen

root@vps#

sudo apt update

sudo apt upgrade

 

UFW:

sudo apt install ufw

sudo ufw status

sudo ufw enable

sudo ufw app list

sudo ufw allow SSH

sudo ufw allow 'WWW Full'

regel verwijderen doe je zo:

sudo ufw app list numbered

sudo ufw delete 3

sudo ufw reload

 

SSH:

Om onderstaande makkelijk te kunnen plakken in je console moet je root toestaan voor SSH

sudo nano /etc/ssh/sshd_config

PermitRootLogin yes

Reboot of reload SSH

Nu kan je vanaf je computer inloggen op je website met ssh als root

handig voor SFTP Drive en RDP door een SSH tunnel

SSH Tunnel met Putty:

In Putty:

Maak een SSH tunnel met port 1234 en destination localhost:3389

Open tunnel en log in.

RDP via SSH tunnel

Op server:

sudo apt install xfce4

sudo apt install xrdp

Op werkstation:

In RDP log je in met 127.0.0.1:1234 en servernaam\user

 

Apache:

sudo systemctl status apache2

sudo apache2ctl configtest

sudo systemctl reload apache2

sudo mkdir -p /var/www/your_domain

sudo chown -R $USER:$USER /var/www/your_domain

sudo chmod -R 755 /var/www/your_domain

nano /var/www/your_domain/index.html

 

<html>

<head>

<title>Welkom op mijn website.nl!</title>

</head>

<body>

<h1>Gelukt! Virtual host werkt!</h1>

</body>

</html>

 

hostname -I

sudo apt install curl

curl -4 icanhazip.com

 

check: http://your_server_ip

 

sudo systemctl restart apache2

sudo nano /etc/apache2/sites-available/security.conf

 

<VirtualHost *:80>

ServerAdmin admin@your_email_domain

ServerName your_domain

ServerAlias www.your_domain

DocumentRoot /var/www/your_domain

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

 

sudo a2ensite jouwdomeinnaam.conf

sudo a2dissite 000-default.conf

sudo apache2ctl configtest

 

HTTP2:

sudo a2dismod php7.3

sudo systemctl restart apache2

sudo a2dismod mpm_prefork

sudo a2enmod mpm_event

sudo systemctl restart apache2

sudo service php7.3-fpm restart

sudo a2enmod http2

sudo systemctl restart apache2

sudo a2enmod headers

sudo systemctl restart apache2

 

Security:

sudo apt install libapache2-mod-security2

sudo systemctl restart apache2

sudo nano /etc/apache2/conf-enabled/security.conf

 

ServerTokens Full

ServerSignature On

SecServerSignature "Bas"

TraceEnable Off

 

Expires header:

sudo a2enmod expires

sudo systemctl restart apache2

 

SSL:

sudo nano /etc/apt/sources.list

deb http://ftp.debian.org/debian buster-backports main

sudo apt update

sudo apt install python-certbot-apache -t buster-backports

sudo certbot --apache --rsa-key-size 4096 --must-staple --staple-ocsp -d securityheaders.nl -d vpn.computerbas.nl

sudo certbot renew --dry-run

 

PHP 7.3:

sudo apt install php7.3

sudo apt install php7.3-mysql

sudo apt install php7.3-zip

sudo apt install php7.3-fpm

sudo apt install php7.3-mbstring

sudo apt install php-curl

sudo apt install php7.3-curl

sudo a2enmod proxy_fcgi setenvif

sudo systemctl restart apache2

sudo a2enconf php7.3-fpm

sudo systemctl restart apache2

sudo a2enmod setenvif

sudo a2enmod headers

sudo a2enmod deflate

sudo a2enmod filter

sudo a2enmod expires

sudo a2enmod rewrite

sudo a2enmod include

 

docker:

 

sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common

 

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

 

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

 

apt-cache policy docker-ce

 

sudo apt update

 

sudo apt install docker-ce

 

sudo systemctl status docker

 

sudo docker run hello-world

 

Done!

 

 

Mailserver in docker:

 

sudo docker pull tvial/docker-mailserver:latest

 

curl -o setup.sh https://raw.githubusercontent.com/tomav/docker-mailserver/master/setup.sh; chmod a+x ./setup.sh

 

curl -o docker-compose.yml https://raw.githubusercontent.com/tomav/docker-mailserver/master/docker-compose.yml.dist

 

curl -o .env https://raw.githubusercontent.com/tomav/docker-mailserver/master/.env.dist

 

curl -o env-mailserver https://raw.githubusercontent.com/tomav/docker-mailserver/master/env-mailserver.dist

 

sudo apt install docker-compose

 

 

NextCloud op Docker:

 

sudo docker run --name mariadb -v mariadb:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=secret-pass -d mariadb

 

sudo docker ps

 

sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mariadb

 

sudo docker run --name nextcloud -v nextcloud:/var/www/cloud -d -p 8080:80 nextcloud

 

sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nextcloud

 

sudo docker ps

 

 

Remove:

 

docker rm nextcloud

docker rm docker-mailserver