Как узнать какой веб сервер используется на linux
Перейти к содержимому

Как узнать какой веб сервер используется на linux

  • автор:

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.

Closed 4 years ago .

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.

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

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:

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 .

n.st's user avatar

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.

Как узнать версию Nginx

Если вы администрируете Linux сервер, вам может понадобиться узнать версию Nginx. Это очень популярный и высокопроизводительный веб-сервер, который используется даже чаще чем Apache. От версии зависит поддерживает веб-сервер те или иные возможности, а также есть ли в нём все необходимые патчи исправляющие уязвимости.

Дальше в этой статье мы рассмотрим как посмотреть версию различными способами на самом сервере или без доступа к серверу.

Как посмотреть версию Nginx

Самый простой способ посмотреть версию Nginx если у вас есть доступ к серверу — воспользоваться командой nginx с опцией -v:

Если вы запускаете команду от имени обычного пользователя и получаете ошибку, это значит что она находится в каталоге /sbin/ или /usr/sbin, доступному только для суперпользователя. Попробуйте выполнить команду с sudo:

Более подробную информацию можно получить используя опцию -V. Она выводит информацию о версии компилятора и модулях, с которыми была скомпилирована программа:

Если вы хотите проверить скомпилирована ли программа с определённым модулем, например, модулем http_flv, используйте такую команду:

nginx -V 2>&1 | grep http_flv_module

Если имя модуля есть в списке, то оно будет подсвечено красным цветом.

Это всё что касается просмотра версии на сервере. Кроме того, Nginx отображает версию сервера при возникновении ошибки в браузере, а также передает её в заголовке Server. Посмотреть передаваемые заголовки можно с помощью curl. Например:

curl -I test.losst.pro

Как скрыть версию Nginx

Если вы не хотите чтобы ваш Nginx показывал свою версию всем в заголовках или во время ошибки, надо отредактировать файл /etc/nginx/nginx.conf. Измените значение директивы server_tokens с on на off в секции http:

sudo vi /etc/nginx/nginx.conf

Затем перезапустите сервер:

sudo systemctl restart nginx

Теперь вы знаете как скрыть версию, в заголовке Nginx будет передавать только своё название.

Как видите, всё очень просто. Теперь вы знаете как посмотреть версию Nginx. Если вы знаете другие способы, пишите в комментариях!

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

how to find out the apache version installed in ubuntu?

how to find out the Apache server version installed in Ubuntu 14.04?

Sumanshu Singh's user avatar

3 Answers 3

Open the terminal and type:

-v Print the version of apache2, and then exit.

karel's user avatar

From the terminal you can enter: (lowercase -v )

or to get even more compile info on Apache enter: (uppercase -V )

of course as mention by @karel you can also use apache2 instead of apachectl . just giving an alternative. This worked for me in Ubuntu 18.04 and I’m using Apache 2.4.37.

How can I check if current web server is NGINX or Apache using bash script?

I have a Laravel project deployed on Ubuntu VM. I have a script that I am working on right now that to know if the current VM deployed using nginx or Apache programmatically.

I know I can just check using these ps and grep command I will find that out

With those result about, I know that this VM is using Apache.

But, I have no idea how to check it via a Bash script. How would one go about and do that? I’m open to any suggestions at this moment.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *