How to change the port number of Apache(web server) – Command line option for Linux server

Hi, we all know the default port for the Apache web-server. The Apache is using the port 80 to communicate with world. We already discussed about, how do we change the Apache port in a cPanel based server, click here to Change the Apache port via command line in cpanel

Here I am explaining the way to change the Apache port on your Linux server. The port number is defined in the configuration file of the Apache web-server. Do follow the steps to change the Apache port from command line.
Apache configuration file:

# /etc/httpd/conf/httpd.conf

Step 1 : SSH to your server as root user.
Step 2 : Open the Apache configuration file with your favorite file editor.

# vi /etc/httpd/conf/httpd.conf

And change the Listen Address value to your new port number.


# grep Listen /etc/httpd/conf/httpd.conf
Listen 0.0.0.0:80
Listen [::]:80
SSL port
Listen 0.0.0.0:443
Listen [::]:443

Step 3 : Restart the apache service to take this change live.

# service httpd restart
Or
# /etc/init.d/httpd restart

That’s it, then try to access your website with the port which you have selected for the Apache.

 

Related:
1, How to change ftp port – cpanel
2, How to change the ssh port in Linux servers – Command line option
3, How to reset SSH port from WHM
4, How to change the apache port via command line in cpanel
5, How to change cpanel port through command line
6, Important cPanel service’s configuration file, path, service name, port – Command line view
7, How to change Direct admin’s default port number
8, Port number for Direct admin
9, What port is webmin using and configuring your firewall for webmin
10, Change SSH port of a server having Webmin
11, How to open alternate SMTP port 26 on Plesk server

,

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

One thought on “How to change the port number of Apache(web server) – Command line option for Linux server

  1. Essential in an environment where you may want to remotely reboot a Java System after maintenance without worrying about whether your server will come back online.

Leave a Reply

Your email address will not be published. Required fields are marked *