I am trying to migrate from Apache 2.2 on Debian 7 to Apache 2.4 on CentOS 7.
There is a file named "envvars" on Debian 7 as below which has to exist on CentOS 7 as far as I know.
# 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
export APACHE_PID_FILE=/var/run/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
I created the same file under conf where httpd.conf located but it did not work and also add the contents to /etc/sysconfig/httpd but an error stops running the apache server as below.
Jun 17 17:48:35 ww-test httpd[5707]: [Wed Jun 17 17:48:35.473658 2020] [core:warn] [pid 5707] AH00111: Config variable ${APACHE_PID_FILE} is not defined
Jun 17 17:48:35 ww-test httpd[5707]: [Wed Jun 17 17:48:35.473857 2020] [core:warn] [pid 5707] AH00111: Config variable ${APACHE_RUN_USER} is not defined
Jun 17 17:48:35 ww-test httpd[5707]: [Wed Jun 17 17:48:35.473864 2020] [core:warn] [pid 5707] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
Jun 17 17:48:35 ww-test httpd[5707]: [Wed Jun 17 17:48:35.473885 2020] [core:warn] [pid 5707] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
Jun 17 17:48:35 ww-test httpd[5707]: [Wed Jun 17 17:48:35.495541 2020] [core:warn] [pid 5707] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
Jun 17 17:48:35 ww-test httpd[5707]: AH00543: httpd: bad user name ${APACHE_RUN_USER}
Jun 17 17:48:35 ww-test systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jun 17 17:48:35 ww-test systemd[1]: Ignoring invalid environment assignment 'export APACHE_RUN_USER=apache': /etc/sysconfig/httpd
Jun 17 17:48:35 ww-test systemd[1]: Ignoring invalid environment assignment 'export APACHE_RUN_GROUP=apache': /etc/sysconfig/httpd
Jun 17 17:48:35 ww-test systemd[1]: Ignoring invalid environment assignment 'export APACHE_PID_FILE=/var/run/httpd$SUFFIX.pid': /etc/sysconfig/httpd
Jun 17 17:48:35 ww-test systemd[1]: Ignoring invalid environment assignment 'export APACHE_RUN_DIR=/var/run/httpd$SUFFIX': /etc/sysconfig/httpd
Jun 17 17:48:35 ww-test systemd[1]: Ignoring invalid environment assignment 'export APACHE_LOCK_DIR=/var/lock/httpd$SUFFIX': /etc/sysconfig/httpd
Jun 17 17:48:35 ww-test systemd[1]: Ignoring invalid environment assignment 'export APACHE_LOG_DIR=/var/log/httpd$SUFFIX': /etc/sysconfig/httpd
Jun 17 17:48:35 ww-test kill[5708]: kill: cannot find process ""
Jun 17 17:48:35 ww-test systemd[1]: httpd.service: control process exited, code=exited status=1
Jun 17 17:48:35 ww-test systemd[1]: Failed to start The Apache HTTP Server.
I tried source envvars to test if the environemts work but it did not.
Is there any way that I can add the environment variables so that it applies to whenever I start Apache?
Thanks!
Within httpd.conf, declare your variable(s) with: Define (Preferably at the very first line)
Define APACHE_RUN_USER Apache
You can later use this variable like so:
User ${APACHE_RUN_USER}
Refer link for more information.
Related
Hi I am trying to create a python file that reloads apache2 the code of this file is:
import os
os.system("service apache2 reload")
When I use the command in the terminal everything works fine but when I run the python script I got this error:
Job for apache2.service failed.
See "systemctl status apache2.service" and "journalctl -xe" for details.
so I checked the journalctl and got this:
nov 29 13:50:19 gerrietech apachectl[37415]: Action 'graceful' failed.
nov 29 13:50:19 gerrietech apachectl[37415]: The Apache error log may have more information.
end this comes out of the error log:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.50.183. Set the 'ServerName' directive globally to suppress this message
[Mon Nov 29 13:37:35.533656 2021] [mpm_prefork:notice] [pid 36741] AH00163: Apache/2.4.46 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Mon Nov 29 13:37:35.533672 2021] [core:notice] [pid 36741] AH00094: Command line: '/usr/sbin/apache2'
[Mon Nov 29 13:38:23.180736 2021] [mpm_prefork:notice] [pid 36741] AH00169: caught SIGTERM, shutting down
[Mon Nov 29 13:38:45.809351 2021] [mpm_prefork:notice] [pid 37219] AH00163: Apache/2.4.46 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Mon Nov 29 13:38:45.809422 2021] [core:notice] [pid 37219] AH00094: Command line: '/usr/sbin/apache2'
How do i fix this?
After i used /etc/init.d/apache2 reload instead of service apache2 restarti dont get any errors and the script does what it is supposed to do
I am trying to migrate from Apache 2.2 on Debian 7 to Apache 2.4 on CentOS 7.
when httpd starts, it fails to start as below.
root# journalctl -xe
Jun 23 14:26:04 ww-test httpd[17716]: AH00526: Syntax error on line 47 of /etc/httpd/conf/httpd.conf:
Jun 23 14:26:04 ww-test httpd[17716]: Invalid command 'LockFile', perhaps misspelled or defined by a module not included in the server configuration
Jun 23 14:26:04 ww-test systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jun 23 14:26:04 ww-test kill[17718]: kill: cannot find process ""
Jun 23 14:26:04 ww-test systemd[1]: httpd.service: control process exited, code=exited status=1
Jun 23 14:26:04 ww-test systemd[1]: Failed to start The Apache HTTP Server.
vi httpd.conf
45 # The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
46 #
47 LockFile ${APACHE_LOCK_DIR}/accept.lock
48
I installed the related package as below although I am not sure if it is the right one.
============================================================================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================================================================
Installing:
lockfile-progs x86_64 0.1.15-7.el7 /lockfile-progs-0.1.15-7.el7.x86_64 50 k
Installing for dependencies:
liblockfile x86_64 1.08-17.el7 base 21 k
Transaction Summary
Thanks for reading it.
Replace this line:
LockFile ${APACHE_LOCK_DIR}/accept.lock
To:
Mutex file:/var/httpd/locks default
Directives AcceptMutex, LockFile, RewriteLock, SSLMutex, SSLStaplingMutex, and WatchdogMutexPath have been replaced with a single Mutex directive. You will need to evaluate any use of these removed directives in your 2.2 configuration to determine if they can just be deleted or will need to be replaced using Mutex
I'm running a Bitrix server over a CentOS Linux 7.4.1708 machine and I can't manage to get Apache work properly. I've tried restarting the Apache service but it didn't work.
I've checked the system logs via Webadmin and it shows the following:
[Mon Mar 05 03:33:12.118466 2018] [mpm_prefork:notice] [pid 1351]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 03:33:12.118482 2018] [core:notice] [pid 1351] AH00094:
Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Mar 05 11:19:46.641040 2018] [mpm_prefork:notice] [pid 1351]
AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 05 11:20:15.021546 2018] [suexec:notice] [pid 1360] AH01232:
suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 05 11:20:15.107376 2018] [so:warn] [pid 1360] AH01574: module
socache_shmcb_module is already loaded, skipping
[Mon Mar 05 11:20:17.068083 2018] [mpm_prefork:notice] [pid 1360]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 11:20:17.068138 2018] [core:notice] [pid 1360] AH00094:
Command line: '/usr/sbin/httpd -f /etc/httpd/conf/httpd-scale.conf -D
FOREGROUND'
[Mon Mar 05 11:36:43.537842 2018] [mpm_prefork:notice] [pid 1360]
AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 05 11:37:13.314311 2018] [suexec:notice] [pid 1351] AH01232:
suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 05 11:37:13.351957 2018] [so:warn] [pid 1351] AH01574: module
socache_shmcb_module is already loaded, skipping
[Mon Mar 05 11:37:15.361335 2018] [mpm_prefork:notice] [pid 1351]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 11:37:15.361360 2018] [core:notice] [pid 1351] AH00094:
Command line: '/usr/sbin/httpd -f /etc/httpd/conf/httpd-scale.conf -D
FOREGROUND'
[Mon Mar 05 11:49:01.192086 2018] [mpm_prefork:error] [pid 1351]
AH00161: server reached MaxRequestWorkers setting, consider raising
the MaxRequestWorkers setting
[Mon Mar 05 12:01:13.778293 2018] [mpm_prefork:notice] [pid 1351]
AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 05 12:01:43.297586 2018] [suexec:notice] [pid 1383] AH01232:
suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 05 12:01:43.371237 2018] [so:warn] [pid 1383] AH01574: module
socache_shmcb_module is already loaded, skipping
[Mon Mar 05 12:01:44.932973 2018] [mpm_prefork:notice] [pid 1383]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 12:01:44.933001 2018] [core:notice] [pid 1383] AH00094:
Command line: '/usr/sbin/httpd -f /etc/httpd/conf/httpd-scale.conf -D
FOREGROUND'
I don't have any clue on what the problem might be. Apache used to work fine until we installed a Bitrix update on the server.
Any sort of help or comment about this would be much appreciated.
Did you increase the MaxRequestWorkers setting as suggested in the logs?
Find the corresponding file:
grep -Ril MaxRequestWorkers /etc/httpd/
On CentOS usually it is /etc/httpd/conf/httpd.conf. Open the file, increase the value of MaxRequestWorkers and restart the web server for the changes to take effect:
systemctl restart httpd
Apache Virtual Host documentation:
If you are trying to debug your virtual host configuration, you may find the Apache -S command line switch useful. That is, type the following command:
/usr/local/apache2/bin/httpd -S
This command will dump out a description of how Apache parsed the configuration file. Careful examination of the IP addresses and server names may help uncover configuration mistakes. (See the docs for the httpd program for other command line options)
# /usr/local/apache2/bin/httpd -S
bash: /usr/local/apache2/bin/httpd: No such file or directory
# find / -type f -iname apache2
/etc/monit/monitrc.d/apache2
/etc/init.d/apache2
/etc/default/apache2
/etc/logrotate.d/apache2
/etc/bash_completion.d/apache2
/etc/cron.daily/apache2
/usr/share/php5/sapi/apache2
/usr/share/lintian/overrides/apache2
/usr/sbin/apache2
# /usr/sbin/apache2 -S
[Tue Jul 19 15:18:49.663497 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Tue Jul 19 15:18:49.663887 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Tue Jul 19 15:18:49.664071 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Tue Jul 19 15:18:49.664244 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Tue Jul 19 15:18:49.664428 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue Jul 19 15:18:49.684790 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
[Tue Jul 19 15:18:49.685433 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
So, what should I be typing instead of /usr/local/apache2/bin/httpd -S on Debian 8 with Apache 2.4.10 ?
My system:
# lsb_release -da
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.1 (jessie)
Release: 8.1
Codename: jessie
Turnkey LAMP Debian 8 Core 14.1 LAMP Stack - Web Stack (MySQL)
$ apache2 -v
Server version: Apache/2.4.10 (Debian)
Server built: Aug 1 2015 20:53:57
Installed Varnish from yum; but immediate error when initiating via systemctl.
Jul 28 14:11:54 localhost.localdomain varnishd[6546]: .init_func = VGC_function_vcl_init,
Jul 28 14:11:54 localhost.localdomain varnishd[6546]: .fini_func = VGC_function_vcl_fini,
Jul 28 14:11:54 localhost.localdomain varnishd[6546]: };
Jul 28 14:11:54 localhost.localdomain varnishd[6557]: Assert error in main(), mgt/mgt_main.c line 686:
Jul 28 14:11:54 localhost.localdomain varnishd[6557]: Condition((daemon(1,0)) == 0) not true.
Jul 28 14:11:54 localhost.localdomain varnishd[6557]: errno = 19 (No such device)
Jul 28 14:11:54 localhost.localdomain systemd[1]: Failed to read PID from file /var/run/varnish.pid: Invalid argument
Jul 28 14:11:54 localhost.localdomain systemd[1]: varnish.service never wrote its PID file. Failing.
Jul 28 14:11:54 localhost.localdomain systemd[1]: Failed to start Varnish a high-perfomance HTTP accelerator.
Jul 28 14:11:54 localhost.localdomain systemd[1]: Unit varnish.service entered failed state.
SELinux is disabled; package was installed via root. This is a fresh install.
Looks like you need to reboot. ;)
The message:
Failed to read PID from file /var/run/varnish.pid Invalid argument
is non-critical. It is just systemd trying to read the pidfile too early. You can poll status with:
systemctl status varnish
If its "Main PID" entry is matching the contents of /var/run/varnish.pid(and if varnishd is started via systemd, it always does), you can ignore that message. This is fixed in later versions of systemd.