Click here for "Safe Air Conditioner Repair and Proper Freon Recovery".

Debian10 ; FTP server, Web server Apache

1. FTP server installation

1.1 Install vsftpd

# apt install vsftpd

FTP Port21 permission
# ufw allow ftp

Edit vsftpd configuration file

# vi /etc/vsftpd.conf
# Do not allow anonymous users to log in

# Allow login by local user account
# Allow the use of FTP commands to make changes to files
# Set the permission values to be applied to new files.
# Each digit indicates owner, group, and other, and the bit indicates rwx
# Change the user’s login directory to the user’s root directory.
# Users will no longer be able to access outside of the login directory
# Exclude users listed in vsftpd.chroot_list from the above restrictions
# Allow uploads by ASCII
# Allow downloading by ASCII
# Line 131: Uncomment (enable bulk transfer of entire directory)

Next, create a new vsftpd.chroot_list under /etc.
Add your Debian user name (e.g. debian-user) to this file.

# vi /etc/vsftpd.chroot_list

Finally, enable vsftpd and reboot

# systemctl restart vsftpd

1.2 Check the FTP connection.

Use FFFTP, a Windows FTP client, to check.
Open FFFTP and select Connect from the menu bar.

A window called “Host List” will open. Select a new host.

A window called “Host Settings” will open. Enter the following and press OK

1. host configuration name (any name)
2. Hostname (IP address in Debian)
3. User name (Debian user name) hoge
4. password ********

You will be returned to the Host List window. Press Connect.

A window called “Save Encryption Status” will open. Select Yes.

If you can see the Windows directory on the left and the Debian directory on the right, the connection is successful.
If you cannot connect, turn Passive mode on and off.

2. WEB server Apache2 installation

2.1 Apache2 Installation and Configuration

Open port 80 before installing Apache2.

# ufw allow http

Install Apache2

# apt -y install apache2

Basic Configuration of Apache2

# vi /etc/apache2/conf-enabled/security.conf
# Line 25: Change
ServerTokens  Prod

# vi /etc/apache2/mods-enabled/dir.conf

# Line 2: Check for file names that can be accessed only by directory name.
DirectoryIndex  index.html index.htm index.php

# vi /etc/apache2/apache2.conf

# Line 70: Server name added.
ServerName <Domain Name>
# Line 172: Change
AllowOverride ALL

# vi /etc/apache2/sites-available/000-default.conf
# Line 11: Change administrator address
# systemctl restart apache2

2.2 Apache2; using Perl scripts

Install and enable Perl.

# apt -y install perl

Enable the CGI module.
# a2enmod cgid
Enabling module cgid.
To activate the new configuration, you need to run:
systemctl restart apache2

Restarting Apache
# systemctl restart apache2

When the CGI module is enabled, the [/usr/lib/cgi-bin] directory will be allowed to execute CGI by default.

By creating and deploying the [/usr/lib/cgi-bin/index.cgi] script, you can access [http://(Apache2 server)/cgi-bin/index.cgi]. Note that this setting treats all files under [/usr/lib/cgi-bin] as CGI, so non-CGI files cannot be displayed.
Let’s create the following test script and see if it works.

Create a test script
# cat > /usr/lib/cgi-bin/sample_script <<‘EOF’
print “Content-type: text/html\n\n”;
print “CGI TEST\n”;

Grant permissions to script files.
# chmod 705 /usr/lib/cgi-bin/sample_script
operation check
# curl http://localhost/cgi-bin/sample_script
Hello CGI
In the rare case that you get a “curl: command not found” message
# apt install curl
check again

2.3 Apache2; using PHP scripts

Install PHP

# apt -y install php php-cgi libapache2-mod-php php-common php-pear php-mbstring

Configuring Apache2

# a2enconf php7.3-cgi
Enabling conf php7.3-cgi.
To activate the new configuration, you need to run:
systemctl reload apache2
# systemctl restart apache2

Editing the PHP configuration file

# vi /etc/php/7.3/apache2/php.ini
# Line 841: upload_max_filesize = 2M → upload_max_filesize = 200M
# Line 956: Uncomment and set time zone
date.timezone = “Asia/Tokyo”
# systemctl restart apache2

Create a PHP test page and check it works
Creating a test page

# vi /var/www/html/index.php
<div style=”width: 100%; font-size: 40px; font-weight: bold; text-align: center;”>
print “PHP Test Page”;

If you see a page like the following, you are good to go.

2.4 Virtual Host Configuration

Copy the default configuration file and configure the virtual host settings

# cd /etc/apache2/sites-available/
# cp 000-default.conf

Edit the configuration file

# vi
<VirtualHost *:80>
DocumentRoot /var/www/html/
CustomLog ${APACHE_LOG_DIR}/ combined

Disable the default configuration file by putting a symbolic link to it

# cd /etc/apache2/sites-available/
# a2ensite
# a2dissite 000-default.conf  Default disable
# systemctl restart apache2

Edit the hosts file

# vi /etc/hosts

Create directory

# mkdir /var/www/html/

Create a test page and check it works.

# vi /var/www/html/
<div style=”width: 100%; font-size: 40px; font-weight: bold; text-align: center;”>
Virtual Host Test Page