Recommended Free Tools
Install Apache on an Ubuntu Server with two commands: refresh Ubuntu’s package index, then install the apache2 package. When installation finishes, browse to the server’s IP address; the default Apache page confirms that the web server is installed and serving requests.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
This guide covers the complete first setup: opening the firewall safely, checking the service, locating the document root and configuration files, and creating a named virtual host for a custom domain.
| # | Preview | Product | Price | |
|---|---|---|---|---|
| 1 |
|
Our Knives Will Save Us: Dispatches from a White Mountain Apache Chef | $27.71 | Buy on Amazon |
| 2 |
|
Apache Cookbook: Solutions and Examples for Apache Administrators | $20.01 | Buy on Amazon |
| 3 |
|
Choctaw-Apache Foodways | $18.60 | Buy on Amazon |
| 4 |
|
Apache Cookbook | $23.99 | Buy on Amazon |
| 5 |
|
Apache TomEE Cookbook | $5.00 | Buy on Amazon |
As an Amazon Associate I earn from qualifying purchases.
Free tools Windows power users keep installed
One-click scans. No signup required.
What you need before installing Apache
The procedure assumes an Ubuntu Server that you can reach over SSH and an account allowed to run commands with sudo. You also need the server’s reachable IP address for the first browser test. If a firewall is active, its policy must permit the kind of web traffic you intend to serve.
- An Ubuntu Server installation with SSH access.
- An account with
sudoprivileges. - The server’s IP address.
- A plan for HTTP, HTTPS, or both if UFW is enabled.
Apache is installed from Ubuntu’s repositories. Refreshing package metadata first ensures that apt is working from the current index available to that server.
#1 Best Overall
Install Apache2 from Ubuntu’s repositories
-
Connect to the server over SSH.
ssh your-user@server-ipReplace
your-userandserver-ipwith the account and address for your server. -
Refresh the package index.
sudo apt update -
Install Ubuntu’s Apache package.
sudo apt install apache2Accept the package installation prompt when
aptasks for confirmation. The package is Ubuntu’s Apache2 build and includes the service and its standard configuration layout.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 & 11Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Canonical’s Ubuntu documentation describes the sequence this way: “To install Apache2, first refresh the package index, then install the package.” Do not skip apt update merely because the server was installed recently; package indexes can become stale independently of the operating-system installation date.
Verify that Apache is installed and serving requests
Check the systemd service
Use systemd to inspect the Apache service after installation:
sudo systemctl status apache2.service
The status view shows whether the service is active and includes recent log messages. If it is not running, start it with:
sudo systemctl start apache2.service
To make Apache start automatically when Ubuntu boots, enable the service:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →sudo systemctl enable apache2.service
Installation normally starts the service, but checking explicitly distinguishes a completed package install from a server that is actually listening for requests.
Open the default page
From a computer that can reach the server, enter its IP address in a browser, for example http://203.0.113.10/. Ubuntu’s tutorial says that entering the web server’s IP address and seeing the default Apache page confirms that the required packages are installed and the server is serving requests.
If the browser displays the default page, Apache is responding through the default site and the default document root is available. A browser timeout, connection refusal, or an unexpected site requires the checks in the troubleshooting section rather than a second installation attempt.
Allow web traffic through Ubuntu’s firewall
UFW is Ubuntu’s default firewall configuration tool. A running Apache service can still be unreachable when the firewall blocks its listening traffic. Before changing policy, preview an HTTP rule without applying it:
sudo ufw --dry-run allow http
The dry run lets you inspect the rule that would be created. If HTTP is appropriate for this server’s exposure, apply the corresponding policy:
sudo ufw allow http
For a site intended to receive encrypted web traffic, apply the HTTPS policy as well:
sudo ufw allow https
Choose the exposure that matches the service you are actually publishing. HTTP and HTTPS are separate firewall policies; previewing a rule does not open the port, while the non-dry-run command changes UFW’s active policy. If UFW is not active, these commands are not required for local Apache operation, but another network firewall or cloud security policy may still control reachability.
Know Apache’s Ubuntu file layout
Ubuntu organizes Apache below /etc/apache2/. This differs from distributions that commonly center their configuration on an httpd.conf file. On modern Ubuntu releases, apache2.conf is the main configuration file.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesRank #3
| Path | Purpose |
|---|---|
/var/www/html |
Default document root. Files placed here are served by Ubuntu’s default site. |
/etc/apache2/apache2.conf |
Main Apache configuration file used by Ubuntu’s layout. |
/etc/apache2/ports.conf |
Controls the ports on which Apache listens. |
/etc/apache2/sites-available/ |
Stores virtual-host definition files, whether or not they are currently enabled. |
/etc/apache2/sites-enabled/ |
Contains links for the site definitions Apache should load. |
The separation between sites-available and sites-enabled lets you keep a site definition on disk while deciding whether Apache should load it. Use the Apache helper commands to change that enabled set instead of manually editing links.
Find the default document root
The default site serves content from /var/www/html. To test it without changing the site definition, create or edit an HTML file in that directory, then request the server’s IP address again. The URL path maps beneath the document root: a file named index.html is the usual page returned for the root path.
Keep custom sites in their own document-root directories when you move beyond a single site. This prevents files for unrelated domains from being mixed in the default directory and makes each virtual-host definition easier to understand.
Default site or named virtual hosts?
A single default site is enough when one server address should always return one website. Named virtual hosts are the appropriate structure when several domains share one Apache instance or when you want an explicit mapping between a domain and a directory.
| Decision point | Default site | Named virtual host |
|---|---|---|
| Configuration isolation | Uses the existing default site definition and the shared default document root. | Uses a separate file in sites-available for each site. |
| Domain routing | Primarily serves the default response for the address. | Routes requests using ServerName and, when needed, ServerAlias. |
| Document root | /var/www/html. |
A DocumentRoot chosen for that site, such as /var/www/mynewsite. |
| Applying changes | Changes to the site configuration require a reload or restart. | Enabling, disabling, or editing the host also requires a reload or restart. |
Create an Apache virtual host on Ubuntu
1. Create the site’s document directory
Choose a directory that will contain the files for the new site. The path must match the DocumentRoot in the virtual-host file. For the example below, the directory is /var/www/mynewsite:
sudo mkdir -p /var/www/mynewsite
Add the site’s HTML files to that directory. A minimal test page can be created with an editor, for example:
sudo nano /var/www/mynewsite/index.html
Save a simple page, then close the editor. The exact page content is not important for the routing test; a distinctive heading makes it clear that Apache selected the new document root rather than the default one.
Rank #4
2. Write a site definition in sites-available
Create a file whose name identifies the site:
sudo nano /etc/apache2/sites-available/mynewsite.conf
Set a ServerName that matches the domain clients will request and a DocumentRoot that points to the directory you created:
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/mynewsite
</VirtualHost>
Replace example.com with the domain assigned to your site and replace the document-root path if you selected another directory. ServerAlias is optional; include it only for additional names that should reach the same site. The host declaration above describes HTTP on port 80. Your DNS or local name-resolution setup must point the name to this server before a normal domain request can reach it.
3. Enable the virtual host
Enabling a site creates the enabled-site link that Ubuntu’s Apache layout expects:
sudo a2ensite mynewsite
The argument corresponds to the site definition’s name. If the file is mynewsite.conf, use mynewsite with a2ensite, as shown.
4. Apply the configuration
Restart Apache after enabling the site:
sudo systemctl restart apache2.service
A reload can be used when you want Apache to reread configuration without a full process restart:
sudo systemctl reload apache2.service
If a change does not take effect after a reload, use the documented restart command and then check the service status. Always make one configuration change at a time while setting up a new host so that a failure can be traced to the file you just edited.
5. Test the named site
Request the configured domain in a browser. The distinctive page in /var/www/mynewsite should appear. If the server’s IP still shows the default page, the request may not contain the Host name required for virtual-host selection, or the new site may not be enabled. Test with the domain that matches ServerName or one of its aliases.
Best Value
Disable a virtual host while troubleshooting
To stop Apache from loading a site definition without deleting the file, disable it with:
sudo a2dissite mynewsite
sudo systemctl restart apache2.service
The file remains in /etc/apache2/sites-available/, so you can correct it and enable it again later:
sudo a2ensite mynewsite
sudo systemctl restart apache2.service
This is useful when a newly added host appears to interfere with the default site or another known-good host. Keep the disable and restart together so the running Apache process reflects the enabled-site directory.
Troubleshoot the most common installation failures
The package command cannot refresh its index
If sudo apt update reports repository or connectivity errors, resolve those errors before retrying sudo apt install apache2. The installation command depends on package metadata and repository access; repeatedly running the install command does not repair a failed update.
The service is installed but not running
Run:
sudo systemctl status apache2.service
Read the recent status output, then try:
sudo systemctl start apache2.service
If it stops again, make a note of the message shown by systemd before changing files. A configuration mistake introduced during virtual-host setup should be isolated by disabling the new site and restarting Apache.
The browser times out
First distinguish a service problem from a network-policy problem. Check the Apache service locally, then review UFW. Preview the HTTP rule with:
sudo ufw --dry-run allow http
If the policy is appropriate, apply it with sudo ufw allow http. For encrypted traffic, apply the HTTPS policy separately. A browser outside the server’s network may also be subject to an upstream firewall or cloud security rule that is not controlled by Apache.
The browser shows the wrong site
Confirm that the request uses the domain in ServerName or ServerAlias, that the site was enabled with a2ensite, and that Apache was reloaded or restarted afterward. Check the DocumentRoot spelling and place a clearly identifiable test file in that directory. If necessary, disable the new site with a2dissite and restart to return to the known default configuration.
You edited the wrong configuration location
On Ubuntu, site definitions belong in /etc/apache2/sites-available/ and enabled definitions appear in /etc/apache2/sites-enabled/. Do not assume that a distribution using a historical httpd.conf-centric layout has the same paths. For Ubuntu, inspect apache2.conf, ports.conf, and the site directories under /etc/apache2/.
A repeatable setup checklist
- Connect to the Ubuntu Server over SSH.
- Run
sudo apt update. - Run
sudo apt install apache2. - Check
sudo systemctl status apache2.service. - Open the server IP address and confirm the default Apache page.
- If UFW is active, preview and then apply the HTTP or HTTPS policy required by the site.
- For a custom domain, create a document directory and a file in
/etc/apache2/sites-available/. - Set
ServerNameandDocumentRoot, then enable the file withsudo a2ensite mynewsite. - Reload or restart Apache and request the configured domain.
- If the host causes problems, disable it with
sudo a2dissite mynewsiteand restart while you correct the definition.
What a successful installation looks like
A basic installation is complete when the apache2 package is installed, the Apache service is active, and a browser can retrieve Ubuntu’s default page from the server’s IP address. A named-site installation adds three more checks: its file is stored under sites-available, it is enabled in sites-enabled through a2ensite, and a request using the configured name returns content from the declared DocumentRoot.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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.

