How To Change Apache HTTP (TCP) Port In Linux?
What is Apache HTTP(TCP) Port ?
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.
Input:
Command
$ 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:
Output:
Step 1-
Change the directory with the command of
command
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
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
Input:
· 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.
Output:
· Here we have replaced TCP (80 TO 8080) with a few steps.
· And here we can change some directory with the command cd .
Command:
cd /etc
· to go inside the directory.
ETC is a folder that contains all your system configuration files. Then why the name etc.
command:
cd httpd/
to go inside the directory
· Because The server root will be located in /etc/httpd.
to go inside the directory
command:
cd conf
· In the /etc/httpd/conf directory you will find the three basic Apache configuration file
Command
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
Command
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.