• 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. debchange: command not found
  2. Understanding RPM Versions and Naming Schemes
  3. CentOS / RHEL 7 : How to configure cache-only nameserver
  4. aspell Command Examples in Linux
  5. /proc/cpuinfo file explained
  6. Linux “seq” Command Examples
  7. egrep Command Examples in Linux
  8. eject: command not found
  9. How to Change runlevels/targets using systemd in Ubuntu
  10. printk and console log level

You May Also Like

Primary Sidebar

Recent Posts

  • fprintd-delete Command Examples in Linux
  • fprintd-delete: command not found
  • foreman: command not found
  • foreman Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright