Showing posts with label httpd. Show all posts
Showing posts with label httpd. Show all posts

How To Change Apache Port Number

FREQUENTLY ASKED QUESTIONS (Apache Web server)
Q: How to change Apache server default listening port number? 


Change the Apache web server's default listening port number from 80 TCP to any other port number. All you need to do is ddit the httpd.conf configuration file and specify the new port number.
Edit Apache configurations
[root@server ~]# vi /etc/httpd/conf/httpd.conf  
# Search for the line starts with "Listen" (can find near the 136th line) and add your default port number. In this example i changed default apache port from 80/TCP to 90/TCP. 
Listen 90
#Now save the httpd.conf file.
Click on screenshot to enlarge
Restart Apache Service
[root@server ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                             [  OK  ]

Open new port in Firewalls
But, If a firewill is running in the Apache server or in the network/router, you should open the new Apache server port(90/tcp) in all firewalls. 

Test new listening Port
Test new listening port by connecting server from a web browser or telnet to the server.

If the Apache server address is 192.168.10.50,
[root@server ~]#  telnet 192.168.10.50 90
OR
Go to browser and connect to http://192.168.10.50:90

Install And Configure Apache Web Server In Linux

Apache is the most popular and stable web server on the internet. It support multiple languages and supports SSL/TLS and many more features.
Follow the steps to install and configure an Apache web server (httpd) in a RPM based linux distribution.
In this example i used CentOS 6, but it should work same way in all RPM based distros like Redhat, Fedora, CentOS, etc


Install Apache Server from Yum

[root@server ~]# yum install httpd
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
 * base: centos.01link.hk
 * extras: centos.01link.hk
 * updates: centos.01link.hk
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-15.el6.centos.1 set to be updated
--> Processing Dependency: httpd-tools = 2.2.15-15.el6.centos.1 for package: htt                               pd-2.2.15-15.el6.centos.1.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.2.15-15.el6.centos.1 set to be updated
--> Finished Dependency Resolution


Dependencies Resolved


================================================================================
 Package          Arch        Version                        Repository    Size
================================================================================
Updating:
 httpd            x86_64      2.2.15-15.el6.centos.1         updates      813 k
Updating for dependencies:
 httpd-tools      x86_64      2.2.15-15.el6.centos.1         updates       70 k


Transaction Summary
================================================================================
Install       0 Package(s)
Upgrade       2 Package(s)


Total download size: 882 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): httpd-2.2.15-15.el6.centos.1.x86_64.rpm           | 813 kB     00:26
(2/2): httpd-tools-2.2.15-15.el6.centos.1.x86_64.rpm     |  70 kB     00:01
--------------------------------------------------------------------------------
Total                                            30 kB/s | 882 kB     00:29
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
updates/gpgkey                                           | 3.3 kB     00:00 ...
Importing GPG key 0xC105B9DE "CentOS-6 Key (CentOS 6 Official Signing Key) <cent                               os-6-key@centos.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating       : httpd-tools-2.2.15-15.el6.centos.1.x86_64                1/4
  Updating       : httpd-2.2.15-15.el6.centos.1.x86_64                      2/4
  Cleanup        : httpd-2.2.15-5.el6.centos.x86_64                         3/4
  Cleanup        : httpd-tools-2.2.15-5.el6.centos.x86_64                   4/4


Updated:
  httpd.x86_64 0:2.2.15-15.el6.centos.1


Dependency Updated:
  httpd-tools.x86_64 0:2.2.15-15.el6.centos.1


Complete!

Now the installation process is completed. The CentOS 6 has Apache preinstalled. But above i updated the httpd package and dependencies to the latest version.

Start Apache server
[root@server ~]# service httpd start
Starting httpd:                                            [  OK  ]


Configure Firewall for Apache
By default Apache server will listen on port 80/TCP, so you need to open that port for giving web server access to clients or Disable linux firewall 
Or temporarily stop firewall
[root@server ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]


Test Apache Web server
go to Webserver's web browser and go the address http://localhost/
Or access from another machine by server's ip address. If the Apache serrver's ip address is 192.168.10.50 then try http://192.168.10.50/
Click on screenshot to enlarge

Related Posts Plugin for WordPress, Blogger...

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Coupons