Linux 3 - Setup of Debian Server

By Sheldon L Published at 2019-09-16 Updated at 2019-10-01


Part 1 - Must on a Server (not for serving as VPN)

# All in root
    su -

# Update and Upgrade: https://www.3cx.com/blog/voip-howto/os-security-updates-debian/  
    grep security /etc/apt/sources.list | tee /etc/apt/security.sources.list
    apt upgrade -o Dir::Etc::SourceList=/etc/apt/security.sources.list  # only secure
    apt update 
    apt upgrade

    # Repeat for check
    # To update one package:
    apt update && apt upgrade packagename
    # To find out the name of the package you have installed on your system:
    dpkg -l | more

# Installing utilities :
    apt install wget unzip links nmap telnet htop
    
# Configure users
    adduser username

    sudo passwd username

    usermod -aG sudo username
    # Add and Delet: https://linuxize.com/post/how-to-add-and-delete-users-on-debian-9/
    # Configuration:  /etc/group, /etc/shadow, /etc/passwd, /etc/sudoers

# Set Hostname of Server
    vi /etc/hostname

# Install and Configure Firewall
    apt update
    apt install ufw
    # List of all port
    lsof -i -P -n
    # List of all app that can be manipulated
    ufw app list
    # Configuration of ufw: https://www.linode.com/docs/security/firewalls/configure-firewall-with-ufw/
    ufw default allow outgoing
    ufw allow # ssh http mysql udp or # of port
    sudo ufw deny # ssh http mysql udp or # of port

    # Don't enable before allow Essential ports
    sudo ufw enable
    sudo ufw status

# Configure SSH: 
    ssh -V
    # /etc/ssh/sshd_config
        # 'Root Loin Permit No'
        # 'SSH Port'
    # Check ufw

# Install Apache HTTP Server: https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-debian-9
    apt update
    apt install apache2
    # /etc/apache2/ports.conf: Change Listen 80

    systemctl start apache2
    systemctl enable apache2
    systemctl status apache2
    hostname -I     # Get IP or HostName
    links ipadress
    # Check ufw
    # Refer to URL to Setting Up Virtual Hosts (Recommended)
    # Refer to URL to Getting Familiar with Important Apache Files and Directories

# Install MySQL: https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/
    cd /tmp
    wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
    dpkg -i mysql-apt-config_0.8.13-1_all.deb  # may need other dependency, install them
    apt-get update
    apt-get install mysql-server
    # May need some dependencies

    service mysql stop  
    systemctl disable mysql       # my VPS PAM is too small, only run when needed 
    # Check ufw
    
# Install PHP
    apt install php
    systemctl restart apache2
    # Verify PHP by creating following php script in the Apache document root directory
    echo -e "<?php\nphpinfo();\n?>"  > /var/www/html/phpinfo.php
    php /var/www/html/phpinfo.php
    links http://127.0.0.1/phpinfo.php

Part 2 - Optional

# Source and Kernel
    # /etc/apt/sources.list
    uname -r

# Install GCC

# Install Java

# Install Apache Tomcat a servlet container designed by Apache to run Java HTTP web server

# Installing Webmin a central system to configure various system configuration

# Install and Enable SELinux to secure

# Install Rootkit Hunter to check secure

# Install Linux Malware Detect

# Configure Cron Jobs

# Server Bandwidth Testing with Speedtest-cli

# Install Owncloud