Apache
Apache
04 [Quickstart] | DigitalOcean
NEW Join the DigitalOcean + DEV Hackathon. Build something awesome to end 2020.
TUTORIAL
By Kathleen Juell
Published on July 23, 2018 English
470.3k
Introduction
The Apache HTTP server is the most widely-used web server in the world. It provides many
powerful features, including dynamically loadable modules, robust media support, and
extensive integration with other popular software.
In this guide, we’ll explain how to install an Apache web server on your Ubuntu 18.04 server.
For a more detailed version of this tutorial, please refer to How To Install the Apache Web
Server on Ubuntu 18.04.
Prerequisites
Before you begin this guide, you should have the following:
An Ubuntu 18.04 server and a regular, non-root user with sudo privileges. Additionally, you
will need to enable a basic firewall to block non-essential ports. You can learn how to
configure a regular user account and set up a firewall for your server by following our initial
server setup guide for Ubuntu 18.04.
When you have an account available, log in as your non-root user to begin.
SCROLL TO TOP
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 1/12
24/12/2020 How To Install the Apache Web Server on Ubuntu 18.04 [Quickstart] | DigitalOcean
Output
Available applications:
Apache
Apache Full
Apache Secure
OpenSSH
Let’s enable the most restrictive profile that will still allow the traffic you’ve configured,
permitting traffic on port 80 (normal, unencrypted web traffic):
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 2/12
24/12/2020 How To Install the Apache Web Server on Ubuntu 18.04 [Quickstart] | DigitalOcean
Output
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Apache ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Apache (v6) ALLOW Anywhere (v6)
Output
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Tue 2018-04-24 20:14:39 UTC; 9min ago
Main PID: 2583 (apache2)
Tasks: 55 (limit: 1153)
CGroup: /system.slice/apache2.service
├─2583 /usr/sbin/apache2 -k start
├─2585 /usr/sbin/apache2 -k start
└─2586 /usr/sbin/apache2 -k start
Access the default Apache landing page to confirm that the software is running properly
through your IP address:
http:// your_server_ip
You should see the default Ubuntu 18.04 Apache web page:
SCROLL TO TOP
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 3/12
24/12/2020 How To Install the Apache Web Server on Ubuntu 18.04 [Quickstart] | DigitalOcean
SCROLL TO TOP
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 4/12
24/12/2020 How To Install the Apache Web Server on Ubuntu 18.04 [Quickstart] | DigitalOcean
The permissions of your web roots should be correct if you haven’t modified your unmask
value, but you can make sure by typing:
/var/www/your_domain/index.html
<html>
<head>
<title>Welcome to Your_domain !</title>
</head>
<body>
SCROLL TO TOP
<h1>Success! The your_domain virtual host is working!</h1>
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 5/12
24/12/2020 How To Install the Apache Web Server on Ubuntu 18.04 [Quickstart] | DigitalOcean
</body>
</html>
Paste in the following configuration block, updated for our new directory and domain name:
/etc/apache2/sites-available/your_domain.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName your_domain
ServerAlias your_domain
DocumentRoot /var/www/ your_domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 6/12
24/12/2020 How To Install the Apache Web Server on Ubuntu 18.04 [Quickstart] | DigitalOcean
Output
Syntax OK
Apache should now be serving your domain name. You can test this by navigating to
http:// your_domain , where you should see something like this:
Conclusion
Now that you have your web server installed, you have many options for the type of content
to serve and the technologies you want to use to create a richer experience.
If you’d like to build out a more complete application stack, check out this article on how to
configure a LAMP stack on Ubuntu 18.04.
Report an issue
Kathleen Juell
Developer @digitalocean/community SCROLL TO TOP
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 7/12
24/12/2020 How To Install the Apache Web Server on Ubuntu 18.04 [Quickstart] | DigitalOcean
RELATED
What is Apache?
Tutorial
Comments
4 Comments
Leave a comment...
Sign In to Comment
SCROLL TO TOP
skylarkrieger July 1, 2019
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 8/12
24/12/2020 How To Install the Apache Web Server on Ubuntu 18.04 [Quickstart] | DigitalOcean
I used this to set up a web server, walked away from my laptop. My laptop restarted when I was
0 away (blame Windows). Anyways, now I can no longer ssh into the web server I just set up. Any
troubleshoot?
Reply Report
ls -la /home/username/www
total 12
drwxr-xr-x 2 username username 4096 Jul 10 10:32 .
drwxr-xr-x 5 username username 4096 Jul 10 10:48 ..
-rwxr-xr-x 1 username username 11 Jul 10 10:32 index.html
Reply Report
0
You’re using users home directory and it’s forbidden for outsiders, your path should be
/var/www/your_domain
Reply Report
0 That’s a nice article. For non tech people check out EasyApacheServer
(https://github.com/realpvn/EasyApacheServer) it basically sets up everything for you, just ssh
to the server and run this script
Reply Report
SCROLL TO TOP
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 9/12
24/12/2020 How To Install the Apache Web Server on Ubuntu 18.04 [Quickstart] | DigitalOcean
SCROLL TO TOP
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 10/12
24/12/2020 How To Install the Apache Web Server on Ubuntu 18.04 [Quickstart] | DigitalOcean
BECOME A CONTRIBUTOR
DigitalOcean Products Virtual Machines Managed Databases Managed Kubernetes Block Storage
Object Storage Marketplace VPC Load Balancers
Learn More
Company
SCROLL TO TOP
About
L d hi
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 11/12
24/12/2020 How To Install the Apache Web Server on Ubuntu 18.04 [Quickstart] | DigitalOcean
Leadership
© 2020 DigitalOcean, LLC. All rights reserved. Blog
Careers
Partners
Referral Program
Press
Legal
Security & Trust Center
SCROLL TO TOP
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04-quickstart 12/12