How to change the port number of Apache Web Server?

Default port to access the Apache is 80. Secure port for communicating with world for Apache is 443. Very frequently, we need to update the Apache port. Here is procedure to update the Apache port number on Linux server.

Steps -

1. SSH to your server. Please make sure, you have root access to server. Without root access, you can not proceed with it. 

2. Now, you will need to update the Apache configuration file. Apache configuration file is present at this location -

You can use any file editor with which you are comfortable to update the file  -
vi /etc/httpd/conf/httpd.conf

3. Search for the listen value in Apache configuration file. You can use blow command to find it -
grep Listen /etc/httpd/conf/httpd.conf

Output will be as follow -
Listen  ---------------> This for non SSL port
Listen [::]:80

Listen> This is for SSL port
Listen [::]:443

You can update the Listen value to the port number which you would like to update. 

4. Restart the Apache Service after updating the port number. You can use any of the below command to restart the service -
service httpd restart

/etc/init.d/httpd restart

That's it!

Was this answer helpful?

 Print this Article

Also Read

How to perform LAMP installation on CentOS?

LAMP stands for Linux, Apache, MySQL, and PHP. It is nothing but Linux operating system with...

Basic exim commands

1. REMOVE MAILS BY ID - /usr/sbin/exim -v -Mrm (MAIL ID HERE) 2. LIST QUEUED MAILS -...

Daily Useful Linux Commands

Finding the username from provided hosting service name - /script/whoowns domain_name Finding...

Disk Usage Useful Command

Note - You can replace /home with correct '/' drive on your server. 1. Checking the disk usage -...

How to backup and restore large MySQL databases using mysqldump?

1. Backup database:#mysqldump -u username -p[username_password] databasename >...