Avatar of tomfra
tomfraFlag for Czechia

asked on 

I need to run Apache on a different port number, on a CPanel server

OK, I need to run Apache on a different port number, on a CPanel server. I simply need the port 80 available for something else so that's the reason I first need to move Apache from port 80 to say, port 81. I tried changing the "port" and "listen" values in the httpd.conf but then Apache refused to start. It may have something to do with the specific CPanel setup but that's just a guess.

My server runs CentOS 4.4 i686 and the newest stable version of WHM/CPanel.

Any ideas how to accomplish this?

Tomas
LinuxLinux NetworkingApache Web Server

Avatar of undefined
Last Comment
tomfra
Avatar of Pablo Allietti
Pablo Allietti
Flag of Uruguay image

mmm i think you CANT do that with cpanel... in the httpd.conf you only need to modify LISTEN 80 to LISTEN 81     and restart apache but if the apache dont start i think you need to find in the virtualhosts for example you can find a

VirtualHost myname.com:80

you need to replace with myname.com:81
Avatar of tomfra
tomfra
Flag of Czechia image

ASKER

I've tried that and it worked, partially though. I've modified the "Listen" value to 81, the "Port" value to 81 and all of the VirtualHosts but now when I want to access the webs I have to manually specify the new port in the URL - i.e. http://mydomain.com:81, otherwise I am simply redirected to the default CPanel webpage. And when I ran "nmap localhost", it shows that port 80 is still being used by httpd - and port 81 is used by "hosts2-ns".
ok. nmap take info from /etc/services and port 81 in services is a hosts-ns

and cpanel run in port 80 you need to modify in cpanel.conf the port specify to your cpanel.

Avatar of tomfra
tomfra
Flag of Czechia image

ASKER

There was no entry for port 81 in /etc/services , nmap probably takes the info from a different location. I couldn't find cpanel.conf, only cpanel.config in /var/cpanel/ but there was no entry for the httpd port value. Maybe I should add something in there?
mmm i dont think so...       you restart apache after the changes?? because you can have another webserver running in port 80.... is extrange because if you cahnge the port of the webserver you cannot access to the last port (80)
Avatar of tomfra
tomfra
Flag of Czechia image

ASKER

Well,I guess I know the reason... In the httpd.conf there is this section:

##  SSL Support
##
##  When we also provide SSL we have to listen to the
##  standard HTTP port (see above) and to the HTTPS port
##
<IfDefine SSL>
Listen 80
Listen 443
</IfDefine>

As I mentioned before, I changed the Listen & Port values to 81 bu the <IfDefine SSL> section the Listen value is mentioned again. And if when I change this one to 81 or comment it out, Apache does not restart.
and what is the error? in the apahce error log you can see that.

Avatar of tomfra
tomfra
Flag of Czechia image

ASKER

I've just checked the Apache error log and found this:

[crit] (98)Address already in use: make_sock: could not bind to port 81

But port 81 is open for sure, I've just checked it through the "nmap localhost" command.



try to change to the port 82 or 83 for example maybe you running something in the port 81
Avatar of tomfra
tomfra
Flag of Czechia image

ASKER

I was able to restart Apache via SSH with the "service httpd restart" command, before I was trying it only through the WHM panel which failed. I am not sure what's the reason in this case, however, I am still not able to access the webs without specifiing the non-standard port number. In other words: http://mydomain.com:81 works, http://mydomain.com does not and unlike before, I don't see the default CPanel setup webpage but just a "connection refused" error message.

if you change the port you need to specify the port to see webpages.

i dont understand why you need to change the default port of apache... indeed is many cases or all cases you need to change the port of the other application.. not apache...  please reconsider change the port 80 and let apache do the job
Avatar of tomfra
tomfra
Flag of Czechia image

ASKER

The reason is technically not Apache but SSH. I will be using one of my servers as a proxy server and in the corporate environment it is relatively common to block ports such as 22 and the port 80 is one of the few ports that are left open. I want those users to be able to connect via SSH to my server (SSH tunneling) which means I have to make SSH available on port 80.

This may be totally strange but I believe it could work. However, I can't move SSH to port 80 because Apache is listening there so I first have to move Apache to another port. Does that make sense? ;)

I don't really understand all the details of Linux networking etc, but I believe it should be possible to make Apache listen on a different port *without* having to type the non-standard port number as a part of the URL. But I may be wrong.

Tomas

ASKER CERTIFIED SOLUTION
Avatar of Pablo Allietti
Pablo Allietti
Flag of Uruguay image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of tomfra
tomfra
Flag of Czechia image

ASKER

Hmm... maybe moving SSH to another commonly open port instead of port 80 would make more sense then... I know this all may sound terribly odd but I have to find a way how to circumvent very restrictive "open port rules" imposed by many system admins in big companies, schools, etc. I will probably have to find another workaround.

Nevertheless, thanks for your help. This info is going to help me a lot! Solution accepted ;)

Tomas
Linux
Linux

Linux is a UNIX-like open source operating system with hundreds of distinct distributions, including: Fedora, openSUSE, Ubuntu, Debian, Slackware, Gentoo, CentOS, and Arch Linux. Linux is generally associated with web and database servers, but has become popular in many niche industries and applications.

71K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo