Unable to change Apache http server port in unix
I downloaded Apache HTTP server, compiled it and installed it in a unix box.
I tried to start my Apache HTTP server in unix but got the below error so I thought of changing the port.
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
I tried to change the listening port for my Apache HTTP server in UNIX by modifying the httpd.conf file (present under conf directory) but this doesn't seem to have any effect when I restart my server.
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 82
I tried changing the port number to a value greater than 1024 (non privileged port numbers) but I am getting the same error as above(error still list port 80).
I am using httpd for starting the server. I even tried starting using the below command but I am still getting the same error..
apachectl -f ./conf/httpd.conf
Am I missing something?
Solution 1:
When you say you downloaded Apache and installed it on a "UNIX" box, what Operating System are you actually running? Are you running Linux? Solaris? FreeBSD? OpenBSD? Etc.?
Further, whatever system you are running should likely have Apache as a package to install from its package management utility.
Also, apachectl shouldn't likely take a configuration parameter. Can you try instead running...
# httpd -f ./conf/httpd.conf
Probably better if you use the full path and not relative just to make sure nothing is going wrong. Your best bet, though, is tell us what OS you are using and maybe get this installed with a more supportable way that has documentation behind it.
Solution 2:
Check that you're actually using the httpd.conf file that you're specifying on the command line, on the Centos System I have to hand specifying ./conf/httpd.conf
still uses the /etc/httpd/conf/httpd.conf
file (relative paths appear to be rooted at /etc/httpd).
Check also that you're not running up against SELinux which can be configured to only allow httpd to bind to certain ports, as root you can get the list with
semanage -port -l | grep http_port_t
http_port_t tcp 80, 443, 488, 8008, 8009, 8443
You can add your own port using
semanage port -a -t http_port_t -p tcp 1025
as root but if you don't have root access you'll have to choose one from the list above.