Когда я запускаю apache, тогда он дает мне ниже ошибку -
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
Я выполнил команду ниже -
systemctl status apache2.service
Я получил ошибку ниже
apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: failed (Result: exit-code) since Wed 2017-05-31 17:01:40 IST; 1min 34s ago
Docs: man:systemd-sysv-generator(8)
Process: 11884 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 3171 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
Process: 12696 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
May 31 17:01:40 itadmin systemd[1]: Starting LSB: Apache2 web server...
May 31 17:01:40 itadmin apache2[12696]: * Starting Apache httpd web server apache2
May 31 17:01:40 itadmin apache2[12696]: mktemp: failed to create file via template ‘/tmp/tmp.XXXXXXXXXX’: Read-only file system
May 31 17:01:40 itadmin apache2[12696]: /etc/init.d/apache2: 72: /etc/init.d/apache2: cannot create : Directory nonexistent
May 31 17:01:40 itadmin apache2[12696]: *
May 31 17:01:40 itadmin apache2[12696]: * The apache2 configtest failed.
May 31 17:01:40 itadmin systemd[1]: apache2.service: Control process exited, code=exited status=1
May 31 17:01:40 itadmin systemd[1]: Failed to start LSB: Apache2 web server.
May 31 17:01:40 itadmin systemd[1]: apache2.service: Unit entered failed state.
May 31 17:01:40 itadmin systemd[1]: apache2.service: Failed with result 'exit-code'.
Я ничего не понимаю. Пожалуйста, кто-нибудь может мне помочь?
Я также столкнулся с той же ошибкой (во время работы с Saltstack) и смог ее решить. Есть четыре способа:
По какой-то причине отсутствует ваш /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
Если ваш файл envvars в порядке, это может быть случай отсутствия пакетов. Переустановите отсутствующие пакеты с помощью команды ниже, а затем перезапустите службу Apache. sudo apt-get -o DPkg::Options::="--force-confmiss" --reinstall install apache2
sudo service apache2 restart
В качестве альтернативы вы можете удалить Apache и все его файлы конфигурации, а затем переустановить его. sudo apt-get purge apache2
sudo apt-get install apache2
И, наконец, если все вышеперечисленные опции не работают, вы можете попробовать установить пакет libapache2-mod-php7.0 или отключить модуль PHP7, запустив sudo a2dismod php7.0
Я также столкнулся с той же ошибкой (во время работы с Saltstack) и смог ее решить. Есть четыре способа:
По какой-то причине отсутствует ваш /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
Если ваш файл envvars в порядке, это может быть случай отсутствия пакетов. Переустановите отсутствующие пакеты с помощью команды ниже, а затем перезапустите службу Apache. sudo apt-get -o DPkg::Options::="--force-confmiss" --reinstall install apache2
sudo service apache2 restart
В качестве альтернативы вы можете удалить Apache и все его файлы конфигурации, а затем переустановить его. sudo apt-get purge apache2
sudo apt-get install apache2
И, наконец, если все вышеперечисленные опции не работают, вы можете попробовать установить пакет libapache2-mod-php7.0 или отключить модуль PHP7, запустив sudo a2dismod php7.0