Apache2 Web Server



  • Once this is complete, it’s time to install your new Apache web server: sudo apt-get install apache2 -y Apache is the main piece of software you need to serve webpages to client PCs. STEP-04: Add PHP and MySQL (optional) Many websites use content management systems, such as WordPress.
  • The Apache HTTP Server Project.

Apache is part of the popular LAMP (Linux, Apache, MySQL, PHP) stack of software. It is included with the latest version of Ubuntu 18.04 by default.

HTTPD - Apache2 Web Server. Apache is the most commonly used Web server on Linux systems. Web servers are used to serve Web pages requested by client computers. Clients typically request and view Web pages using Web browser applications such as Firefox, Opera, Chromium, or Internet Explorer.

This guide will show you how to start, stop, and restart Apache service on Ubuntu using the terminal.

  • Access to a user account with sudo or root privileges
  • An installed and configured Apache installation
  • The apt package manager, included by default
  • A command-line/terminal window (Ctrl-Alt-T)

For Ubuntu users with versions 16.04 and 18.04 and Debian 9.x users, use the following commands in the terminal window to start Apache:

Check status to see whether Apache is enabled with the command:

If it is running, it should display the message active (running) as in the image below.

Use the following commands in the terminal window to stop Apache:

Check status to see whether Apache is disabled with the command:

If it has stopped running, it should display the message inactive (dead) as in the image below.

To restartApache use the command:

If Apache was previously disabled, a statuscheck will show that it is up and running again.

For Ubuntu and Debian users with an older version, use the following commands in the terminal window to start Apache:

or

Check status to see whether Apache is enabled with the command:

or

It should display the message active (running).

To stop Apache use the following command:

or

Check status to see whether Apache is disabled with the command:

It should display the message inactive (dead) as in the image below.

Apache web server windows

Note: The restart command can take several moments to complete, depending on the complexity of your server configuration. If you’re running a large or complex server configuration, this can cause disruptions for users who rely on the server.

Starting, stopping and restarting the Apache service on Ubuntu is straightforward. Knowing how to do these basic tasks from the terminal line makes the task faster and easier.

Next you should also read

This guide will help you install the Apache web server on an Ubuntu Linux 18.04 operating system.Ubuntu…

ModSecurity is an Open-source firewall application for Apache. Learn how to Setup & Configure ModSecurity on…

Configure Apache Web Server Ubuntu

In this SIMPLE Updated Tutorial Learn How to restart, start, & stop Apache web server on the CentOS 7 Linux…

MySQL is an open-source relational database server tool for Linux operating systems. It is widely used in…

The Apache HTTP Server (commonly referred to simply as Apache), is a free and open-source web server software brought to you by the Apache Software Foundation. Apache has been around for more than 2 decades and is considered beginner-friendly.

Related Read: How to Host a Website on NGINX Web Server

In this tutorial, you will learn how to install an Apache webserver to host a simple HTML website running on a Linux platform.

Install Apache Web Server in Linux

On Ubuntu Linux and other Debian-based distributions such as Linux Mint, Apache can be installed with the following command.

On Red Hat Enterprise Linux and related distributions such as CentOS, Fedora, and Oracle Linux, Apache can be installed with the following command.

Apache Web Server Download

On Ubuntu Linux and other Debian-based distributions, you can start and check the status of the Apache webserver by running the commands below.

On Red Hat Enterprise Linux and related distributions, run the following commands to start and check the status of Apache.

Apache2 Web Server

Once you have confirmed that Apache is active, open a web browser and enter the IP address of your Linux server. You may also enter localhost in place of your server IP.

You should see a test page that confirms that Apache is up and running properly.

Host a Simple HTML Website on Apache

After you have confirmed that Apache is working properly, you are now ready to add your website content. On Apache, the default location where publicly accessible web content is stored in /var/www/html. This is commonly referred to as the website root.

The first page that is loaded when users visit your website is called the index page. Let us create one as follows.

Nxp sound cards & media devices driver. Firstly, change into the website root with the command below.

Apache2 Web Server Ubuntu

On Ubuntu Linux, run the command below to rename the default index page file.

On Red Hat, there is nothing to rename here as the default index page file is not stored in this location.

Next, create a new index file with:

Copy and paste the sample HTML code below into the open text editor.

Save and close the index.html file.

Now, go back to your web browser and refresh the page. You should see your new website as shown in the image below.

Manage Apache Web Server in Linux

As we wrap up this tutorial, let us highlight some basic commands for managing Apache in addition to the ones that we have already used. As you may have noticed, the Apache web service is referred to as apache2 on Ubuntu while it is called httpd on Red Hat Linux.

To configure Apache to automatically start when the Linux server is rebooted, run:

To disable automatic starting of Apache when the Linux server is rebooted, run:

To restart Apache, run:

Apache Web Server Vs Tomcat

To stop Apache, run:

Conclusion

Apache Browser

In this tutorial, we have described how to install Apache on Ubuntu Linux as well as Red Hat Linux. We also showed you how to replace the default Apache web page with your own content.