A fresh Fast Hive VPS is a bare operating system - there is no web server on it until you install one. This guide takes you from a newly deployed server to a working website served over HTTPS, using Nginx, PHP-FPM, MariaDB and a free Let's Encrypt certificate. Commands are given for both Debian/Ubuntu and AlmaLinux/Rocky.
Step 1 - Install the stack
# Ubuntu / Debian
sudo apt update
sudo apt install -y nginx mariadb-server php-fpm php-mysql php-cli \
php-curl php-gd php-mbstring php-xml php-zip
# AlmaLinux / Rocky
sudo dnf install -y nginx mariadb-server php-fpm php-mysqlnd php-cli \
php-curl php-gd php-mbstring php-xml php-zip
Start the services and have them come back after a reboot:
sudo systemctl enable --now nginx mariadb php-fpm
systemctl status nginx --no-pager
Step 2 - Open the firewall
Your firewall should already be default-deny. Let web traffic through, and nothing else:
# ufw (Ubuntu / Debian)
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw status verbose
# firewalld (AlmaLinux / Rocky)
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Browse to your VPS IP address. You should see the default Nginx page. If you do not, the firewall or the service is the reason - fix that before continuing.
Step 3 - Secure the database
sudo mysql_secure_installation
Set a root password, remove anonymous users, disallow remote root login, and drop the test database. Then create a database and a user for your site:
sudo mysql
CREATE DATABASE mysite CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'mysite'@'localhost' IDENTIFIED BY 'a-long-generated-password';
GRANT ALL PRIVILEGES ON mysite.* TO 'mysite'@'localhost';
FLUSH PRIVILEGES;
EXIT;
0.0.0.0 and do not open port 3306 in the firewall. An internet-reachable database with a weak password is one of the most common ways a VPS is lost. If a remote application genuinely needs access, tunnel it over SSH or use private networking.Step 4 - Create the site directory
sudo mkdir -p /var/www/example.com/public
echo '<?php phpinfo();' | sudo tee /var/www/example.com/public/index.php
# Ubuntu/Debian run the web server as www-data; AlmaLinux/Rocky as nginx
sudo chown -R www-data:www-data /var/www/example.com
sudo find /var/www/example.com -type d -exec chmod 755 {} \;
sudo find /var/www/example.com -type f -exec chmod 644 {} \;
Step 5 - Configure the site
Create /etc/nginx/sites-available/example.com (Debian/Ubuntu) or /etc/nginx/conf.d/example.com.conf (AlmaLinux/Rocky):
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
root /var/www/example.com/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# Never serve dotfiles
location ~ /\. { deny all; }
}
The PHP-FPM socket path varies by distribution and version - confirm yours with ls /run/php/ and adjust. On Debian/Ubuntu, enable the site, then test and reload:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
nginx -t validates the configuration before you reload. Get into the habit - it turns a typo into a message instead of an outage.
Step 6 - Point your domain
Create an A record for the domain pointing at your VPS IP address, and one for www. DNS must resolve before the next step, because the certificate authority verifies control by reaching your domain.
nslookup example.com 8.8.8.8
Step 7 - Add HTTPS
# Ubuntu / Debian
sudo apt install -y certbot python3-certbot-nginx
# AlmaLinux / Rocky
sudo dnf install -y certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com
Certbot obtains the certificate, edits your Nginx configuration to serve HTTPS, and offers to redirect HTTP to HTTPS - accept that. It also installs a renewal timer. Confirm it works:
sudo certbot renew --dry-run
systemctl list-timers | grep certbot
Step 8 - Finish up
- Delete the phpinfo file.
sudo rm /var/www/example.com/public/index.php- it exposes a great deal about your server. - Upload your real site, or install your application.
- Set PHP limits appropriately in
/etc/php/*/fpm/php.ini-memory_limit,upload_max_filesize,post_max_size- then reload PHP-FPM. - Turn
display_errorsoff for production. - Take a snapshot now that the server is configured and working.
Apache instead of Nginx
If you prefer Apache, install apache2 (Debian/Ubuntu) or httpd (AlmaLinux/Rocky) in place of Nginx, use a virtual host rather than a server block, and run certbot --apache. Apache reads .htaccess files, which some applications expect; Nginx does not, and equivalent rules go in the server block instead.
Do not install both. They will fight over ports 80 and 443, and the second one to start simply fails.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
| Browser cannot connect at all | Firewall is closed or Nginx is not running. Check systemctl status nginx and your firewall rules. |
| Browser downloads the PHP file instead of running it | The location ~ \.php$ block is missing or the FPM socket path is wrong. Your source code is being served publicly - fix immediately. |
| 502 Bad Gateway | PHP-FPM is down or the socket path does not match. systemctl status php-fpm, then check ls /run/php/. |
| 403 Forbidden | Wrong ownership or permissions, or no index file. On AlmaLinux/Rocky, SELinux may also be blocking - check sudo ausearch -m avc -ts recent. |
| Certbot fails to issue | DNS does not resolve to this server yet, or port 80 is closed. Both must be true for validation. |
| Nginx will not reload after an edit | Run sudo nginx -t - it names the file and line of the syntax error. |
| Site works on the IP but not the domain | DNS has not propagated, or server_name does not match the hostname requested. |
| Where are the logs? | /var/log/nginx/error.log and journalctl -u php-fpm -n 50. Read them before guessing. |
Frequently asked questions
Nginx or Apache?
Nginx is lighter under concurrent load and is the common default. Choose Apache when your application depends on .htaccess and you would rather not translate those rules.
Can I host several sites on one VPS?
Yes - one server block per site, each with its own root directory, database and certificate. That is a normal reason to choose a VPS.
Should I install a control panel instead?
A panel handles vhosts, mail and certificates for you at the cost of some control and resources. If you want that experience, ordering cPanel with the VPS is the cleaner route than adding one afterwards.
Do I need to configure mail as well?
Running your own mail server is a substantial undertaking - deliverability, spam filtering, reputation. For most people, keeping mail on Fast Hive hosting or a dedicated mail provider and pointing the MX records there is the better answer.
How do I keep this patched?
Enable unattended security updates, and check periodically that they are actually running. On an unmanaged VPS nothing patches itself unless you set it up.
Will Fast Hive help if I break the web server?
Our engineers support the hypervisor, network and storage. For the stack you installed we will help you diagnose - reading logs and identifying what is failing - but the configuration is yours. See the VPS support scope article.
/var/log/nginx/error.log. Never paste your root password or private key.