How to determine which webserver is installed with no information? [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
I’ve recently taken over a project after a developer caused issues with the client. However, due to the lack of documentation (laugh) I have no idea where the website files are stored or what webserver has been installed. Questions: In Linux, how can I see what webserver has been installed? In Linux, how can I find where the webserver points to in the file directory? (aware that this will depend on the answer from the first question) ** Hosted on Linode
Does the system show a net interface on an IP address? A brute forse approach might be to analyze the files the server shows on the net and to search it with «find . -iname filename». If you find a file you may individuate the path where are the site file and then search such a path (or part of it) into the files into the /etc directory. I think the webserver nay be Apache or Tomcat. Both servers have configuration file where’re all info needing to start the server.
An important first step will be to find out what Linux distribution is running on the server. The next steps may depend quite strongly on that detail. We may be able to give you some hints, but as it stands your question seems to broad to generate a concise and useful answer. For step-by-step debugging, a chat room/IRC might be more useful.
4 Answers 4
A basic approach would be to use netstat -tnlp with an additional grep on the browser ports that it is supposed to be serving. Typically, that would then be:
netstat -tnlp | grep 80 netstat -tnlp | grep 443
That should list the process PID and name that owns these ports. That should give you a clue which server it is. Then, locate the configuration files for that server application, e.g. /etc/httpd .
There is no such things as the webserver in linux. Several different servers exist that could do the job. The most common are probably Apache httpd and nginx.
In general you should start by finding out which it is, and then look at it’s configuration.
One option to find out which webserver is installed is using netstat to see what is listening to the ports commonly used for HTTP traffic, 80 (for unencryted) and 443 (for encrypted/HTTPS) are the most common. But if there is some proxy in front, any port might be used, in that case 8080 and 8443 are common choices.
Another option would be to utilise your distribution’s package system. The tools to use depend a lot on which distribution you have, on Debian it would be something like dpkg -l | grep -i web , it probably outputs several packages, but the relevant should be aming, and easy to pick from the descriptions.
In this specific case it might make sense to just see if the two common choices have configuration on the system. In most cases apache httpd will have it’s configuration in /etc/apache (possibly /etc/apache2 ), nginx often in /etc/nginx .
For apache httpd, the relevant setting will often be DocumentRoot , for nginx it’s most commonly root , but both can be configured to do almost anything (Apache httpd supports ModRewrite that is said to be Turing complete, making it theoretically capable of doing absolutely anything), so it can be a bit difficult to find what you need.
Полезные команды для управления Apache в Linux
В этом руководстве мы опишем некоторые из наиболее часто используемых команд управления службами Apache (HTTPD) , которые полезно знать, разработчику или системному администратору, и держать эти команды под рукой. Мы покажем команды для Systemd и SysVinit.
Убедитесь, что следующие команды должны выполняться от имени пользователя root или sudo и работать с любым дистрибутивом Linux, таким как CentOS, RHEL, Fedora, Debian и Ubuntu.
Про Linux за 5 минут
Установка Apache Server
$ sudo apt install apache2 [On Debian/Ubuntu] $ sudo yum install httpd [On RHEL/CentOS] $ sudo dnf install httpd [On Fedora 22+] $ sudo zypper install apache2 [On openSUSE]
Проверка версии Apache
Чтобы проверить установленную версию вашего веб-сервера Apache в вашей системе Linux, выполните следующую команду.
Server version: Apache/2.4.6 (CentOS) Server built: May 5 2019 01:47:09
Если вы хотите увидеть номер версии Apache и параметры компиляции, используйте флаг -V, как показано ниже.
Server version: Apache/2.4.6 (CentOS) Server built: May 5 2019 01:47:09 Server's Module Magic Number: 20120211:24 Server loaded: APR 1.4.8, APR-UTIL 1.5.2 Compiled using: APR 1.4.8, APR-UTIL 1.5.2 Architecture: 64-bit Server MPM: prefork threaded: no forked: yes (variable process count) Server compiled with. -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=256 -D HTTPD_ROOT="/etc/httpd" -D SUEXEC_BIN="/usr/sbin/suexec" -D DEFAULT_PIDLOG="/run/httpd/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf"
Проверка на ошибки синтаксиса конфигурации Apache
Чтобы проверить ваши файлы конфигурации Apache на наличие любых синтаксических ошибок, выполните следующую команду, которая проверит правильность файлов конфигурации, прежде чем перезапускать службу.
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using merionet.ru. Set the 'ServerName' directive globally to suppress this message Syntax OK
Запуск сервиса Apache
------------ On CentOS/RHEL ------------ $ sudo systemctl start httpd [On Systemd] $ sudo service httpd start [On SysVInit] ------------ On Ubunt/Debian ------------ $ sudo systemctl start apache2 [On Systemd] $ sudo service apache2 start [On SysVInit]
Включение службы Apache
Предыдущая команда пока только запускает службу Apache, чтобы включить автозапуск при загрузке системы, выполните следующую команду.
------------ On CentOS/RHEL ------------ $ sudo systemctl enable httpd [On Systemd] $ sudo chkconfig httpd on [On SysVInit] ------------ On Ubunt/Debian ------------ $ sudo systemctl enable apache2 [On Systemd] $ sudo chkconfig apache2 on [On SysVInit]
Перезапуск службы Apache
------------ On CentOS/RHEL ------------ $ sudo systemctl restart httpd [On Systemd] $ sudo service httpd restart [On SysVInit] ------------ On Ubunt/Debian ------------ $ sudo systemctl restart apache2 [On Systemd] $ sudo service apache2 restart [On SysVInit]
Просмотр состояния сервиса Apache
Чтобы проверить информацию о состоянии времени выполнения службы Apache, выполните следующую команду.
------------ On CentOS/RHEL ------------ $ sudo systemctl status httpd [On Systemd] $ sudo service httpd status [On SysVInit] ------------ On Ubunt/Debian ------------ $ sudo systemctl status apache2 [On Systemd] $ sudo service apache2 status [On SysVInit]
Перезагрузка сервиса Apache
Если вы внесли какие-либо изменения в конфигурацию сервера Apache, вы можете указать службе перезагрузить свою конфигурацию, выполнив следующую команду.
------------ On CentOS/RHEL ------------ $ sudo systemctl reload httpd [On Systemd] $ sudo service httpd reload [On SysVInit] ------------ On Ubunt/Debian ------------ $ sudo systemctl reload apache2 [On Systemd] $ sudo service apache2 reload [On SysVInit]
Остановка службы Apache
------------ On CentOS/RHEL ------------ $ sudo systemctl stop httpd [On Systemd] $ sudo service httpd stop [On SysVInit] ------------ On Ubunt/Debian ------------ $ sudo systemctl stop apache2 [On Systemd] $ sudo service apache2 stop [On SysVInit]
Показать справку Apache Command
И последнее, но не менее важное: вы можете получить справку о служебных командах Apache в systemd, выполнив следующую команду.
Usage: httpd [-D name] [-d directory] [-f file] [-C "directive"] [-c "directive"] [-k start|restart|graceful|graceful-stop|stop] [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X] Options: -D name : define a name for use in directives -d directory : specify an alternate initial ServerRoot -f file : specify an alternate ServerConfigFile -C "directive" : process directive before reading config files -c "directive" : process directive after reading config files -e level : show startup errors of level (see LogLevel) -E file : log startup errors to file -v : show version number -V : show compile settings -h : list available command line options (this page) -l : list compiled in modules -L : list available configuration directives -t -D DUMP_VHOSTS : show parsed vhost settings -t -D DUMP_RUN_CFG : show parsed run settings -S : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG -t -D DUMP_MODULES : show all loaded modules -M : a synonym for -t -D DUMP_MODULES -t : run syntax check for config files -T : start without DocumentRoot(s) check -X : debug mode (only one worker, do not detach)
На этом пока все! В этой статье мы объяснили наиболее часто используемые команды управления службами Apache / HTTPD, которые полезно будет знать, включая запуск, включение, перезапуск и остановку Apache.
How to check if a web server is installed in a Linux machine? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
- 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.
- If a web Server installed, how to check where it is installed, path , properties etc..
2 Answers 2
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:
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:
You will get an error message that may tell you something about what webserver is installed. For example:
Not Found
The requested URL /status was not found on this server.
Apache/2.2.22 (Ubuntu) Server at 127.0.1.1 Port 80 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:
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.:
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.