Timeout when reading response headers from daemon process - apache2

I am using mod_wsgi with apache2.
[Thu Aug 29 10:50:48.050923 2019] [mpm_prefork:notice] [pid 24309] AH00163: Apache/2.4.18 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
From the above line, you can see that mod_wsgi version is 4.3.0 and apache 2.4.18.
I am running a web application made of Trac framework. And a Django app. Both of them interconnected with some linking. And a Zend app is also part of the overall system.
The major problem is that the app goes unusable by producing "Gateway time out" errors.
When examined, I found 'apache2' is taking too much of CPU. Sometimes 'postgresql' takes too much of CPU. I am not sure why this is happening. In a hope, I tried restarting the services apache and postgresql but it doesn't help much. The same problem continues.
30820 postgres 20 0 314748 46120 42936 R 98.3 1.1 0:26.04 postgres
Above line is part of 'top' command in which postgres uses 98.3% of CPU.
Below is my virtual host script.
<VirtualHost *:80>
ServerName subdomain.domain.com
WSGIDaemonProcess prismdjango user=www-data group=www-data home=/opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO
WSGIDaemonProcess prismnew user=www-data group=www-data home=/opt/PRISM30/
WSGIScriptAlias /audittool /opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO/PRISMDJANGO/wsgi.py
WSGIScriptAlias /api /opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO/PRISMDJANGO/wsgi.py
WSGIScriptAlias /project /opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO/PRISMDJANGO/wsgi.py
WSGIScriptAlias /accounts /opt/PRISM30/PRISM30/wsgi.py
WSGIProcessGroup prismdjango
WSGIProcessGroup prismnew
Alias /Audittool/static /opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO/Audittool/static
Alias /user_deactivate /var/www/html/user_deactivate
Alias /contractual_requirements/static /opt/PRISM30/contractual_requirements/static/
<Directory /opt/PRISM30>
WSGIProcessGroup prismnew
WSGIApplicationGroup %{GLOBAL}
Require all granted
Options ExecCGI
AddHandler wsgi-script .wsgi
#Options Indexes FollowSymLinks Includes ExecCGI
#AllowOverride All
#Require all granted
<Files PRISM30/wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /opt/Production/CustomPlugins/CommonPlugin/PRISMDJANGO>
WSGIProcessGroup prismdjango
WSGIApplicationGroup %{GLOBAL}
Require all granted
Options ExecCGI
AddHandler wsgi-script .wsgi
#Options Indexes FollowSymLinks Includes ExecCGI
#AllowOverride All
#Require all granted
<Files PRISMDJANGO/wsgi.py>
Require all granted
</Files>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
DocumentRoot /opt/TracProjects
WSGIDaemonProcess prism user=www-data group=www-data home=/opt/TracProjects
WSGIScriptAlias / /usr/share/trac/trac.wsgi
WSGIProcessGroup prism
<Directory "/opt/TracProjects">
WSGIApplicationGroup %{GLOBAL}
Options Indexes FollowSymLinks
#AddHandler cgi-script .cgi
#Options Indexes ExecCGI
#DirectoryIndex index.cgi
Order allow,deny
Allow from all
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
<Location /opt/TracProjects>
WSGIProcessGroup prism
</Location>
# TRAC ENV PARENT DIRECTORIES SETUP
DirectoryIndex index.php index.cgi
Alias /authtimesheet "/var/www/ZendApp/public"
#DocumentRoot /var/www/ZendApp/public
#SetEnv APPLICATION_ENV "development"
<Directory /var/www/ZendApp/public>
Options Indexes FollowSymLinks
DirectoryIndex index.php
AllowOverride All
#Order allow,deny
#Allow from all
Require all granted
</Directory>
</VirtualHost>
From apache log file,
[Wed Aug 28 18:31:25.478081 2019] [wsgi:error] [pid 23046] [client 172.24.188.116:36348] Timeout when reading response headers from daemon process 'prism': /usr/share/trac/trac.wsgi, referer: http://subdomain.domain.com
[Wed Aug 28 18:34:30.461158 2019] [wsgi:error] [pid 24138] [client 172.24.188.116:36576] Truncated or oversized response headers received from daemon process 'prism': /usr/share/trac/trac.wsgi, referer: http://subdomain.domain.com
I just want to get rid of this Time outs!Hope this Truncated or oversized response would be of another clue.
Below line is from postgresql log.
could not receive data from client: Connection reset by peer.

Related

Dancer2 - Cannot deploy with Apache2 using Plack

I am trying to deploy Dancer2 app using Plack on Apache2. But after changing all the configurations on port 80 - it shows me directory listing instead of the application itself
Here is my running application on local:
root#dancer-cmuscheduler:/home/ADI/dancer_scheduler# plackup
bin/app.psgi HTTP::Server::PSGI: Accepting connections at
http://0:5000/
This runs just fine on port 5000.
However, I would like to deploy on apache2. Here is my configruations:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /data
SetEnv DANCER_ENVIRONMENT "production"
<Directory /var/www/cmuscheduler>
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Location />
SetHandler perl-script
PerlResponseHandler Plack::Handler::Apache2
PerlSetVar psgi_app /var/www/cmuscheduler/bin/app.psgi
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>
I have been trying to debug for 4 hours now. The funny thing is there is no helpful logs in the log file associated that would nudge me in the right direction
[Thu Jul 14 02:23:14.424149 2016] [mpm_event:notice] [pid 7468:tid
140401436669824] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming
normal operations [Thu Jul 14 02:23:14.424306 2016] [core:notice] [pid
7468:tid 140401436669824] AH00094: Command line: '/usr/sbin/apache2'
Please advice

Apache2 is not wanting to be deleted

I am having trouble removing a VirtualHost, so I thought of just simply editing the /etc/apache2/sites-available/default file. It turns out that I am trying to add the original 'index.html' file, which I have in the /var/www/ directory. But it is not working because another VirtualHost has taken port 80 and I don't see my 'index.html' file listed there in the default file. I am super frustrated, so I am thinking of just doing a fresh install of the apache2 service. But even though I use this command to remove it:
sudo apt-get install --remove apache2 php5 libapache2-mod-php5
Even though I do this, it is not removed and I get this error at the end of the process:
Errors were encountered while processing:
libopenvnc-imgproc2.3
libavfilter2:armhf
libav-tools
ffmpeg
E: Sub-process /usr/bin/dpkg returned an error code (1)
Is there any way to do a fresh install of apache2 along with php5 and libapache2-mod-php5 as I had installed them when I first got my Pi? I am just lost, I have gone to a million forums and none have helped me.....
Here is the 'default' file text:
NameVirtualHost *:8091
NameVirtualHost *:80
NameVirtualHost *:443
This is what I tried doing, but it didn't work, it said the file couldn't be found!
<VirtualHost *:80>
DocumentRoot /var/www/remote_replay.php
ServerName 192.168.1.80
</VirtualHost>
This part below works fine, but I want it removed!!!!!
WSGIDaemonProcess web2py user=www-data group=www-data
<VirtualHost *:8091>
WSGIProcessGroup web2py
WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
WSGIPassAuthorization On
<Directory /home/www-data/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \
/home/www-data/web2py/applications/$1/static/$2
<Directory /home/www-data/web2py/applications/*/static/>
Options -Indexes
Order Allow,Deny
Allow from all
</Directory>
<Location /admin>
Deny from all
</Location>
<LocationMatch ^/([^/]+)/appadmin>
Deny from all
</LocationMatch>
CustomLog /var/log/apache2/access.log common
ErrorLog /var/log/apache2/error.log
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/self_signed.cert
SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key
WSGIProcessGroup web2py
WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
WSGIPassAuthorization On
<Directory /home/www-data/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \
/home/www-data/web2py/applications/$1/static/$2
<Directory /home/www-data/web2py/applications/*/static/>
Options -Indexes
ExpiresActive On
ExpiresDefault "access plus 1 hour"
Order Allow,Deny
Allow from all
</Directory>
CustomLog /var/log/apache2/access.log common
ErrorLog /var/log/apache2/error.log
</VirtualHost>
There is a problem with your virtual host configuration, DocumentRoot must be a directory. If you want to serve a specific file, use DocumentIndex to specify the files to use in order of preference:
<VirtualHost *:80>
DocumentRoot /var/www/
DocumentIndex remote_replay.php index.php index.html index.htm
ServerName 192.168.1.80
</VirtualHost>

ZPanelcp , Domains activation not work

-Hello everyone , I just rent an a dedicated server (ubuntu 12.4) and i install apache + php, mySQL etc ...but using SSH to creat domains (virtual hosts) it is a litle bit laborer so I decided to install some GUI admin panel and also decided for ZPanelcp last version so everything installed fine without errors and I set first time two domains something like :
new.domain.com
new.otherdomain.com
these domains has been activated successfully without set zpanel DNS for those domains but next day I notice when I try to create again other domains in my ZPanel show as "live" but in my webbrowser can not see so in reality they were not activated , ok first time I Run Daemon again and restart BIND also restart apache I try a few changes in my server conf files but nothing I reboot my server also nothing my server use one static ip.
Here are my Zpanel, apache2 conf files.
Apache2 files:
folder files:
/etc/apache2/apache2.conf
# Here is last lines of this files related to my problem
# Include of directories ignores editors' and dpkg's backup files,
# see the comments above for details.
# Include generic snippets of statements
Include conf.d/
# Include the virtual host configurations:
Include sites-enabled/
ServerName cp.zpanel.com
Include /etc/zpanel/configs/apache/httpd.conf
/etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
/etc/apache2/sites-enabled/000-default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/zpanel/configs/apache/httpd.conf
# ZPanel Apache Include file for CentOS Linux
# Written by Bobby Allen, 15/05/2011
# Set the Zpanel Alias (used for development, sable will eventually use a VHOST)
Alias /zpanel /etc/zpanel/panel
# Setup the directory settings and PHP security flags for the Zpanel application directory.
<Directory /etc/zpanel/panel>
Options FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_value upload_tmp_dir /var/zpanel/temp
</IfModule>
</Directory>
# Disallow web access to directories that don't need it/that we don't want people looking in!
<Directory /etc/zpanel/panel/cnf>
Order Deny,Allow
Deny from All
</Directory>
# Set server tokens (security??)
ServerTokens Maj
# Now we include the generic VHOST configuration file that holds all the ZPanel user hosted vhost data
Include /etc/zpanel/configs/apache/httpd-vhosts.conf
/etc/zpanel/configs/apache/httpd-vhosts.conf
################################################################
# Apache VHOST configuration file
# Automatically generated by ZPanel 10.0.1
# Generated on: 09:15 13th Dec 2012 CET
################################################################
NameVirtualHost *:80
# Configuration for ZPanel control panel.
<VirtualHost *:80>
ServerAdmin zadmin#localhost
DocumentRoot "/etc/zpanel/panel/"
ServerName cp.zpanel.com
ServerAlias *.cp.zpanel.com
AddType application/x-httpd-php .php
<Directory "/etc/zpanel/panel/">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# Custom settings are loaded below this line (if any exist)
</VirtualHost>
################################################################
# ZPanel generated VHOST configurations below.....
################################################################
# DOMAIN: new.domain.com
<virtualhost *:80>
ServerName new.domain.com
ServerAlias new.domain.com www.new.domain.com
ServerAdmin zadmin#localhost
DocumentRoot "/var/zpanel/hostdata/zadmin/public_html/new_domain_com"
php_admin_value open_basedir "/var/zpanel/hostdata/zadmin/public_html/new_domain_com:/var/zpanel/temp/"
php_admin_value suhosin.executor.func.blacklist "passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_$
ErrorLog "/var/zpanel/logs/domains/zadmin/new.domain.com-error.log"
CustomLog "/var/zpanel/logs/domains/zadmin/new.domain.com-access.log" combined
CustomLog "/var/zpanel/logs/domains/zadmin/new.domain.com-bandwidth.log" common
<Directory />
Options FollowSymLinks Indexes
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
AddType application/x-httpd-php .php3 .php
ScriptAlias /cgi-bin/ "/_cgi-bin/"
<location /cgi-bin>
AddHandler cgi-script .cgi .pl
Options ExecCGI -Indexes
</location>
ErrorDocument 403 /_errorpages/403.html
ErrorDocument 500 /_errorpages/500.html
ErrorDocument 404 /_errorpages/404.html
ErrorDocument 510 /_errorpages/510.html
DirectoryIndex index.html index.htm index.php index.asp index.aspx index.jsp index.jspa index.shtml index.shtm
# Custom Global Settings (if any exist)
# Custom VH settings (if any exist)
</virtualhost>
# END DOMAIN: new.domain.com
################################################################
##ETC other domains##
/etc/hosts
### Hetzner Online AG installimage
# nameserver config
# IPv4
127.0.0.1 localhost
6.8.81.52 Ubuntu-1210-quantal-64-minimal
#
# IPv6
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Check the permissions of httpd-vhosts.conf file. Maybe you don't have write permission.

Install Web2py in virtual hosting

Install Web2py by a script setup-web2py-ubuntu.sh, previously adjusted the way for their virtual hosting.
But it works only on port 443, and the 80 th issue
It works!
How to fix?
#NameVirtualHost *:80
#NameVirtualHost *:443
# If the WSGIDaemonProcess directive is specified outside of all virtual
# host containers, any WSGI application can be delegated to be run within
# that daemon process group.
# If the WSGIDaemonProcess directive is specified
# within a virtual host container, only WSGI applications associated with
# virtual hosts with the same server name as that virtual host can be
# delegated to that set of daemon processes.
WSGIDaemonProcess demo2.host.ru user=web2 group=client1
<VirtualHost *:80>
WSGIProcessGroup demo2.host.ru
WSGIScriptAlias / /var/www/clients/client1/web2/web/web2py/wsgihandler.py
WSGIPassAuthorization On
<Directory /var/www/clients/client1/web2/web/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(.*) \
/var/www/clients/client1/web2/web/web2py/applications/$1/static/$2
<Directory /var/www/clients/client1/web2/web/web2py/applications/*/static/>
Options -Indexes
Order Allow,Deny
Allow from all
</Directory>
<Location /admin>
Deny from all
</Location>
<LocationMatch ^/([^/]+)/appadmin>
Deny from all
</LocationMatch>
CustomLog /var/log/apache2/access.log common
ErrorLog /var/log/apache2/error.log
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /usr/local/ispconfig/interface/ssl/ispserver.crt
SSLCertificateKeyFile /usr/local/ispconfig/interface/ssl/ispserver.key
WSGIProcessGroup demo2.host.ru
WSGIScriptAlias / /var/www/clients/client1/web2/web/web2py/wsgihandler.py
WSGIPassAuthorization On
<Directory /var/www/clients/client1/web2/web/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(.*) \
/var/www/clients/client1/web2/web/web2py/applications/$1/static/$2
<Directory /var/www/clients/client1/web2/web/web2py/applications/*/static/>
Options -Indexes
ExpiresActive On
ExpiresDefault "access plus 1 hour"
Order Allow,Deny
Allow from all
</Directory>
CustomLog /var/log/apache2/access.log common
ErrorLog /var/log/apache2/error.log
</VirtualHost>
Create files: parameters_443.py and parameters_80.py in folder web2py.
password="pbkdf2(1000,20,sha512)$851a015489"
Still not working...
Plz help! :'(

Apache not seeing subdirectories of /var/www

I'm trying to get a basic site running under Apache 2. Eventually I'm aming to use mod_wsgi to serve a django applictation, but for now I've started with a really simple variation of the default virtual host, currently just showing a directory listing of /var/www. The problem I'm having is that the server can't seem to see the directory "/var/www/mysite". Viewing www.mysite.com/ gives me a listing as expected of /var/www directory, but only shows the files, not directories.
Please can anybody tell me if there's something obvious that I'm missing here.
Thanks in advance
Virtual Hosts file:
<VirtualHost *:80>
ServerName www.mysite.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks +Indexes
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Listing of /var/www (including security context 'ls -Zl /var/www')
-rw-r--r-- 1 www-data www-data ? 45 Jul 14 15:37 index.html__
-rw-r--r-- 1 www-data www-data ? 91 Aug 9 14:19 index2__.html
drw-r--r-- 2 www-data www-data ? 4096 Aug 9 14:36 mysite
Try changing the permissions of the mysite directory so that the apache user has execute permission on it:
chmod a+x mysite
Try giving the read access permission on the sub folder
chmod -R 775 /var/www/html/subfolder
Or
chmod -R 775 /var/www/subfolder
as per your sub directory structure

Resources