Click here for "Error Codes for Commercial Air Conditioners".(Japanese Version)

Debian11.5 Building a server

Debian11.5 Building a server

Debian11.5 ; OS Install

1.Debian11 OverviewIn this article, we will explain how to build a server with Debian, the basis of the user-friendly Linux distribution UBUNTU.The latest release is Debian 11.5 (codenamed "bullseye").Released on August 14, 2021 with an update (point release11.5) on September 10, 2022.2.Download Debian installation imageDebian11 download site https://www.debian.org/Access the above official website and download "debian-11.5.0-amd64-netinst.iso." which is convenient for setup in an environment connected to the Internet.(Fits on a single CD)NETINST allows you to download and install the necessary packages from the Internet, so you can use a smaller installer (approximately 391 MB for v11.5.0) than a full installer.Click through the following screens in order.
Debian11.5 Building a server

Debian11.5 ; WEB Server(Apache) Install

Web server Apache2 installationAllow http:80 and https:443 ports in UFW before installation# ufw allow http# ufw allow https# ufw reload1 Apache2 Installation and ConfigurationApache2 Install3. Apache2; Using Perl ScriptsEnable CGI to make Perl scripts available4 Apache2 : Using PHP Scripts①Install PHP# apt -y install php php-cgi libapache2-mod-php php-common php-pear php-mbstring5. Virtual Host SettingsCopy the default configuration file (file name is arbitrary, in this case vhost-yourdomain.conf as an example) and configure the virtual host
Debian11.5 Building a server

Debian11.5 ; SNORT2 , Tripwire Install

1.Install SNORT2Snort is an open source network intrusion detection system capable of performing real-time traffic analysis and packet logging on IP networks.It can perform "protocol analysis," "content search," and "matching," and can be used to detect a variety of attacks, including "buffer overflows," "stealth port scans," "CGI attacks," "SMB probes," "OS fingerprinting attempts," "semantic URL attacks," and "server message block probes.2.Install TripwireImplement a system to detect file tampering on Linux servers by crackers.This time, Tripwire, a host-based IDS (IDS=Intrusion Detection System), will be installed as the file tampering detection system.Tripwire creates a database of file status at the time of installation, and detects file additions/changes/deletions by comparing the database with the current status of the file.
Debian11.5 Building a server

Debian11.5 ; System Backup and Restore

1. System Backup1.1 Backup under /var/www/html① Create backup_all.sh script under /opt1.2 Mysql database backup①Create db_backup.sh script under /opt# vi /opt/db_backup.shdb_backup.sh script contents2. System Restore2.1 Restore backup files under HTML① Store HTML backup files used for backup in the "/ (root)" directorySelect the backup file with the latest timestamp (e.g. www_back_20220501.tar.gz)2.2 Restore MySQL database①Save DB backup file to any directory and extract data# cd /var/www/backup/db_bak
Debian11.5 Building a server

Debian11.5 ; Let's Encrypt WEB , Mail Server SSL

1. Obtain a certificate (Let's Encrypt)1.1 advance preparation①Enable mod_ssl# a2enmod ssl2. SSL/TLS (Let's Encrypt) configuration for Apache2①Edit Apache2 SSL-related configuration files3. SSL/TLS (Let's Encrypt) settings on the mail server3.1 Obtaining a certificate for the mail serverObtain a certificate for the mail server, but it cannot be obtained in the same way as above, so the following with the "--standalone" option fails.
Debian11.5 Building a server

Debian11.5 ; Initialization

1. Installing and configuring the vim editorDebian has "nano" as the default editor. nano is somewhat difficult to use, and there are few environments where it is used, so we will introduce the procedure for changing the editor to "vim".。1.1 Check vim packageDebian has vim installed by default, but it is a package called "vim-tiny", which is a less functional version. Let's check the installed vim package.Debian uses the "dpkg" command to check packages. The "-l" option displays a list of packages.Since the "dpkg" command as is will show all packages installed on the system, we will use the "grep" command to extract only those packages that contain the string "vim". Execute as follows
Debian11.5 Building a server

Debian11.5 ; MySQL8 , WordPress Install

1. Install MySQL 81. 1 InstallThe MySQL team provides the official MySQL PPA for Debian Linux. After downloading and installing the package on your Debian system, the PPA file will be added to your system. To enable the PPA, run the following command1.2. MySQL Server Security SettingsRun the tool mysql_secure_installation to configure security-related settings for the MySQL server.Once executed, several security settings are initiated in the form of questions. First, you will be asked if you want to use a plugin for password validation as follows2.Install WordPress2.1 Database CreationCreate a database for Word Press (for example, in this case, the database name is "wp_db", the user name is "wp_user", and the password is "?Y123456y")2.2 Wordpress Download and Installation①Download and Deployment
Debian11.5 Building a server

Debian11.5 ; SSH connection using public key cryptography

RSA SSH connection with authentication using public key cryptographyCreate public and private key pairsCreate a public/private key pair for a user connecting to a Linux server using OpenSSH.Use ssh-keygen to create the key pair.This time, we will create a key set using the RSA cipher used in the SSH protocol Version 2.The creation of a public/private key pair is performed with remote login user privileges (e.g., huong).If you do not specify the destination and file name, id_rsa and id_rsa.pub will be created in /home/huong/.ssh/. On the way, enter the password for the key.
Debian11.5 Building a server

Debian11.5 ; logwatch , Disk Usage Check Script

1. Introduce disk usage check script1.1 Scripting# cd /opt/script/# vi disk_capacity_check.shContents of disk_capacity_check.shConfigured to notify when disk usage exceeds 80%.2. Log analysis tool logwatch installed2.1 logwatch Install# apt -y install logwatch2.2 Edit logwatch configuration file
Debian11.5 Building a server

Debian11.5 ; Anti-virus(Clamav) 、Mail Server

1. Antivirus software Clamav installedInstall Clam AntiVirus, a free anti-virus software for Linux, as an anti-virus measure.By installing this anti-virus software, you can not only scan the entire server for viruses, but also scan incoming and outgoing mail for viruses if you build and configure a mail server.1.1 Install# apt install clamav clamav-daemon2. Mail server installationPostfix was developed as a Mail Transport Agent (MTA) to replace sendmail, and is a mail server that is highly compatible with sendmail, secure, easy to maintain, and fast.In addition, since Postfix only functions as an SMTP server for sending mail, the POP server Dovecot for receiving mail will be installed separately in the latter half.2.1 Postfix : Installation Configuration3 Applied ClamAV to mail server PostfixSet up Postfix and Clamav to work together to scan incoming and outgoing mail in real time.①Install Amavisd and Clamav Daemon and start Clamav Daemon
Debian11.5 Building a server

Debian11.5 ; NTP ,FTP Server Installation

1. Install NTP server# apt -y install chrony# vi /etc/chrony/chrony.conf# Line 8.:Comment the default settings and add the NTP server for your time zone.#pool 2.debian.pool.ntp.org iburstpool ntp.nict.jp iburst# Add to the last line (Range for which time synchronization is allowed)allow 192.168.11.0/242. Install FTP Server2.1 Install Vsftpd# apt install vsftpdFTP Port21 allowed# ufw allow ftp# ufw reload
Debian11.5 Building a server

Debian11.5 ; SSH , Firewall Setting

1. SSH Service Security SettingsThe SSH service allows the root user to log in by default, and since the root user already knows the user name and can log in to the server with administrative privileges once the password is known, we will deny this setting.2. Firewall SettingsSince Debian often uses software called "ufw" to configure firewalls, we will configure firewall settings using ufw.Since ufw is not installed when the OS is installed, the ufw package must be installed prior to configuration. The following is a procedure to configure minimal filter settings after installation.Filter rules to be set in ufw• All packets forwarded to the server are rejected• All packets sent from the server to the outside are allowed• The first port to allow is the port for SSH• Limit packets coming into the server