In this article, I will guide you on installing Apache HTTP web server or Apache Server in Ubuntu operating system. Using this guide, you can install Apache servers in different Ubuntu Operating systems like Ubuntu 16.04, Ubuntu 18.04, and Ubuntu 20.04.
Must Read: Install Apache Server On Debian
Installing Apache Server On Ubuntu
Step – 1. Update System:
Using the following command, you have to update your Ubuntu system before installing the Apache web server.
$ sudo apt update
Step – 2. Install Apache Server:
After update completion, you need to execute the following command to install the latest version of Apache Server.
$ sudo apt install apache2
Output:
root@PRONAY-PC:~# sudo apt install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
libjansson4 liblua5.2-0 ssl-cert
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom openssl-blacklist
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3
libaprutil1-ldap libjansson4 liblua5.2-0 ssl-cert
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 1865 kB of archives.
After this operation, 8080 kB of additional disk space will be used.
Do you want to continue? [Y/n]
When you execute the installing command, the server will prompt you to “Do you want to continue?” you have to type “Y” and hit enter on the keyboard.
If you are installing Apache Server on a cloud, it will install instantly, and if you are installing on a local machine, it will depend on your internet connection.
Step – 3. Check Apache Server Status:
After installing the Apache webserver, you have to perform one more step. In this step, you have to make sure that the HTTP server is running. So use the following command to check Apache server status.
$ sudo service apache2 status
Output:
root@PRONAY-PC:~# sudo service apache2 status
* apache2 is not running
root@PRONAY-PC:~#
When you execute the service status command and show “* apache2 is not running,” then you have to run one more command to start the service.
$ sudo /etc/init.d/apache2 start
Or
$ sudo systemctl apache2 start
After using the starting command for the Apache server, you have to re-execute the service status command.
$ sudo service apache2 status
Output:
root@PRONAY-PC:~# sudo service apache2 status
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-05-18 01:11:56 CST; 1 day 22h ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 20095 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Process: 30285 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
Main PID: 20099 (apache2)
Tasks: 6 (limit: 1148)
Memory: 31.5M
CGroup: /system.slice/apache2.service
├─20099 /usr/sbin/apache2 -k start
├─30293 /usr/sbin/apache2 -k start
├─30294 /usr/sbin/apache2 -k start
├─30295 /usr/sbin/apache2 -k start
├─30296 /usr/sbin/apache2 -k start
└─30297 /usr/sbin/apache2 -k start
May 18 01:11:56 iZrj9cvo9flaqach4whkb9Z systemd[1]: Starting The Apache HTTP Server...
May 18 01:11:56 iZrj9cvo9flaqach4whkb9Z apachectl[20095]: AH00558: apache2: Could not reliably determine the server's fu
May 18 01:11:56 iZrj9cvo9flaqach4whkb9Z systemd[1]: Started The Apache HTTP Server.
May 19 00:00:20 iZrj9cvo9flaqach4whkb9Z systemd[1]: Reloading The Apache HTTP Server.
May 19 00:00:20 iZrj9cvo9flaqach4whkb9Z apachectl[25136]: AH00558: apache2: Could not reliably determine the server's fu
May 19 00:00:20 iZrj9cvo9flaqach4whkb9Z systemd[1]: Reloaded The Apache HTTP Server.
May 20 00:00:20 iZrj9cvo9flaqach4whkb9Z systemd[1]: Reloading The Apache HTTP Server.
May 20 00:00:20 iZrj9cvo9flaqach4whkb9Z apachectl[30285]: AH00558: apache2: Could not reliably determine the server's fu
May 20 00:00:20 iZrj9cvo9flaqach4whkb9Z systemd[1]: Reloaded The Apache HTTP Server.
lines 1-26/26 (END)
If you get the green color active status shown in the output, that means your Apache server successfully runs. Also, you can check that is Apache is running or not using a web browser. You have to enter your server IP Address or using a local machine, then type localhost
.
How To Manage Apache Server On Ubuntu
After installing the Apache server on Ubuntu, you have to know how to manage the Apache HTTP server. I have mentioned some commands to restart, stop, and start the webserver. These commands will work with Debian or Ubuntu 14.04 or newer.
Must Read: How To Upgrade PHP 7.4 To PHP 8.0?
Restart Apache Server:
$ sudo /etc/init.d/apache2 restart
Or
$ sudo service apache2 restart
Or
$ sudo systemctl apache2 restart
Stop Apache Server:
$ sudo /etc/init.d/apache2 stop
Or
$ sudo service apache2 stop
Or
$ sudo systemctl apache2 stop
Start Apache Server:
$ sudo /etc/init.d/apache2 start
Or
$ sudo service apache2 start
Or
$ sudo systemctl apache2 start
FAQs About Apache Server On Ubuntu
What is Apache HTTP Server?
Apache HTTP Server, also called Apache, is a popular open-source, cross-platform supported web server software.
How to install Apache on Linux?
Apache is a cross-platform web server software, and you can install Apache HTTP server using a single command ( $sudo apt install apache2
) in Linux operating system.
How to configure Apache web server in Ubuntu step by step?
For configuring the Apache web server in Ubuntu, you have to execute a command ($ ls /etc/apache2/*
) and the terminal will show you all Apache mods. After that, you can use the “nano
” command to modify or configure the webserver.
Is Apache Server part of the LAMP Stack?
Yes, the Apache HTTP server is part of the LAMP stack. And in LAMP, “A” stands from Apache. LAMP stack is a complete package to run a full-fledged website on the internet.
Summary
Use the method that’s I have mentioned above to install the Apache HTTP server. You can install it in Ubuntu operating system or Debian operating system. You can use the same command lines in both operating systems. You already know that using an Apache web server, you can create a website or run CMS like WordPress or Joomla, etc.