• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Change Default Port of Apache On RHEL/CentOS 7

by admin

If you want to change Port in the Apache configuration file it’s easy to do. You can also run a website on a different port rather than the default port.

1. Let’s check which is listening to which service:

# nmap -sT -O localhost

apache change default port CentOS 7

2. Check whether Port 8000 is free or not:

# lsof -i:8000

No output means this port is free.

lsof command output

3. Add this port to firewall:

# firewall-cmd –zone=public –permanent –add-port=8000/tcp

add apache port to firewalld

4. Reload the firewall to apply changes

# firewall-cmd reload
success

5. Add this port in apache configuration file located at /etc/httpd/conf/httpd.conf:

# vi /etc/httpd/conf/httpd.conf
#Listen 12.34.56.78:80
Listen 80
Listen 8080

6. Restart the Apache Service:

# Systemctl restart httpd

7. Create a file at location /var/www/html/index.html:

# vi /var/www/html/index.html
hello this is port change example

8. Now try to access the Website Page on browser with IP:8000

http://192.168.140.141:8000/

apache change default port RHEL 7

Filed Under: CentOS/RHEL, CentOS/RHEL 7, CentOS/RHEL 8, Linux

Some more articles you might also be interested in …

  1. How to Install Oracle Linux (UEK-2) with btrfs as a root filesystem
  2. fuser Command Examples in Linux
  3. Understanding RHV Cluster Migration Policy
  4. Beginners Guide to Tuning Profiles in CentOS/RHEL
  5. How to manage File and Directory Permissions/Ownerships in Linux
  6. How to Set Resource Limits for a Process with Systemd in CentOS/RHEL 7 and 8
  7. How to Find and Delete Empty Directories and Files in Linux
  8. RHEL 7 – RHCSA Notes – input / output redirection
  9. Audit Rule Configuration not Reflected – How to troubleshoot
  10. RHEL 7 – RHCSA Notes : Create hard and soft links.

You May Also Like

Primary Sidebar

Recent Posts

  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found
  • macof: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright