What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
To run Apache on a VPS, install the distribution package, verify that the service is listening, create a virtual-host file under the distribution’s configuration tree, point its DocumentRoot at your site, enable and reload it, then make sure DNS sends the hostname to the VPS. When something fails, start with Apache’s parsed virtual-host map and error log rather than guessing.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
What Apache does on a VPS
Apache HTTP Server is a package-managed web server whose behavior is controlled by text files and directives. A directive can apply globally or only inside a section such as <VirtualHost> or <Directory>; the section in which you place it changes which requests it affects. The DocumentRoot directive maps a URL path to the directory containing files for a site.
As an Amazon Associate I earn from qualifying purchases.
Free tools Windows power users keep installed
One-click scans. No signup required.
A VPS gives you administrative access, but it also leaves you responsible for the operating system, firewall, DNS, configuration syntax, permissions, updates and service health. Apache can serve static HTML directly or receive requests for an application through a proxy, while the same virtual-host and logging concepts remain in use.
Before installing: requirements and a first plan
- A VPS with shell access and administrative privileges (normally through
sudo). - A distribution-supported package manager and service manager.
- A public or otherwise reachable VPS address, with the intended HTTP and HTTPS ports permitted by both the operating-system firewall and the VPS provider’s network controls.
- A domain name whose DNS can be changed, unless you are doing local-only testing.
- A directory in which you will keep the site files, normally below
/var/wwwon Ubuntu.
Decide whether you need one site or several. A single site can use the default host while you learn the basics. Multiple domains normally use name-based virtual hosts, allowing several hostnames to share one IP address.
#1 Best Overall
Install Apache and confirm the first response
Ubuntu and Debian-family systems
Refresh package metadata and install the Apache package:
sudo apt update
sudo apt install apache2
Check the service with the system service manager:
sudo systemctl status apache2 --no-pager
If it is not running, inspect the status output and the error log before repeatedly restarting it. A successful installation does not prove that the VPS is reachable from the internet.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsRPM-based systems
RPM-based distributions use their own package and service naming conventions. Install the distribution’s httpd package with its documented package manager, then check the corresponding service unit (often named httpd). Do not copy Ubuntu enablement commands or paths blindly: configuration directories, helper utilities and default log names differ between distributions.
Test locally, then test from outside
From the VPS, request the local listener with an HTTP client or open the server address in a browser. A default Apache page confirms that the daemon can answer locally, not that DNS, firewalls or provider routing are correct.
Next, test the VPS address from another network. Confirm that the provider and the operating-system firewall allow the ports you intend to use. There is no universal firewall policy for every VPS image, so follow the rules and commands documented for your provider and distribution.
Understand the Apache configuration layout
On Ubuntu, the main configuration tree is /etc/apache2. Site definitions normally live in /etc/apache2/sites-available; enabling a site makes Apache include it in the active configuration. Modules, ports and global settings have their own files in the same tree.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #2
Keep site-specific directives in a site file rather than editing a generated or distribution-maintained default file. A directive outside a section can affect every host. The same directive inside <VirtualHost> affects requests routed to that host; a <Directory> section controls filesystem access for a path. Read the directive’s scope before moving it.
Configuration filenames and helper commands are distribution-specific. Ubuntu provides a2ensite and a2dissite; another distribution may expect a different include mechanism. Always validate with the local Apache binary after changes.
Create an Ubuntu virtual host step by step
1. Create the site directory and a test page
Use a separate directory for each site:
sudo mkdir -p /var/www/example
sudo tee /var/www/example/index.html > /dev/null <<'HTML'
<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Example</title></head>
<body><h1>example.com is working</h1></body>
</html>
HTML
Ensure the Apache worker can traverse the directory and read the files. If you change ownership or permissions, grant only the access required by your distribution’s Apache user and your deployment process; avoid making the entire tree world-writable.
2. Write the site definition
Create /etc/apache2/sites-available/example.conf with the hostname, web root and separate logs:
Recommended Free Tools
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/example-error.log
CustomLog ${APACHE_LOG_DIR}/example-access.log combined
</VirtualHost>
ServerName is the primary hostname. Add every additional hostname that should reach this site as a ServerAlias. Keep the DocumentRoot exact: a typo can produce a 404 or expose a different directory. Per-site logs make it easier to distinguish traffic when several hosts share one VPS.
3. Enable the file and apply it
sudo a2ensite example.conf
sudo apachectl -t
sudo systemctl reload apache2
apachectl -t must report a valid configuration before a reload. A reload applies configuration to new requests without the interruption associated with a full stop and start. Use a restart only when a change requires it or when the service manager and module documentation call for one:
sudo systemctl restart apache2.service
To disable a site on Ubuntu, run sudo a2dissite example.conf, validate again, and reload. Keep a known-good configuration available so that a failed edit can be reverted quickly.
DNS is part of virtual-host setup
Creating a <VirtualHost> does not create a DNS record. The domain and each alias must resolve to the VPS address before a remote browser can reach the intended host. Check the authoritative DNS provider and allow time for its published record to be visible according to its TTL.
For local-only testing, add a temporary hosts-file entry on the computer making the request, mapping the domain to the VPS address. This bypasses public DNS only for that machine; it does not publish the site and should be removed after testing.
Test the exact hostname, not just the IP address. A request sent to the bare IP has no matching domain name, so Apache may choose the first or default host for that address and port.
How Apache chooses a virtual host
Name-based virtual hosts can share one IP. Apache first considers the requested address and port, then compares the request hostname with ServerName and ServerAlias. If no name matches, the first host configured for that address and port can receive the request as the default.
This explains why a new domain may display an older website: the browser might be sending a different hostname, DNS might point elsewhere, or the intended host might not be the first valid match for that listener. An intentional default host is safer than allowing file order to decide accidentally.
Rank #4
After every virtual-host change, inspect Apache’s parsed view:
sudo apachectl -S
The output shows the addresses and ports Apache is listening on, the names associated with each host, and which host is considered default. Compare that output with the hostname in the browser and with the DNS answer for the domain.
Use a safe change-and-reload cycle
- Edit or create the relevant file under the active configuration tree.
- Run
sudo apachectl -t. Do not reload when it reports a syntax error. - Run
sudo apachectl -Swhen the change affects hostnames, addresses or ports. - Reload with
sudo systemctl reload apache2on Ubuntu, or the equivalent command for your distribution. - Check
sudo systemctl status apache2 --no-pagerand make a request to the exact hostname. - Watch the relevant error and access logs while reproducing the problem.
A command returning you to the shell is not proof that the service accepted the new configuration. The syntax test, service status and logs provide three separate checks.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Troubleshoot the wrong website
Confirm the requested hostname
Read the address in the browser and compare it character-for-character with ServerName and every ServerAlias. Differences such as an omitted www, a spelling variation or a request to an HTTPS listener instead of HTTP select a different host.
Inspect Apache’s host map
Run sudo apachectl -S. Verify that the intended hostname appears under the address and port receiving the request, and identify the default host for unmatched names. If the host is absent, the site may not be enabled, the file may be outside the active include tree, or the syntax may have prevented a reload.
Verify DNS independently
Resolve the domain from the client network and confirm that it returns the VPS address. If it returns an old address, a different provider, or no address, correct DNS before changing Apache. A hosts-file test can distinguish DNS trouble from Apache routing while you wait for the public record to update.
Best Value
Confirm that the request reached this VPS
Inspect the access log while making a request. If no new line appears, investigate DNS, routing, firewall rules, port selection or a proxy in front of the VPS. If a line appears under another site’s log, Apache received the request but matched a different virtual host.
Logs are the first diagnostic tool
Apache’s error log records what went wrong, when it happened and often the clue needed to fix it. Treat it as the starting point for syntax failures, permission denials, missing modules, 403 and 404 responses, application errors and proxy or upstream failures.
On Ubuntu, the default access log is /var/log/apache2/access.log, while the default error log is commonly /var/log/apache2/error.log. A site’s CustomLog and ErrorLog directives can send traffic and errors to per-site files instead. Check the path actually configured for the host rather than assuming every request is in the global file.
sudo systemctl status apache2 --no-pager
sudo tail -f /var/log/apache2/error.log
sudo tail -f /var/log/apache2/access.log
Correlate the timestamp, requested path and status code. A 403 usually calls for checking filesystem traversal and Apache access rules; a 404 calls for checking the URL and DocumentRoot; a 500 requires the application or module’s own error details as well as Apache’s entry. A failed reload normally leaves a precise syntax or module message in the service status or error output.
Common failure patterns and fixes
| Symptom | Likely area | What to check |
|---|---|---|
| Default page appears instead of your site | Host matching or enablement | Run apachectl -S; verify ServerName, aliases, enabled site and the first host for the address and port. |
| Browser cannot connect | DNS, routing or firewall | Resolve the domain, test the VPS address, and verify provider and operating-system rules for the intended port. |
| Reload fails | Configuration syntax or missing module | Run apachectl -t, read the error log and service status, then correct the named file or directive. |
| 403 Forbidden | Filesystem permissions or access rules | Check that Apache can traverse every parent directory and read the target file; inspect the error log for the denied path. |
| 404 Not Found | Wrong URL or document root | Compare the request path with files under the configured DocumentRoot and confirm the request reached the intended host. |
| Application returns 500 or proxy errors | Upstream application | Read Apache’s error entry, then check the application process, socket or port and its own logs. |
Choosing an Apache deployment approach
| Approach | When it fits | Operational difference |
|---|---|---|
| Ubuntu or Debian package | A conventional operator-managed VPS | Uses /etc/apache2, Ubuntu’s site helpers and the distribution service unit; updates come through the package manager. |
| RPM-based package | A VPS running an RPM-family distribution | Uses that distribution’s package names, configuration layout, enablement method and service commands; consult its package documentation. |
| Source installation | A controlled environment requiring a specific build or module set | You assume responsibility for install paths, upgrades, service integration, modules and log rotation instead of relying on distribution defaults. |
| One site | A simple static or early-stage deployment | Fewer host-matching decisions, but still requires a deliberate default host and correct DNS. |
| Multiple name-based sites | Several domains sharing one VPS IP | Each host needs accurate names, roots and logs; unmatched requests follow the first matching/default host. |
| Static files | HTML, CSS, JavaScript and downloadable assets | Apache reads files from DocumentRoot; permissions and cache behavior are the main local concerns. |
| Application behind a proxy | A separate process serves dynamic requests | Apache routes to an upstream service, so Apache and application logs must be read together. |
| Managed hosting | You do not want to administer the operating system | The provider controls much of the package, service, firewall and update workflow; the VPS-specific commands in this guide may not be available. |
Production readiness checklist
- Use a supported distribution and keep Apache and its modules updated through the normal package process.
- Set an explicit
ServerNameand intentional default host; do not rely on accidental file ordering. - Use separate document roots and logs for separate sites.
- Keep application code and writable upload areas narrower than the whole web root.
- Allow only the ports required by the deployment, using both provider and operating-system controls.
- Validate configuration before every reload and retain a rollback copy of the last known-good files.
- Monitor error and access logs, and arrange rotation so logs cannot consume the VPS disk.
- Test both the hostname and the IP behavior, including an unmatched hostname, before declaring the setup complete.
The practical diagnostic sequence
When a site fails, work from the outside in: resolve the hostname, test reachability to the VPS and port, confirm Apache’s service status, validate syntax, inspect apachectl -S, then read the error and access logs while reproducing the request. This order separates DNS and network failures from virtual-host routing, filesystem permissions and application problems, preventing unrelated configuration changes from obscuring the real cause.
Quick Recap
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.




