Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Apache

How to Launch Your Website on a New VPS With LAMP, SFTP and DNS

By Freedom251 Team · · 11 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To launch a site on a new VPS, create an Ubuntu server with a non-root administrator, install Apache, MySQL and PHP, point your domain’s DNS records at the server’s public IPv4 address, upload the files with SFTP, and then enable HTTPS with Certbot. The reliable order is important: make the server reachable and secure first, configure the correct Apache virtual host, wait for DNS to resolve, and only then request a certificate.

This guide uses the current Ubuntu 24.04 LAMP workflow documented for DigitalOcean’s 2026 Marketplace image, while showing the manual commands so you can reproduce the setup on another Ubuntu VPS.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What LAMP provides

LAMP means Linux, Apache, MySQL and PHP. Linux is the operating-system layer supplied by the VPS; Apache accepts HTTP requests and serves files; MySQL stores application data; and PHP generates dynamic pages. As DigitalOcean’s 2026 tutorial puts it, a LAMP stack is a group of open-source software typically installed together to host dynamic websites and PHP web applications.

The stack is suitable for a PHP site, a content-management system, or a custom application that needs a relational database. Static HTML sites do not require MySQL or PHP, but installing the complete stack gives you room to add server-side functionality later.

Prepare the VPS before installing software

Choose the operating system and record the address

Create a VPS running Ubuntu 24.04 LTS and copy its public IPv4 address. You will use that address for initial browser tests, DNS A records and SSH/SFTP connections. A one-click LAMP image is faster because Apache, MySQL, PHP, Certbot and Fail2ban are preinstalled; a clean Ubuntu server gives you more control over package versions and configuration.

DigitalOcean’s 2026 LAMP Marketplace image lists Apache 2.4.58, MySQL 8.0.43, PHP 8.4.11, Fail2ban 1.0.2 and Certbot 2.9.0. Those versions describe that image at the time of documentation, not a promise that every Ubuntu VPS will install identical versions. Check the versions on your own server after installation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a non-root administrator

Log in once as the provider’s initial account, then create a named user with sudo privileges. Replace deploy with your chosen username.

adduser deploy
usermod -aG sudo deploy

Copy your SSH authorized key to the new account from your workstation, or use the provider’s key-injection option. Test a second SSH session as that user before closing the original root session:

ssh deploy@SERVER_IP

Use sudo for administration and avoid routine root login. SSH keys are preferable to passwords; if you disable password authentication, verify that key-based login works first so you do not lock yourself out.

Apply updates and establish the firewall

sudo apt update
sudo apt full-upgrade -y
sudo apt install -y ufw
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose

The current one-click image exposes SSH on port 22 (with rate limiting), HTTP on port 80 and HTTPS on port 443. Allow only ports your application needs; do not open MySQL’s port 3306 to the public internet for a normal single-server deployment.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Apache and verify the web server

Install and start Apache

sudo apt install -y apache2
sudo systemctl enable --now apache2
sudo systemctl status apache2 --no-pager

Open http://SERVER_IP in a browser. You should see Ubuntu’s Apache2 default page. This test proves that the VPS, firewall and web service can communicate before you introduce DNS or application files.

If the page does not load, check that the VPS has the expected public address, that the provider’s external firewall also permits TCP 80, and that Apache is listening:

sudo ss -tulpn | grep ':80'
sudo journalctl -u apache2 --since "10 minutes ago"

Install and harden MySQL

Install the database server

sudo apt install -y mysql-server
sudo systemctl enable --now mysql
sudo systemctl status mysql --no-pager

Run the supplied hardening routine

Ubuntu’s package installs MySQL locally. Run its interactive hardening command:

sudo mysql_secure_installation

Read each prompt rather than accepting an answer mechanically. The routine can remove anonymous accounts, disallow remote root login, remove the test database and reload privilege tables. These choices reduce exposure for a web server whose database should remain private.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a database and least-privilege application account

Do not configure your PHP application with MySQL’s administrative root account. Create a database and a user limited to that database. Use a long, unique password and substitute your own names.

sudo mysql
CREATE DATABASE site_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'site_app'@'localhost' IDENTIFIED BY 'replace-with-a-long-random-password';
GRANT ALL PRIVILEGES ON site_db.* TO 'site_app'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Keeping the account’s host as localhost prevents network logins from other machines. If your architecture genuinely requires a separate database host, design an allowlist and encrypted connection rather than broadly opening port 3306.

Install PHP and connect it to Apache and MySQL

Install the runtime and Apache module

sudo apt install -y php libapache2-mod-php php-mysql
php --version

The command displays the PHP version selected by Ubuntu’s repositories. The 2026 Marketplace image reports PHP 8.4.11, but repository updates can change the exact patch release. The libapache2-mod-php package lets Apache process PHP files, while php-mysql supplies MySQL connectivity.

Test PHP, then remove the test file

Create a temporary diagnostic page in the current default web root:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/info.php

Visit http://SERVER_IP/info.php. A PHP information page confirms that Apache is executing PHP rather than downloading the source. Delete it immediately after the check because it reveals loaded modules, paths and server settings:

sudo rm /var/www/html/info.php

Test the database connection through PHP

After you create the application database, place a short test script outside public access when possible, or remove it immediately after testing. A minimal mysqli check is:

<?php
$connection = new mysqli('localhost', 'site_app', 'replace-with-a-long-random-password', 'site_db');
if ($connection->connect_error) {
    http_response_code(500);
    exit('Database connection failed');
}
echo 'Database connection succeeded';
$connection->close();
?>

Do not leave credentials or a diagnostic endpoint in a publicly accessible directory. Delete the file once it returns the expected result.

Create a domain-specific document root

Choose ownership and permissions

A custom virtual host should not share the default site’s directory. Create a directory named for the domain:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo mkdir -p /var/www/example.com/public_html
sudo chown -R deploy: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 {} ;

Here, deploy can upload files and the www-data group can read them through Apache. If an application must write uploads or cache files, grant write access only to those specific directories; do not make the entire document root world-writable.

Create the Apache virtual host

Create /etc/apache2/sites-available/example.com.conf:

sudo nano /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html

    <Directory /var/www/example.com/public_html>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>

Replace both hostnames and the path with your real values. ServerName must match the domain you will request a certificate for. AllowOverride All is useful for applications that supply an .htaccess file; if your site does not need it, use a narrower setting.

Enable the site and reload Apache

sudo a2ensite example.com.conf
sudo a2enmod rewrite
sudo apache2ctl configtest
sudo systemctl reload apache2

The configuration test must report Syntax OK. If this is the only site on the VPS, disable the default host so its page cannot win virtual-host matching:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo a2dissite 000-default.conf
sudo systemctl reload apache2

Do not disable a host that serves another live domain. Before DNS is changed, you can test the new host locally with a header request:

curl -I -H 'Host: example.com' http://SERVER_IP

Upload your website with SFTP

Understand the web root

The current one-click image uses /var/www/html as its default web root. A custom virtual host such as the one above serves /var/www/example.com/public_html instead. Uploading to the wrong directory is a common reason for seeing the Apache default page after a successful transfer.

DigitalOcean’s documentation describes the general model: files placed in the web root can be served by the web server using SFTP or another transfer tool.

Connect from a graphical SFTP client

  1. Choose SFTP, not plain FTP.
  2. Enter the VPS public IPv4 address as the host, port 22, and the deploy username.
  3. Select your SSH private key when the client asks for authentication.
  4. Open /var/www/example.com/public_html as the remote directory.
  5. Upload the site’s entry file, assets and application directories while preserving the required folder structure.

If the client reports permission denied, confirm that you connected as deploy, inspect ownership with ls -la /var/www/example.com, and correct the directory rather than granting broad write permissions:

sudo chown -R deploy:www-data /var/www/example.com
sudo chmod 755 /var/www/example.com/public_html

Use the command-line SFTP client

sftp deploy@SERVER_IP
cd /var/www/example.com/public_html
put index.php
put -r assets
bye

For a larger deployment, upload to a temporary release directory, verify the files, and switch the document-root symlink during a maintenance window. That approach reduces the chance of visitors seeing a half-uploaded application, but the simple direct upload is adequate for a small site.

Point DNS at the VPS

Create the required A records

At the DNS provider, create two A records:

Hostname Type Value Purpose
@ or the apex domain (for example, example.com) A VPS public IPv4 address Serves the root domain
www A Same VPS public IPv4 address Serves www.example.com

Some DNS dashboards display the apex as @; others require the complete domain. Do not add the domain twice if the provider automatically appends it. Remove stale A records that point elsewhere, and check for an existing CNAME on www before creating a conflicting record.

Wait for and verify propagation

DNS changes are cached according to their TTL, so the old address can continue appearing for a while. Query both names:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
dig +short example.com A
dig +short www.example.com A

Proceed when both return the VPS address from the networks your visitors use. A local result can be cached; checking from a second network or a public DNS resolver helps distinguish propagation delay from a misconfigured record.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Enable HTTPS with Certbot

Meet the prerequisites

Certbot requires a registered domain and two DNS records: the apex and www hostnames must resolve to the server. Your Apache virtual host must contain the matching ServerName and alias. Keep ports 80 and 443 allowed while validation runs; the certificate authority commonly reaches the server over HTTP before Apache is configured to redirect.

Install and request the certificate

sudo apt install -y certbot python3-certbot-apache
sudo certbot --apache -d example.com -d www.example.com

Follow the prompts for an email address and terms. Certbot can edit the Apache configuration and offer an HTTP-to-HTTPS redirect. Review the proposed changes, then test both URLs in a browser. If you prefer to inspect the configuration first, request a certificate without automatic editing and add the redirect deliberately afterward.

Check renewal

sudo systemctl list-timers | grep certbot
sudo certbot renew --dry-run

The dry run verifies that automated renewal can complete. Do not remove port 80 after issuance if your selected validation method or renewal configuration still needs it; an HTTPS site can continue redirecting HTTP requests safely.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Validate the complete launch

  • Opening the VPS IP returns an Apache response before DNS is changed.
  • A temporary PHP page executes and has been removed.
  • A PHP database check connects with the dedicated application account, not MySQL root.
  • Both the apex and www names resolve to the VPS address.
  • The custom virtual host serves your files instead of the default Apache page.
  • HTTPS loads without certificate warnings, and HTTP follows the intended redirect.
  • SFTP can create and update files in the document root without making every file writable by all users.

When a request reaches the wrong site, inspect the active virtual hosts:

sudo apache2ctl -S

When PHP displays as source or downloads, verify that libapache2-mod-php is installed and restart Apache. For application errors, inspect the domain-specific log files under /var/log/apache2 before changing permissions.

Manual installation or a one-click LAMP image?

Decision factor Manual Ubuntu installation One-click LAMP image
Setup time Longer; you install and configure each service. Shorter; core services are preinstalled.
Package-version control High; you choose repositories and installation timing. Lower initially; versions are those shipped in the image and then managed through normal updates.
Initial security defaults You must create the firewall rules, harden MySQL and configure protections. The current image includes firewall defaults for SSH 22, HTTP 80 and HTTPS 443, plus Fail2ban and Certbot.
Database placement Usually local unless you design a separate service. Local by default, with an option to attach Managed MySQL.
Rollback Depends on your snapshots, backups and configuration management. Provider image snapshots can speed initial recovery, but application data still needs its own tested backups.
Ongoing responsibility You track every package, service and security setting. You still patch the operating system and application; the image reduces initial configuration work but does not eliminate administration.

Choose the image when a repeatable, quick baseline matters more than selecting every component yourself. Choose manual installation when you need a specific package layout, a custom security policy or a configuration that differs materially from the image defaults.

Keep the server maintainable after launch

Patch and monitor

Run regular updates during a maintenance window and review Apache, PHP and MySQL release notes for compatibility changes. Keep Fail2ban enabled if it is installed, and inspect its status along with system logs. Set up provider snapshots or another backup system, but also export the database and test restoring it; a snapshot that has never been restored is not a proven backup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Protect credentials and application data

Store database credentials outside publicly served files when your framework supports environment variables or a protected configuration directory. Keep private keys readable only by their owner, restrict administrative accounts, and never commit production passwords to a public repository.

Separate writable data

Uploads, cache directories and generated logs should be the only locations an application can write. Review permissions after deployments, especially when files were uploaded from a workstation that preserves unexpected modes. Least privilege limits the damage if a PHP dependency or upload handler is compromised.

Frequently Asked Questions

Can I host more than one domain on the same VPS?

Yes. Create a separate document-root directory and Apache virtual-host file for each domain, give each host its own ServerName and ServerAlias values, then obtain certificates for the names that resolve to that VPS.

Why do I still see the Apache default page after uploading my files?

The request is usually matching the default virtual host or the files were uploaded to /var/www/html while your custom host points elsewhere. Check apache2ctl -S, confirm the DocumentRoot, disable 000-default.conf only when it is not needed, and reload Apache.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is an A record required for IPv6 visitors?

An A record handles IPv4. If your VPS has a stable public IPv6 address and you want IPv6 access, add a correctly configured AAAA record as well; do not publish one that is not reachable and firewalled.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

ApacheCertbotDNSLAMPMySQLPHPServer SetupSFTPUbuntuVPS

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.