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
2. Check whether Port 8000 is free or not:
# lsof -i:8000
No output means this port is free.
3. Add this port to firewall:
# firewall-cmd –zone=public –permanent –add-port=8000/tcp
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/