previously i had error in installing apache2 for python, this is the link
I thought i should continue there but right now i'm getting a new error so posting it as a new one this is what the problem is
I have placed a file hello.py having code
#!/usr/bin/python
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello Word - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! This is my first CGI program</h2>'
print '</body>'
print '</html>'
in a folder /var/www/cgi-bin when I run this on apache2 using
http://localhost/cgi-bin/hello.py
i'm getting this error
The requested URL /cgi-bin/hello.py was not found on this server. Apache/2.2.14(Ubuntu)Server at localhost Port 80
This is the code that i found in the default page in sites-available folder:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
</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>
This is what i could find in the error log:
[Fri May 06 13:41:22 2011] [notice] mod_python: using mutex_directory /tmp
[Fri May 06 13:41:22 2011] [notice] Apache/2.2.14 (Ubuntu) mod_python/3.3.1 Python/2.6.5 mod_wsgi/2.8 configured -- resuming normal operations
[Fri May 06 14:23:03 2011] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico
[Fri May 06 14:23:03 2011] [debug] mod_deflate.c(615): [client 127.0.0.1] Zlib: Compressed 284 to 218 : URL /favicon.ico
[Fri May 06 14:23:11 2011] [notice] mod_python (pid=2038, interpreter='127.0.1.1'): Importing module '/var/www/cgi-bin/hello.py'
[Fri May 06 14:23:11 2011] [debug] mod_deflate.c(615): [client 127.0.0.1] Zlib: Compressed 289 to 222 : URL /cgi-bin/hello.py
[Fri May 06 14:23:11 2011] [error] /usr/lib/python2.6/dist-packages/mod_python/importer.py:32: DeprecationWarning: the md5 module is deprecated; use hashlib instead
[Fri May 06 14:23:11 2011] [error] import md5
[Fri May 06 14:23:25 2011] [debug] mod_deflate.c(615): [client 127.0.0.1] Zlib: Compressed 289 to 222 : URL /cgi-bin/hello.py
This is what i could find in access.log:
172.16.0.73 - - [06/May/2011:02:29:02 +0530] "GET / HTTP/1.1" 200 492 "-" "EZI_WIN_HTTP_AGENT"
172.16.0.73 - - [06/May/2011:02:46:47 +0530] "GET / HTTP/1.1" 200 492 "-" "EZI_WIN_HTTP_AGENT"
127.0.0.1 - - [06/May/2011:14:23:03 +0530] "GET /favicon.ico HTTP/1.1" 404 501 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3"
127.0.0.1 - - [06/May/2011:14:23:10 +0530] "GET /cgi-bin/hello.py HTTP/1.1" 404 504 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3"
127.0.0.1 - - [06/May/2011:14:23:25 +0530] "GET /cgi-bin/hello.py HTTP/1.1" 404 504 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3"
127.0.0.1 - - [06/May/2011:15:10:33 +0530] "GET /cgi-bin/hello.py HTTP/1.1" 404 505 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3"
125.224.195.218 - - [06/May/2011:15:15:10 +0530] "CONNECT 203.188.201.253:25 HTTP/1.1" 405 539 "-" "-"
172.16.0.25 - - [06/May/2011:15:45:53 +0530] "HEAD / HTTP/1.0" 200 277 "-" "-"
127.0.0.1 - - [06/May/2011:21:36:32 +0530] "GET /cgi-bin/hello.py HTTP/1.1" 404 505 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3"
127.0.0.1 - - [06/May/2011:21:36:35 +0530] "GET /favicon.ico HTTP/1.1" 404 500 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3"
Please help me through this.
In your Apache configuration, you need to change the Directory directive to: <Directory /var/www/cgi-bin> if this is where you intend to host your mod_python scripts.
UPDATE:
You're placing your python script in /var/www/cgi-bin but /cgi-bin/ is defined to point to /usr/lib/cgi-bin. You need to standardize on one location for /cgi-bin/.
Here's what I would propose as your corrected Apache configuration. Note that I didn't remove any lines, I only commented out the lines that are not needed or have been replaced.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
#<Directory /var/www>
<Directory /var/www/cgi-bin>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
</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>
UPDATE 2:
Now that your Apache configuration is correct, and we've verified that your module is importing correctly, you're still getting a 404. This is because you are using the mod_python publisher handler, which expects a different usage than what you have implemented. Basically, you have implemented a simple CGI script that just prints output. mod_python has a specific API for executing your module. You should try this example to get an understanding of how it works.
To implement your test module as a valid mod_python publisher, you could change hello.py to this:
def index(req):
return """<html>
<head>
<title>Hello Word - First CGI Program</title>
</head>
<body>
<h2>Hello Word! This is my first CGI program</h2>
</body>
</html>"""
Note that the reason you were getting a 404 error (even though the module was imported) is explained on this page:
The traversal will stop and
HTTP_NOT_FOUND will be returned to the
client if:
Any of the traversed object's names
begin with an underscore ("_"). Use
underscores to protect objects that
should not be accessible from the web.
A module is encountered. Published
objects cannot be modules for security
reasons.
If an object in the path could not be
found, HTTP_NOT_FOUND is returned to
the client.
Related
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.
On an apache2 server, I recently cloned an app 'MyApp' from github. But I'm not able to access it through url 133.29.22.57/MyApp/ (ip address is dummy) ? I have tried setting permissions for /var/www/ folder to 777, I also created a new file myapp.conf in etc/apache2/sites-available/ , then I used a2ensite to make it live, then restarted server but still can't access the site. Please help.
Here are the contents of my myapp.conf file :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/MyApp/
<Directory /var/www/MyApp/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Some (possibly) relevant info from apache2.conf
Mutex file:${APACHE_LOCK_DIR} default
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
#
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
IncludeOptional conf-enabled/*.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
UPDATE
some of the content that you may find relevant which I found under /var/log/apache2/access.log...
169.149.128.75 - - [20/Mar/2017:12:30:49 +0000] "GET /MyApp HTTP/1.1" 404 497 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
169.149.128.75 - - [20/Mar/2017:12:31:01 +0000] "GET /MyApp/index.php HTTP/1.1" 404 507 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
169.149.128.75 - - [20/Mar/2017:12:31:05 +0000] "GET /MyApp/index.php HTTP/1.1" 404 506 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
169.149.128.75 - - [20/Mar/2017:12:31:40 +0000] "GET /MyApp/index.php HTTP/1.1" 404 507 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
::1 - - [20/Mar/2017:12:36:02 +0000] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.21 (internal dummy connection)"
moreover,
I tried running command /usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE
which says that the following variables are not defined :
${APACHE_LOCK_DIR} ${APACHE_PID_FILE } ${APACHE_RUN_GROUP } ${APACHE_LOG_DIR}
Setting permissions for /var/www/ folder to 777 is a very bad habit.
Give the directory (recursive) to the web server user, usually www-data like "chown -R www-data:www-data /var/www"
Then do a separated log, something like "mywebsite.error.log" and "mywebsite.access.log" so you'll be able to see quickly what's going on.
ErrorLog ${APACHE_LOG_DIR}/mywebsite.error.log
CustomLog ${APACHE_LOG_DIR}/mywebsite.access.log combined
Then tell us more precisely what's going on and I'll update my answer.
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
Have configured vagrant Ubuntu 14.04 machine with virtual box.
I get the error (in browser)
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
And get the error (/var/log/apache2/error.log):
[Wed Apr 01 20:58:34.609309 2015] [fastcgi:error] [pid 24066:tid 3046103872] (104)Connection reset by peer: [client 192.168.33.1:59777] FastCGI: comm with server "/var/www/html/circulocolaborativo.com.br/php5.fcgi" aborted: read failed
[Wed Apr 01 20:58:34.614694 2015] [fastcgi:error] [pid 24066:tid 3046103872] [client 192.168.33.1:59777] FastCGI: incomplete headers (0 bytes) received from server "/var/www/html/circulocolaborativo.com.br/php5.fcgi"
My virtual host is configured with
<VirtualHost *:80>
Servername circulocolaborativo.local
DocumentRoot /var/www/html/circulocolaborativo.com.br
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# ErrorLog "/home/vagrant/logs/error_log"
<Directory /var/www/html/circulocolaborativo.com.br>
Options FollowSymLinks
DirectoryIndex index.php
Allowoverride all
Require all granted
</Directory>
Alias /php5.fcgi /var/www/html/circulocolaborativo.com.br/php5.fcgi
FastCGIExternalServer /var/www/html/circulocolaborativo.com.br/php5.fcgi -flush -host 127.0.0.1:5200 -idle-timeout 900
AddType application/x-httpd-fastphp5 .php
Action application/x-httpd-fastphp5 /php5.fcgi
<Location /var/www/html/circulocolaborativo.com.br/libraries/Sciere/ws/sptl >
AuthType Digest
AuthName "WebService SPTL"
AuthDigestDomain /libraries/Sciere/ws/sptl/
AuthDigestProvider file
AuthUserFile /var/www/html/.digest_pw_sptl
Require valid-user
</Location>
</VirtualHost>
Could someone help me to solve this issue? I can't figure out what is going on. I'm using php-fpm with fastcgi module.
Google Page Speed and YSlow says that compression isn't enabled.
Here's my config:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName episodecalendar.com
ServerAlias www.episodecalendar.com
DocumentRoot /var/www/episodecalendar.com/production/current/public/
<Directory /var/www/episodecalendar.com/production/current/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/www/episodecalendar.com/production/current/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/www/episodecalendar.com/production/current/access.log combined
ServerSignature On
#Gzip/deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog /var/log/apache2/deflate_log deflate
</VirtualHost>
Have I missed something?
mod_deflate IS enabled, and the header says:
Accept-Encoding gzip,deflate
and the actual log looks like this:
"GET /stylesheets/application_packaged.css?1292696861 HTTP/1.1" 6927/31722 (21%)
"GET /stylesheets/print.css?1292696853 HTTP/1.1" 323/625 (51%)
"GET /javascripts/application_packaged.js?1292696861 HTTP/1.1" 25146/74582 (33%)
PS. I run Rails with mod-Passenger
Sorry my bad. I'm behind a proxy server at the office, so by the time it hits my computer, the request is already unpacked.