12. Install Apache Tomcat
Tomcat is a servlet container designed by Apache to run Java HTTP web server. Install tomcat as below but it is necessary to point out that you must have installed Java prior of installing tomcat.
# yum install tomcat

After tomcat has been installed, star the tomcat service.
# systemctl start tomcat
Check Version of tomcat.
# /usr/sbin/tomcat version

Add service tomcat and default port (8080) through firewall and reload settings.
# firewall-cmd --zone=public --add-port=8080/tcp --permanent # firewall-cmd --reload
Now it’s time to secure tomcat server, create a user and a password to access and manage. We need to edit file ‘/etc/tomcat/tomcat-users.xml‘. See the section which looks like:
<tomcat-users> .... </tomcat-users> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <role rolename="admin-gui"/> <role rolename="admin-script"/> <user username="tecmint" password="tecmint" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/> </tomcat-users>

Here we added user “tecmint” to administer/manage tomcat using password “tecmint”. Stop and start the service tomcat so that the changes are taken into effect and enable tomcat service to start at system boot.
# systemctl stop tomcat # systemctl start tomcat # systemctl enable tomcat.service
Read Also: Installing and Configuring Apache Tomcat 8.0.9 in RHEL/CentOS 7.0/6.x
13. Install Nmap to Monitor Open Ports
Nmap for Network Mapper creates a map of the network by discovering host on which it is running as well as by analyzing network. nmap is not included in the default installation and you have to install it from repository.
# yum install nmap

List all open ports and corresponding services using them on host.
# nmap 127.0.01

You may also use firewall-cmd to list all the ports, however I find nmap more useful.
# firewall-cmd --list-ports

Read Also: 29 Useful Nmap Command to Monitor Open Ports
14. FirewallD Configuration
firewalld is a firewall service which manages the server dynamically. Firewalld removed iptables in CentOS 7. Firewalld is installed by default on RedHat Enterprise Linux and its derivatives by default. With iptables every change in order to be taken into effect needs to flush all the old rules and create new rules.
However with firewalld, no flushing and recreating of new rules required and only changes are applied on the fly.
Check if Firewalld is running or not.
# systemctl status firewalld OR # firewall-cmd --state

Get a list of all the zones.
# firewall-cmd --get-zones

To get details on a zone before switching.
# firewall-cmd --zone=work --list-all

To get default zone.
# firewall-cmd --get-default-zone

To switch to a different zone say ‘work‘.
# firewall-cmd --set-default-zone=work

To list all the services in the zone.
# firewall-cmd --list-services

To add a service say http, temporarily and reload firewalld.
# firewall-cmd --add-service=http # firewall-cmd –reload

To add a service say http, permanently and reload firewalld.
# firewall-cmd --add-service=http --permanent # firewall-cmd --reload

To remove a service say http, temporarily.
# firewall-cmd --remove-service=http # firewall-cmd --reload

To remove a service say http, permanently.
# firewall-cmd --zone=work --remove-service=http --permanent # firewall-cmd --reload

To allow a port (say 331), temporarily.
# firewall-cmd --add-port=331/tcp # firewall-cmd --reload

To allow a port (say 331), permanently.
# firewall-cmd --add-port=331/tcp --permanent # firewall-cmd --reload

To block/remove a port (say 331), temporarily.
# firewall-cmd --remove-port=331/tcp # firewall-cmd --reload

To block/remove a port (say 331), permanently.
# firewall-cmd --remove-port=331/tcp --permanent # firewall-cmd --reload

To disable firewalld.
# systemctl stop firewalld # systemctl disable firewalld # firewall-cmd --state

To enable firewalld.
# systemctl enable firewalld # systemctl start firewalld # firewall-cmd --state

- How to Configure ‘FirewallD’ in RHEL/CentOS 7
- Useful ‘FirewallD’ Rules to Configure and Manage Firewall
15. Installing Wget
wget is a Linux command line based utility that retrieves (downloads) content from web servers. It is an important tool you must have to retrieve web contents or download any files using wget command.
# yum install wget

For more usage and practical examples on how to use wget command to download files on the terminal, read 10 Wget Command Examples.
16. Installing Telnet
Telnet is a network protocol that enables a user to login into another computer on the same network over TCP/IP. Once connection etablished to the remote computer it becomes a virtual terminal and allow you to communicate with the remote host within your computer as per whatever privileges provided to you.
Telnet also very useful for checking listening ports on remote computer or host.
# yum install telnet # telnet google.com 80

I followed this guide. Its really helpful. As you said quite extensively about installing apache, databases and others.
Can you also provide a guide regarding how to upload a site in CentOS after doing all this?
You can use WordPress and add the blogs.create new website add the domain to that website apache.
I am wondering why httpd,php is installed after installing virtualbox. Initially it is installed, will it conflict
Resourceful tutorial for Linux enthusiast.
There is a mistake in the SSH section. The config file is NOT ‘ssh-config’. That is meant for the SSH client not the server. The SSH server settings are in ‘sshd-config’. As a noob, it took me a while to figure out why my changes had no effect on the server.
Otherwise, this has been a great resource for someone like me learning Linux for the first time. Thanks!
@Gary,
Thanks for notifying, yes it should sshd_config for configuring SSH Server. We’ve corrected in the article.
One of the commands didn’t work for me, the one related to opening up the httpd port through firewalld. I got a syntax error
I got a successful execution with the following command, because I did not choose to assign http a funky port, just the standard one (80)
If you want to use a custom port for httpd, use this command, which specifies the port/protocol:
SOURCE:
https://stackoverflow.com/questions/24729024/open-firewall-port-on-centos-7
Thank you for getting this information together, it is very helpful for people not familiar to minimal dekstop-less installations.
There’s a syntax error in the article, it should say:
(two dashes instead of one, before every argument)
@IvanZ,
Thanks, I have corrected the command in the article..