menu

Tuesday 16 July 2019

How to change Apache default port to a custom port

How to change Apache default port to a custom port

If you have sudo permission you can do easily. The only you need to follow these steps-

1. Change Apache port Ubuntu

Edit /etc/apache2/ports.conf file,

$ sudo vi /etc/apache2/ports.conf

Find the following line:

Listen 80
Replace with a random number of your choice like- Listen 8080.


After the change server to accept connections on port 8080 on all interfaces..
If you want the connect perticular IP to network do this Listen 192.168.1.101:8090
If your server has multiple IP addresses or network interfaces.

Save and close the file.

In Ubuntu and Debian, you need to change the port number in 000-default.conf file.

$ sudo vi /etc/apache2/sites-enabled/000-default.conf


Find the following line and change the port number.

<VirtualHost *:8080>
Save and close the file.

Now required to restart apache service to take effect the changes.

$ sudo systemctl restart apache2

We can check the port settings:

$ sudo netstat -tulpn | grep :8080
Sample output:

tcp6       0      0 :::8090                 :::*                    LISTEN      2067/apache2

You can open the browser and enter the URL: http://IP-address:8000.

No comments:

Post a Comment