Configure apache to listen on a port other than 80

I am using a centos server. I want to configure apache to listen on port 8079. I added the LISTEN 8079 directive to httpd.conf .
I opened port 8079 in iptables and restarted iptables. I even stopped the iptables service.

 "netstat -nal | grep 8079" shows "tcp 0 0 :::8079 :::* LISTEN" 

If I try to access http://localhost:8079 or http://myserver.com:8079 from this machine, I can access this page. BUT from any other machine I can’t access the site on any port other than 80. It works on port 80. On port 8079, this is not so.

What else do I need to configure?

+73
apache2 apache-config
15 Oct '10 at 9:15
source share
6 answers

This is a problem with the firewall. There was a hardware firewall that blocked access to almost all ports. (Disabling the software firewall / SELinux bla bla did not affect)

Then I looked at the open ports and used the open port.

If you encounter the same problem, run the following command

 sudo nmap -T Aggressive -A -v 127.0.0.1 -p 1-65000 

It will scan all open ports on your system. Any open port can be accessed externally.

Link : http://www.go2linux.org/which_service_or_program_is_listening_on_port

+19
20 Oct 2018-10-10
source share

In /etc/apache2/ports.conf change the port as

 Listen 8079 

Then go to / etc / apache 2 / sites-enabled / 000-default.conf

And change the first line as

 <VirtualHost *: 8079> 

Now restart

 sudo service apache2 restart 

Now Apache will listen on port 8079 and redirect to / var / www / html

+92
Sep 26 '14 at 16:53
source share

Open the httpd.conf file in a text editor. Find this line:

 Listen 80 

and change it

 Listen 8079 

After the change, save it and restart apache.

+63
Oct 15 '10 at 9:18
source share

It works for me on Centos

First: in /etc/httpd/conf/httpd.conf

add

 Listen 8079 

after

 Listen 80 

This will allow your server to listen on port 8079.

Second: go to your virtual host for ex. /etc/httpd/conf.d/vhost.conf

and add this code below

 <VirtualHost *:8079> DocumentRoot /var/www/html/api_folder ServerName example.com ServerAlias www.example.com ServerAdmin root@example.com ErrorLog logs/www.example.com-error_log CustomLog logs/www.example.com-access_log common </VirtualHost> 

This means that when you go to www.example.com:8079 redirect to

/ var / www / html / api_folder

But you need to restart the service first

sudo service httpd restart

+3
Dec 30 '15 at 20:42
source share

If you are using Apache on Windows :

  • Check the name of the Apache service with Win + R + services.msc + Enter (if it is not ApacheX.Y, it should have the name of the software that you use with apache, for example: "wampapache64");
  • Run the command line as Administrator (using Win + R + cmd + Enter is not enough);
  • Change to the Apache directory, for example: cd c:\wamp\bin\apache\apache2.4.9\bin ;
  • Make sure the configuration file is in order: httpd.exe -n "YourServiceName" -t (replace the service name with what you found in step 1);
  • Verify that the service is stopped: httpd.exe -k stop -n "YourServiceName"
  • Start with: httpd.exe -k start -n "YourServiceName"
  • If all goes well, there is no more problem, but if you get:

    AH00072: make_sock: failed to bind IP address: PORT_NUMBER

    AH00451: no listening jacks available, turning off

    If the port number is not the one you want to use, then open the Apache configuration file (for example, C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf open the code editor or text block, but not notepad ), it doesn’t read the new lines correctly) and replace the number in the line starting with Listen with the number of the desired port, save it and repeat step 6. If this is the one you wanted to use, then continue:

  • Check the PID of the process that uses this port, with Win + R + resmon + Enter , go to the Network tab and then Subtab ports ;
  • Kill him: taskkill /pid NUMBER /f ( /f forces him);
  • Confirm resmon to confirm that the port is free and repeat step 6.

This ensures that the Apache service is started properly, configuration in the virtual hosts configuration file , as indicated by sarul (for example: C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf ), is necessary. if you configure the file path and port change. If you change it again, be sure to restart the service: httpd.exe -k restart -n "YourServiceName" .

+2
Feb 04 '16 at 18:36
source share

For FC22 server

cd / etc / httpd / conf change httpd.conf [enter]

Edit: Listen 80 to: Listen to anynumber

Save file

systemctl restart httpd.service [enter] if necessary, open whatnumber in your router / firewall

+1
Aug 23 '15 at 7:18
source share



All Articles