Table of Contents
- 1) Install Nginx and PHP 8.3
- 2) Create app directory
- 3) Download and extract Init Uploader (no SFTP)
- 4) Configure Init Uploader (CONFIGURATION section)
- 5) Set ownership and permissions
- 6) Tune PHP 8.3 for large uploads
- 7) Nginx server block for cdn.example.com
- 8) Enable HTTPS with Certbot
- 9) Verify the endpoint
- 10) Maintenance recommendations
1) Install Nginx and PHP 8.3
sudo apt update && sudo apt upgrade -y
sudo apt install nginx -y
# PHP 8.3 + common extensions (GD or Imagick, Fileinfo, cURL, Zip, XML, MBString)
sudo apt install php8.3-fpm php8.3-cli php8.3-common \
php8.3-gd php-imagick php8.3-mbstring php8.3-xml php8.3-zip php8.3-curl php8.3-fileinfo unzip -y
php -v
2) Create app directory
sudo mkdir -p /var/www/init-uploader
sudo chown -R $USER:$USER /var/www/init-uploader
3) Download and extract Init Uploader (no SFTP)
Use the official ZIP URL to install directly on the server.
cd /var/www/init-uploader
sudo wget -O init-uploader.zip "https://inithtml.com/releases/tools/init-uploader.zip?v=1.0.1"
sudo unzip -o init-uploader.zip
After extraction, the structure should be:
/var/www/init-uploader/
├─ init-uploader.php
└─ uploads/
4) Configure Init Uploader (CONFIGURATION section)
Edit constants in init-uploader.php to match your domain and security preferences.
sudo nano /var/www/init-uploader/init-uploader.php
Recommended demo settings:
// Authentication
define('API_KEY', 'supersecretapikey123');
define('SECRET_KEY', 'supersecrethmackey456');
define('USE_HMAC_AUTH', false);
define('HMAC_TIME_WINDOW', 300);
// Paths
define('UPLOAD_DIR', __DIR__ . '/uploads');
define('BASE_URL', 'https://cdn.example.com');
// Upload limits
define('MAX_FILE_SIZE', 200 * 1024 * 1024); // 200MB
define('ALLOWED_EXTENSIONS', ['jpg','jpeg','png','gif','webp']);
// Image validation
define('STRICT_IMAGE_VALIDATION', false);
// System
define('ENABLE_LOGGING', true);
define('REQUIRE_HTTPS', true);
5) Set ownership and permissions
Grant the web user (www-data) access to serve and write uploads.
sudo chown -R www-data:www-data /var/www/init-uploader
sudo find /var/www/init-uploader -type d -exec chmod 755 {} \;
sudo find /var/www/init-uploader -type f -exec chmod 644 {} \;
6) Tune PHP 8.3 for large uploads
sudo nano /etc/php/8.3/fpm/php.ini
Set generous limits:
upload_max_filesize = 512M
post_max_size = 512M
max_execution_time = 600
max_input_time = 600
memory_limit = 1024M
sudo systemctl restart php8.3-fpm
7) Nginx server block for cdn.example.com
sudo nano /etc/nginx/sites-available/cdn.example.com
server {
listen 80;
server_name cdn.example.com;
root /var/www/init-uploader;
index init-uploader.php index.php;
# Generous limits and timeouts for uploads
client_max_body_size 512M;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
access_log /var/log/nginx/init-uploader.access.log;
error_log /var/log/nginx/init-uploader.error.log;
location / {
try_files $uri $uri/ /init-uploader.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_read_timeout 600;
}
location ~ /\.ht {
deny all;
}
}
sudo ln -s /etc/nginx/sites-available/cdn.example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
8) Enable HTTPS with Certbot
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d cdn.example.com
sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer
9) Verify the endpoint
Visit https://cdn.example.com. A JSON error like “No files uploaded” confirms the endpoint is active.
Test upload via API key:
curl -X POST "https://cdn.example.com" \
-H "X-API-Key: supersecretapikey123" \
-F "file=@/path/to/test.jpg" \
-F "path=manga/demo"
10) Maintenance recommendations
- Rotate or clean
/var/www/init-uploader/upload.logregularly. - Keep
/var/www/init-uploader/uploadsowned bywww-data. - Switch
USE_HMAC_AUTHtotruefor stronger authentication in production. - Place a CDN in front of
/uploadsfor faster delivery and caching.
Comments