net2ftpTEST
English

Install net2ftp on your server

About 15 minutes on a Linux server with Apache, PHP and MySQL. You need shell access with sudo. First download the package and check its SHA-256.

1. Install PHP and its extensions

On Debian or Ubuntu:

sudo apt install apache2 libapache2-mod-php php php-curl php-zip php-mbstring php-mysql php-xml mariadb-server

The ftp, sodium and openssl extensions are built in there. On other systems, enable extension=ftp, curl, zip and sodium in php.ini. On Windows, also add the PHP folder (e.g. C:\PHP) to the system PATH and restart Windows, otherwise Apache can't load curl and sodium.

2. Unpack the files

sudo unzip net2ftp-v2.zip -d /var/www/
cd /var/www/net2ftp-v2
sudo chown -R www-data:www-data storage
sudo chmod 750 storage storage/tmp

Only the public/ folder may be reachable from the web. src/, config.php and storage/ must stay outside the web root.

3. Create the database

sudo mysql -e "CREATE DATABASE net2ftp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"
sudo mysql -e "CREATE USER 'net2ftp'@'localhost' IDENTIFIED BY 'choose-a-strong-password';
               GRANT SELECT, INSERT, UPDATE, DELETE ON net2ftp.* TO 'net2ftp'@'localhost'"
sudo mysql net2ftp < sql/schema.sql

4. Configure

cp config.sample.php config.php
php -r "echo base64_encode(random_bytes(32)), PHP_EOL;"                       # → 'secret_key'
php -r "echo password_hash('your-admin-password', PASSWORD_DEFAULT), PHP_EOL;"  # → 'admin_password_hash'
php bin/admin-2fa.php                                                         # → 'admin_totp_secret'
nano config.php

Set at least the database password, secret_key, admin_password_hash, admin_totp_secret (the two-factor code for the administration, scan the link with an authenticator app) and your details in the site section (they appear in the privacy policy and disclaimer). The defaults are made for a public installation: connections to private networks are blocked, and there are daily limits per visitor and per server. Review them in config.php.

5. Point Apache to the public folder

<VirtualHost *:443>
    ServerName files.example.com
    DocumentRoot /var/www/net2ftp-v2/public
    <Directory /var/www/net2ftp-v2/public>
        AllowOverride All
        Require all granted
    </Directory>
    SSLEngine on
    SSLCertificateFile    /etc/letsencrypt/live/files.example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/files.example.com/privkey.pem
</VirtualHost>

Always use HTTPS: people type server passwords into this site. A free certificate: sudo apt install certbot python3-certbot-apache && sudo certbot --apache.

6. Schedule the cleanup job

net2ftp deletes leftover temporary files, expired share links and old log entries by itself, once an hour. It is better to let cron do it, so that no visitor ever waits for it:

sudo crontab -u www-data -e
# add this line:
17 * * * *  php /var/www/net2ftp-v2/bin/cleanup.php --quiet

Then set 'housekeeping' => ['mode' => 'cron'] in config.php.

7. Check

Open https://files.example.com/admin.php, log in with your admin password and two-factor code, and open System. Everything should be OK; anything missing is explained there, with the fix. Then log in to a test server on the home page.

Upgrading

Unpack the new version next to the old one, copy config.php and the storage/ folder across, update the database, then switch the DocumentRoot:

mysql net2ftp < sql/upgrade-2.3.sql   # only when upgrading from 2.2
mysql net2ftp < sql/schema.sql

Add any new settings from config.sample.php to your config.php. The README in the package lists every setting.