VPS Website Hosting Setup

DNS, Apache, SSL, and FTP configuration


Complete guide for hosting a website on a self-managed VPS with a domain registered at Hostinger. Covers DNS configuration, Apache virtual hosts, Let’s Encrypt SSL via Certbot, and FTP access with vsftpd.

1. DNS Configuration (Hostinger)

1
In hPanel, go to Domains → Domain Portfolio → Manage next to your domain.
2
Navigate to DNS / Nameservers → Manage DNS Records.
3
Add an A record: set Name to your subdomain (e.g. unreal) and Points To to your VPS public IP.
4
Verify DNS propagation:
dig yourdomain.net +short
dig yourdomain.net @8.8.8.8 +short
dig yourdomain.net @1.1.1.1 +short
Tip: If your local machine still resolves to the old IP, flush your DNS cache. On Windows: ipconfig /flushdns. If your router caches DNS, switch your computer’s DNS to 1.1.1.1 or 8.8.8.8 under Settings → Network & Internet → DNS server assignment.

2. Apache Virtual Host

1
Create the site directory and set ownership:
sudo mkdir -p /var/www/yourdomain/public
sudo chown -R www-data:www-data /var/www/yourdomain
2
Create the virtual host configuration:
sudo nano /etc/apache2/sites-available/yourdomain.conf
<VirtualHost *:80> ServerName yourdomain DocumentRoot /var/www/yourdomain/public <Directory /var/www/yourdomain/public> AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/yourdomain-error.log CustomLog ${APACHE_LOG_DIR}/yourdomain-access.log combined </VirtualHost>
3
Enable the site and reload Apache:
sudo a2ensite yourdomain.conf
sudo systemctl reload apache2
4
Verify Apache is responding:
curl -H "Host: yourdomain" http://localhost

3. SSL Certificate (Let’s Encrypt)

1
Install Certbot:
sudo apt update
sudo apt install certbot python3-certbot-apache -y
2
Obtain and install the certificate. Choose yes when asked about HTTP → HTTPS redirect:
sudo certbot --apache -d yourdomain
3
Verify the certificate and auto-renewal timer:
sudo certbot certificates
sudo systemctl status certbot.timer
Note: Certbot automatically creates the SSL virtual host config and sets up a systemd timer for auto-renewal. No further action is needed.

4. FTP Server (vsftpd with TLS)

1
Install vsftpd and create a dedicated FTP user:
sudo apt install vsftpd -y
sudo adduser ftpuser
2
Set directory permissions. The chroot directory must not be writable by the FTP user:
sudo chown nobody:nogroup /var/www/yourdomain
sudo chown ftpuser:ftpuser /var/www/yourdomain/public
3
Back up and replace the vsftpd configuration:
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
sudo nano /etc/vsftpd.conf
listen=YES listen_ipv6=NO anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 chroot_local_user=YES allow_writeable_chroot=NO ssl_enable=YES rsa_cert_file=/etc/letsencrypt/live/yourdomain/fullchain.pem rsa_private_key_file=/etc/letsencrypt/live/yourdomain/privkey.pem force_local_data_ssl=YES force_local_logins_ssl=YES ssl_tlsv1=YES ssl_sslv2=NO ssl_sslv3=NO pasv_enable=YES pasv_min_port=40000 pasv_max_port=40100 userlist_enable=YES userlist_file=/etc/vsftpd.userlist userlist_deny=NO # Per-user config (for multiple sites) user_config_dir=/etc/vsftpd/user_conf
4
Create per-user configuration so each FTP user lands in their own site directory:
sudo mkdir -p /etc/vsftpd/user_conf
sudo nano /etc/vsftpd/user_conf/ftpuser
Contents of the per-user config file:
local_root=/var/www/yourdomain
5
Create the user list and open firewall ports:
echo "ftpuser" | sudo tee /etc/vsftpd.userlist

sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
sudo ufw allow 40000:40100/tcp
6
Start and enable vsftpd:
sudo systemctl restart vsftpd
sudo systemctl enable vsftpd
Troubleshooting: If vsftpd fails to start, check the error with sudo vsftpd /etc/vsftpd.conf which prints the specific config error. Older versions of vsftpd may not recognize ssl_tlsv1_2 — use ssl_tlsv1=YES instead.

5. FileZilla Connection

1
Open File → Site Manager → New Site in FileZilla.
2
Configure the connection:
Protocol: FTP Host: your server IP Encryption: Require explicit FTP over TLS Logon Type: Normal User: ftpuser Password: your password
3
Click Connect. Upload your site files into the public folder.