How To Change Apache HTTP (TCP) Port In Linux?

A way to establish communications between two computers. It reliably delivers messages of any size in the order they are sent. This is a better protocol for our purposes.

And we can change also TCP port number.



$ netstat -tnlp

The options used in this command have the following meaning:

  • -t — Show TCP ports.
  • -n — Show numerical addresses instead of resolving hosts.
  • -l — Show only listening ports.
  • -p — Show the PID and name of the listener’s process. This information is shown only if you run the command as root or sudo user.

The output will look something like this:


Step 1-

Change the directory with the command of


Cd /var/www/html

This command is by default, we can just put website inside this directory.

· Here we have created a file with a gedit command


gedit index.html

· gedit is like a notepad

· and written some html code inside it.

· It is not necessary that we can write code only in Html

· We can also write in text


· Here I have created a small webpage written in html language.

· After saving the file, we go to our web browser and we enter our ip address and put our port number 80 there.


· Here we have replaced TCP (80 TO 8080) with a few steps.

· And here we can change some directory with the command cd .


cd /etc

· to go inside the directory.

ETC is a folder that contains all your system configuration files. Then why the name etc.


cd httpd/

to go inside the directory

· Because The server root will be located in /etc/httpd.

to go inside the directory


cd conf

· In the /etc/httpd/conf directory you will find the three basic Apache configuration file


Vim httpd.conf

to go inside the directory

· Vim is CLI text editor.

· Using this editor, we change the port number.

· When we use Vim editor we use two command

1. Press ‘I ’ because when press ‘i’ it give us power to insert

2. Press “button”=’esc’ then press colon(:)and last is wq (write and quit)

· Here we change listen port 80

· Now we changed listen 80 port number


systemctl restart httpd

· After changing the port number, we have to run the systemctl restart httpd command once

· Because after changing the port number with this command, we have to start the Apache webserver

Now our webserver is running on port number:

And with the help of these few steps, we can change the port number of our Appache webserver.




We believe in making future tech leaders by providing right education to them.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Fault tolerance patterns for remote calls

Python Malware: Persistence with Windows

Host file enumeration routine, locating possible entry points and payload areas.

AWS Lambda with Scala and GraalVM

Nutanix Data Pipelines and AI for Developers

Quick take on List Views (Deutsche Intro)

How to get started in CS, AI and ML (while staying sane and without going to university)

Kotlin Vs. Java: Which is Best for Developing Android Apps?

<img src=”Kotlin-vs-java-(1).png” alt=”Kotlin vs Java”>

Programming "Guessing Game" With Python- A Simple Python Project.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Future Techno India

Future Techno India

We believe in making future tech leaders by providing right education to them.

More from Medium

What are file test operators in Bash Scripting

What are file test operators in Bash Scripting

GitLab CD Pipeline for Linux package management

Log in to Linux Virtual Machine from windows

Bash scripting