Failed to start lsb apache2 web server как исправить

There are two errors:


1. For some reason your /etc/apache2/envvars is missing:

  • from journalctl -xe:

    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 1: /etc/apache2/envvars: envvars: not found
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 49: /etc/apache2/envvars: envvars: not found
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 1: /etc/apache2/envvars: envvars: not found
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 49: /etc/apache2/envvars: envvars: not found
    ...        
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 1: /etc/apache2/envvars: envvars: not found
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 49: /etc/apache2/envvars: envvars: not found
    
  • from systemctl status apache2.service:

    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 1: /etc/apache2/envvars: envvars: not found
    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 49: /etc/apache2/envvars: envvars: not found
    

In my system this file has next permissions:

$ ls -l /etc/apache2/envvars

-rw-r--r--   1 root root  1782 мар 19  2016 envvars

And its content ($ cat /etc/apache2/envvars) is:

# envvars - default environment variables for apache2ctl

# this won't be correct after changing uid
unset HOME

# for supporting multiple apache2 instances
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
        SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
        SUFFIX=
fi

# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
# temporary state file location. This might be changed to /run in Wheezy+1
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
#. /etc/default/locale

export LANG

## The command to get the status for 'apache2ctl status'.
## Some packages providing 'www-browser' need '--dump' instead of '-dump'.
#export APACHE_LYNX='www-browser -dump'

## If you need a higher file descriptor limit, uncomment and adjust the
## following line (default is 8192):
#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'

## If you would like to pass arguments to the web server, add them below
## to the APACHE_ARGUMENTS environment.
#export APACHE_ARGUMENTS=''

## Enable the debug mode for maintainer scripts.
## This will produce a verbose output on package installations of web server mod                                               ules and web application
## installations which interact with Apache
#export APACHE2_MAINTSCRIPT_DEBUG=1

You can create it manually: sudo nano /etc/apache2/envvars, paste above content inside, save ctrl+o and exit ctrl+x.


2. In your system, the folder /etc/apache2/logs also missing:

  • from journalctl -xe:

    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: (2)No such file or directory: AH02291: Cannot access directory '/etc/apache2/logs/' for main error log
    
  • from systemctl status apache2.service:

    Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: (2)No such file or directory: AH02291: Cannot access directory '/etc/apache2/logs/' for main error log
    

This is not the default log folder, it is defined in your custom configuration, and must be created:

$ sudo mkdir /etc/apache2/logs

I have an Apache Web (version 2.4.10) server running on Debian 8 (Jessie). It is mainly used as a SVN repository server.
It was working well since a few weeks, and suddenly, I got an internal error when attempting to list the SVN repos from a Web Browser as can be seen below:

Apache Internal Error & Authentication

As you can see, authentication is still working fine.

I ran the 2 following commands:
systemctl status apache2.service
and
journalctl -xn

commands

But that doesn’t help me much, maybe I’m missing something?
I did NOT modify any configuration file recently related to Apache (or even anything else for that matter): neither the main apache conf file nor any vHost conf file.
I tried restarting Apache, it does restart but the Web Server still encounters an internal error.

error.log:

[Sun Jan 31 18:36:17.372502 2016] [core:notice] [pid 27449:tid 140087289513856] AH00094: Command line: '/usr/sbin/apache2'
[Sun Jan 31 18:37:07.641329 2016] [mpm_event:notice] [pid 27449:tid 140087289513856] AH00491: caught SIGTERM, shutting down
[Sun Jan 31 18:38:31.156131 2016] [wsgi:warn] [pid 1049:tid 140557851056000] mod_wsgi: Compiled for Python/2.7.8.
[Sun Jan 31 18:38:31.156330 2016] [wsgi:warn] [pid 1049:tid 140557851056000] mod_wsgi: Runtime using Python/2.7.9.

[Sun Jan 31 18:38:31.157222 2016] [mpm_event:notice] [pid 1049:tid 140557851056000] AH00489: Apache/2.4.10 (Debian) SVN/1.8.10 OpenSSL/1.0.1k mod_wsgi/4.3.0 Python/2.7.9 configured -- resuming normal operations

[Sun Jan 31 18:38:31.157241 2016] [core:notice] [pid 1049:tid 140557851056000] AH00094: Command line: '/usr/sbin/apache2'

[Sun Jan 31 19:21:39.401930 2016] [mpm_event:notice] [pid 1049:tid 140557851056000] AH00491: caught SIGTERM, shutting down

[Sun Jan 31 19:22:35.038612 2016] [wsgi:warn] [pid 1313:tid 139813423814528] mod_wsgi: Compiled for Python/2.7.8.

[Sun Jan 31 19:22:35.038672 2016] [wsgi:warn] [pid 1313:tid 139813423814528] mod_wsgi: Runtime using Python/2.7.9.

[Sun Jan 31 19:22:35.039592 2016] [mpm_event:notice] [pid 1313:tid 139813423814528] AH00489: Apache/2.4.10 (Debian) SVN/1.8.10 OpenSSL/1.0.1k mod_wsgi/4.3.0 Python/2.7.9 configured -- resuming normal operations

[Sun Jan 31 19:22:35.039611 2016] [core:notice] [pid 1313:tid 139813423814528] AH00094: Command line: '/usr/sbin/apache2'

[Sun Jan 31 19:24:57.303622 2016] [mpm_event:notice] [pid 1313:tid 139813423814528] AH00491: caught SIGTERM, shutting down

[Sun Jan 31 19:26:20.336578 2016] [wsgi:warn] [pid 1050:tid 140178825381760] mod_wsgi: Compiled for Python/2.7.8.

[Sun Jan 31 19:26:20.336805 2016] [wsgi:warn] [pid 1050:tid 140178825381760] mod_wsgi: Runtime using Python/2.7.9.

[Sun Jan 31 19:26:20.337601 2016] [mpm_event:notice] [pid 1050:tid 140178825381760] AH00489: Apache/2.4.10 (Debian) SVN/1.8.10 OpenSSL/1.0.1k mod_wsgi/4.3.0 Python/2.7.9 configured -- resuming normal operations

[Sun Jan 31 19:26:20.337617 2016] [core:notice] [pid 1050:tid 140178825381760] AH00094: Command line: '/usr/sbin/apache2'

[Sun Jan 31 19:31:24.663351 2016] [mpm_event:notice] [pid 1050:tid 140178825381760] AH00491: caught SIGTERM, shutting down

[Sun Jan 31 19:31:25.827873 2016] [wsgi:warn] [pid 1208:tid 139958437914496] mod_wsgi: Compiled for Python/2.7.8.

[Sun Jan 31 19:31:25.827919 2016] [wsgi:warn] [pid 1208:tid 139958437914496] mod_wsgi: Runtime using Python/2.7.9.

[Sun Jan 31 19:31:25.828655 2016] [mpm_event:notice] [pid 1208:tid 139958437914496] AH00489: Apache/2.4.10 (Debian) SVN/1.8.10 OpenSSL/1.0.1k mod_wsgi/4.3.0 Python/2.7.9 configured -- resuming normal operations

[Sun Jan 31 19:31:25.828679 2016] [core:notice] [pid 1208:tid 139958437914496] AH00094: Command line: '/usr/sbin/apache2'

Could that come from the Python version that mod_wsgi is running which differs from what mod_wsgi is apparently expecting?

Я также столкнулся с той же ошибкой (при работе с Saltstack) и сумел ее исправить. Есть четыре способа.

  1. По какой-то причине ваш /etc/apache2/envvars пропал, отсутствует:
    Чтобы решить эту проблему, вы можете создать файл вручную и добавить содержимое envvars по умолчанию ниже

    sudo vim /etc/apache2/envvars
    
    # envvars - default environment variables for apache2ctl
    
    # this won't be correct after changing uid
    unset HOME
    
    # for supporting multiple apache2 instances
    if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
        SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
    else
       SUFFIX=
    fi
    
    # Since there is no sane way to get the parsed apache2 config in scripts, some
    # settings are defined via environment variables and then used in apache2ctl,
    # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
    export APACHE_RUN_USER=www-data
    export APACHE_RUN_GROUP=www-data
    # temporary state file location. This might be changed to /run in Wheezy+1
    export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
    export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
    export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
    # Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
    export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
    
    ## The locale used by some modules like mod_dav
    export LANG=C
    ## Uncomment the following line to use the system default locale instead:
    #. /etc/default/locale
    
    export LANG
    
    ## The command to get the status for 'apache2ctl status'.
    ## Some packages providing 'www-browser' need '--dump' instead of '-dump'.
    #export APACHE_LYNX='www-browser -dump'
    
    ## If you need a higher file descriptor limit, uncomment and adjust the
    ## following line (default is 8192):
    #APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'
    
    ## If you would like to pass arguments to the web server, add them below
    ## to the APACHE_ARGUMENTS environment.
    #export APACHE_ARGUMENTS=''
    
    ## Enable the debug mode for maintainer scripts.
    ## This will produce a verbose output on package installations of web server modules and web application
    ## installations which interact with Apache
    #export APACHE2_MAINTSCRIPT_DEBUG=1
    

    Затем перезапустите службу Apache как обычно.

    sudo service apache2 restart
    
  2. Если твой envvars файл в порядке, то это может быть случай отсутствия пакетов. Переустановите отсутствующие пакеты, используя приведенную ниже команду, затем перезапустите службу Apache.

    sudo apt-get -o DPkg::Options::="--force-confmiss" --reinstall install apache2
    sudo service apache2 restart 
    
  3. Кроме того, вы можете удалить Apache и все его конфигурационные файлы, а затем переустановить его.

    sudo apt-get purge apache2
    sudo apt-get install apache2
    
  4. И, наконец, если все вышеперечисленные параметры не работают, вы можете попробовать установить пакет libapache2-mod-php7.0 или отключите модуль PHP7, запустив

    sudo a2dismod php7.0
    

I am using Ubuntu 15 64-bit:

$ uname -a
Linux {hostname} 4.2.0-16-generic

And I have installed apache2:

$ sudo apt-get install -y apache2

I have a mod_xxx.so, which I have placed into: /usr/lib/apache2/modules/. I set the permissions to 755 (rwx r-x r-x).

I edited the apache2.conf:

$ sudo vi /etc/apache2/apache2.conf
AddHandler xxx-handler .xxx
LoadModule xxx_module modules/mod_xxx.so

I know this works, as I have done this on several other Linux machines before.

When I try to restart Apache, it is failing with this error:

$ sudo service apache2 restart
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.

After doing, what it says above, systemctl status apache2.service, it shows this:

apache2.service - LSB: Apache2 web server
 Loaded: loaded (/etc/init.d/apache2)
 Active: failed (Result: exit-code) since Wed 2016-03-09 10:32:34 GMT; 9s ago
  Docs: man:systemd-sysv-generator(8)
Process: 3479 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 3503 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

Mar 09 10:32:34 Ubuntu14 apache2[3503]: *
Mar 09 10:32:34 Ubuntu14 apache2[3503]: * The apache2 configtest failed.
Mar 09 10:32:34 Ubuntu14 apache2[3503]: Output of config test was:
Mar 09 10:32:34 Ubuntu14 apache2[3503]: apache2: Syntax error on line 224 of...y
Mar 09 10:32:34 Ubuntu14 apache2[3503]: Action 'configtest' failed.
Mar 09 10:32:34 Ubuntu14 apache2[3503]: The Apache error log may have more i....
Mar 09 10:32:34 Ubuntu14 systemd[1]: apache2.service: Control process exite...=1
Mar 09 10:32:34 Ubuntu14 systemd[1]: Failed to start LSB: Apache2 web server.
Mar 09 10:32:34 Ubuntu14 systemd[1]: apache2.service: Unit entered failed state.
Mar 09 10:32:34 Ubuntu14 systemd[1]: apache2.service: Failed with result 'e...'.
Hint: Some lines were ellipsized, use -l to show in full.

So I have tried to search everywhere for where LoadModule is specified. So I have tried doing this:

$ sudo grep "LoadModule" /

I have also tried this:

sudo find / -type f grep -l "LoadModule"

Still no luck.

Where is the LoadModule specified, in Apache 2.4.12?

I know that in Apache 2.4.7, it is in the apache.conf file, which I have used the same logic here that I have used in the newer version.

This is done on a Virtual Machine, so if an error does happen, I can clean the machine and start again. I am the root user too.

Что делать, если не запускается апач?

Апач перестал запускаться, в логе что то про конфиг test, но его нету!
лог:

root@192:~# journalctl -xn
-- Logs begin at Пн 2017-06-26 23:05:02 MSK, end at Пн 2017-06-26 23:11:05 MSK. --
июн 26 23:11:05 192.168.0 systemd[1]: Starting LSB: Apache2 web server...
-- Subject: Начинается запуск юнита apache2.service
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Начат процесс запуска юнита apache2.service.
июн 26 23:11:05 192.168.0 apache2[2247]: Starting web server: apache2 failed!
июн 26 23:11:05 192.168.0 apache2[2247]: The apache2 configtest failed. ... (warning).
июн 26 23:11:05 192.168.0 apache2[2247]: Output of config test was:
июн 26 23:11:05 192.168.0 apache2[2247]: AH00534: apache2: Configuration error: No MPM loaded.
июн 26 23:11:05 192.168.0 apache2[2247]: Action 'configtest' failed.
июн 26 23:11:05 192.168.0 apache2[2247]: The Apache error log may have more information.
июн 26 23:11:05 192.168.0 systemd[1]: apache2.service: control process exited, code=exited status=1
июн 26 23:11:05 192.168.0 systemd[1]: Failed to start LSB: Apache2 web server.
-- Subject: Ошибка юнита apache2.service
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Произошел сбой юнита apache2.service.
--
-- Результат: failed.
июн 26 23:11:05 192.168.0 systemd[1]: Unit apache2.service entered failed state.


  • Вопрос задан

    более трёх лет назад

  • 4547 просмотров

Где-то в конфигурации апача ошибка.
Просмотрите errorlog — там может быть больше информации, например в какой строке.

У вас конкретно ошибка с MPM модулем — или для него недостаточно параметров, или вы апгрейдили апач, и конфиг остался от старого, в котором опции могут идти в некорректном порядке (например блоки virtualhost до блоков с погрузкой модулей)

Проверьте конфигурацию файлов, можно еще погуглить. Если все плохо — выложите конфиги сюда, тогда можно будет подсказать конкретнее. Потому что вариантов, что вызвало ошибку может быть много.

Пригласить эксперта

apt-get purge apache2 && apt-get install nginx -y

AH00534: apache2: Configuration error: No MPM loaded.

The Apache error log may have more information.

Action 'configtest' failed.
Говорит о том, что провален тест корректности конфигурации. Если Вы выполните в консоли команду configtest, то она скажет Вам где в ваших конфигах ошибка.


  • Показать ещё
    Загружается…

29 мая 2023, в 14:03

5000 руб./за проект

29 мая 2023, в 14:01

7000 руб./за проект

29 мая 2023, в 13:30

30000 руб./за проект

Минуточку внимания

Понравилась статья? Поделить с друзьями:
  • Как найти новую девченку
  • Как найти причину позвонить
  • Как найти воду на участке электродами
  • Как найти зрелую госпожу
  • На телефоне быстро гаснет экран как исправить