×

How to change the ApacheHTTP port in Linux

What is an Apache HTTP server in Linux?

When we talk about the most commonly used web servers, one of the web servers that cannot be missed is Apache. With the help of their device, users request web pages, and to serve those requests, web servers are used. Apache is one of them. The Apache HTTP server is flexible, stable, provides many outstanding features, and is a free open-source platform.

Features of the Apache HTTP server

  • Digital Certificate authentication and Password authentication are supported by it.
  • It has Loadable Dynamic Modules.
  • It hasMPMs (Multiple Request Processing Modes) including Threaded, Prefork, and Event-Based Async.
  • It can easily handle over 10K synchronous connections i.e., it is highly scalable.
  • It supports caching with reverse proxy.
  • Virtual servers are based on name and IP address.
  • Status can be viewed in real-time.
  • It is compatible with IPv6.
  • A separate module supports FTP (File Transfer Protocol).
  • It also supports Computer Gateway Interface (CGI).
  • You can rewrite the URL in this server.
  • Contents and headers can also be rewritten.
  • Dynamic Configuration.
  • User and his ongoing session can be tracked easily.
  • Generic Expression parser.

Performance of Apache HTTP server

Choice of Multiprocessing Modules (MPM) and configuration is important as Apache does not implement a single architecture; it provides a variety of MPMs to cope with the demands of every particular infrastructure, which permits it to execute in any of the process-basedmodes, whether it is an event-hybrid mode or a hybrid mode. Apache is designed in such a way that it can reduce latency and increase throughput, regardless of increasing requests, therefore it ensures reliable and consistent processing of requests in descent time-frames.

Development of the Apache HTTP server

The Apache HTTP server was created for the implementation of the HTTP web server. The aim was to create a commercial-grade, feature-rich, robust, and freely available source code.

Some key points of the Apache HTTP server

  • For incoming connections, the Apache web server is ordered to bind and listen to port 80.0. This is the default setting of the Apache web server.
  • A new statement has to be added to order the Apache webserver to listen and bind to web traffics on ports other than default web ports.
  • /etc/apache2/ports.conf is the configuration file that needs to be changed on a Debian/Ubuntu-based device and on RHEL/CentOS-based distributions, /etc/httpd/conf/httpd.conf configuration file has to be updated.

With a console text editor, open a file that is specific to your distribution and the new port statement has to be added to it as shown below:

# nano /etc/apache2/ports.conf   [On Debian/Ubuntu]
# nano /etc/httpd/conf/httpd.conf  [On RHEL/CentOS]

In this example, we are going to make the Apache HTTP server listen to connections on port 8081, which is not its default port. We have to make sure that we add the statement written below, after the command that instructs the web server to listen to connections on port 80.

Listen 8081
How to change the ApacheHTTP port in Linux

Changing Apache HTTP server port on Ubuntu and Debian

How to change the ApacheHTTP port in Linux

Changing Apache HTTP server port on RHEL and CentOS

After adding the above line, to initialize the binding process, now we have to create or change an Apache virtual host on Ubuntu/Debian-based distribution, and these changes should be specified to our own vhost needs.

     The default virtual host is directly altered in RHEL/CentOS distributions. In the example given below, we will alter the default virtual host of the web server and order the Apache HTTP server to listen to web traffic from port 80 to port 8081.

# nano /etc/apache2/sites-enabled/000-default.conf
How to change the ApacheHTTP port in Linux

Changing Apache HTTP server port on Virtual Host

Now, to bind the Apache HTTP server to the new port and apply the changes made, the daemon has to be restarted and the local network socket table has to be checked using the ss command.

# systemctl restart apache2
# netstat -tlpn| grep apache
# ss -tlpn| grep apache
How to change the ApacheHTTP port in Linux

Verifying the Apache HTTP server port

Apart from all these things, we have an alternative method, i.e., we can open a new tab on a browser and traverse to our server domain name or IP address on port 8081. The default page of the Apache HTTP Server should be displayed on the screen. And due to some reasons, you are not able to access the webpage, go back to the server console, and reassure that to allow the port traffic, proper firewall rules are set up.

http://server.ip:8081
How to change the ApacheHTTP port in Linux

The default page of the Apache HTTP server on Debian and Ubuntu



Related Topics

scp Command in Linux/Unix with Examples

The scp (secure copy) command in Linux is a command-line utility that is used to securely transfer files between two hosts over a network. It is similar to the cp...

4 minutes read.

Linux ls

The primary use case of the ls command is to list the content available in the directory. The default directory is the current directory of the user. The below screenshot...

5 minutes read.

addr2line Command in Linux with Examples

Use of addr2line Command The addr2line command is used to convert addresses to line numbers and file names. This command uses debugging info to check which line number and file name...

4 minutes read.

Difference Between Unix and Linux

Unix vs Linux Unix and Linux both have been of great use in changing the world of operating systems. Unix was among the very few operating systems which were programmed for...

4 minutes read.

chmod Command in Linux/Unix with Examples

The chmod command in Linux is a command-line utility that is used to change the permissions of files and directories. It stands for "change mode" and it is used to...

4 minutes read.

wc Command in Linux/Unix with Examples

The wc command in Linux is a command-line utility that is used to count the number of lines, words, and characters in a text file or standard input. The name...

4 minutes read.

gzip Command in Linux/Unix with Examples

The gzip command in Linux is used for compressing and decompressing files. It uses the Lempel-Ziv coding (LZ77) algorithm to compress files, which is known for its high compression ratio...

6 minutes read.

Linux mkdir | Linux Create Directory

The Linux mkdir command is very much similar to Windows’s "new folder" feature. This command is used in Linux os to create new directories. The command mkdir stands for "make...

1 minute read.

addgroup Command in Linux with Examples

What is the addgroup command? It is a command in Linux to create a new group using specified command lined and the system’s default values. How to add groups Adding a user group:...

4 minutes read.

sudo Command in Linux/Unix with Examples

The sudo command in Linux is used to run a command or set of commands with the privileges of another user, typically the root user. This allows users to perform...

3 minutes read.

find Command in Linux/Unix with Examples

The find command in Linux is a command-line utility that is used to search for files and directories in a file system. It is a versatile command that can be...

5 minutes read.

top Command in Linux/Unix with Examples

The 'top' command in Linux is a real-time system monitoring tool that displays information about the running processes and system resource usage. The command provides a dynamic, scrolling view of...

4 minutes read.

cat Command in Linux/Unix with Examples

The cat command in Linux is a command-line utility that is used to display the contents of a text file. It stands for "concatenate" and it is used to view...

4 minutes read.

Linux cd

Linux cd: As in GUI operating systems like Windows 10, we use the mouse to travel to various folders back and forth; similarly, we have the “cd” command in Linux...

4 minutes read.

mv Command in Linux/Unix with Examples

The 'mv' command in Linux is used to move or rename files and directories. The command stands for "move" and it allows you to move files and directories from one...

3 minutes read.

Top 20 Linux Commands

1) clear command clear is a standard operating system command which is used to clear the terminal screen. This command brings the command line on the top of the terminal. By pressing the...

10 minutes read.

Linux Commands List

Linux Commands List The Linux systems are filled with commands for several use cases. We have divided these commands into some of the most common implementations for a better understanding of...

2 minutes read.

Linux Absolute and Relative Path

The concept of the absolute and relative path is very simple. The names “relative path” and “absolute path” give us little understanding of the concept we are learning here. The...

1 minute read.

Linux SCP Command

SCP stands for secure copy protocol. It is a command-line application for copying files and directories safely between two places. Command-line utilities are programs that operate on a computer's command...

3 minutes read.

cd Command in Linux/Unix with Examples

The 'cd' command in Linux is used to change the current working directory. The command stands for "change directory" and it is used to navigate the file system on a...

3 minutes read.