Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a web server is installed in a Linux machine? [closed]

Good morning folks,

Basic question :-)

  1. How to check if a web server is installed in a Linux machine? I dont know if any web server installed or not. If installed I would like to use it to build a web service.

  2. If a web Server installed, how to check where it is installed, path , properties etc..

Thank you for your time!

like image 667
user3427350 Avatar asked Mar 17 '14 02:03

user3427350


People also ask

How can I tell if a webserver is running?

Another quick way to see if you are running a rogue Web server is to go to a command prompt and type netstat -na. On the second line you can see that you have TCP port 80 LISTENING. This means that you are using the HTTP service on your machine, which again, indicates that you have a Web server running.

How do I know if my Linux server is reachable?

The ping command is a simple network utility command-line tool in Linux. It's a handy tool for quickly checking a host's network connectivity. It works by sending an ICMP message ECHO_REQUEST to the target host. If the host reply with ECHO_REPLY, then we can safely conclude that the host is available.


1 Answers

If there's a webserver active it's easy enough to tell, but if the webserver is installed, but not active, it's more difficult, since there are probably a dozen different webservers that might be installed (but haven't been started). You can tell if there's a web server active on the default port for http (80) with:

$ telnet hostname 80

Where hostname is the hostname or IP address of the machine of interest. If you have shell access to the machine of interest, then you can just use localhost, for example, if there is a webserver active, you will see something like:

$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

If you type something like:

GET /foo

You will get an error message that may tell you something about what webserver is installed. For example:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /status was not found on this server.</p>
<hr>
<address>Apache/2.2.22 (Ubuntu) Server at 127.0.1.1 Port 80</address>
</body></html>
Connection closed by foreign host.

This would tell you that Apache version 2.2.22 is installed and running on the machine that you're running the shell on.

If there is no webserver active, on the other hand, you will see something like:

$ telnet localhost 80
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

In this case, things get rather more distribution-specific (what you find and where is dependent on the Linux distribution installed). You can try to see if there's a webserver installed, but not active, by checking for common service names or installed files and directories. You could try:

$ service apache2 status

or

$ service httpd status

And you might get:

Apache2 is NOT running.

This at least tells you that Apache is installed, but not running, whereas:

apache2: unrecognized service

... would tell you that Apache is not installed. There could, however, be another webserver installed.

You might also check to see if there's a /var/www/ directory, or another directory where webservers commonly store files by default, e.g.:

$ ls /var/www

Unfortunately, it's hard to give a good answer without knowing what distribution (e.g. Debian, Ubuntu, RedHat, CentOS, Fedora, ...) is installed on the machine of interest.

like image 70
Emmet Avatar answered Oct 16 '22 19:10

Emmet