attempt to invoke directory as script? - apache

is something wrong with my apache config ?
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">
AllowOverride None
AddHandler cgi-script pl cgi
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

nothing is wrong with your httpd configs, you need to configure httpd to redirect to the directory index. it is literally trying to execute the directory "/etc/www/cgi-bin" as cgi.

Related

Directory not rendering images because of cgi

My server doesn't render any images under the cgi directory, I know that this is because apache is told to run every file under that directory as a cgi program.
I would like to adjust the settings to tell apache to run all the .cgi and .pl as cgi programs but run the rest of files as they should be.
For instance, if I go to example.com/x.gif from a browser I can see the image, but if I go to example.com/cgi-bin/x.gif I can't. (being the image in both dirs, of course, and with 775)
The problem is that I don't know how to tell that to apache, this is the httpd.include
<Directory /var/www/vhosts/example.com/httpdocs>
<IfModule mod_perl.c>
<Files ~ (\.pl$)>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
allow from all
PerlSendHeader On
</Files> </IfModule> <IfModule mod_python.c>
<Files ~ (\.py$)>
SetHandler python-program
PythonHandler mod_python.cgihandler
</Files> </IfModule> <IfModule mod_fcgid.c>
<Files ~ (\.fcgi)>
SetHandler fcgid-script
Options +FollowSymLinks +ExecCGI
</Files> </IfModule> <IfModule mod_fcgid.c>
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
Options +ExecCGI
allow from all
</Files> </IfModule>
SSLRequireSSL
Options -Includes +ExecCGI
</Directory>
I found a solution.
As I said, apache is told to run every file under that directory as a cgi program. So are needed new rules to tell apache to use a default handler for those filetypes different from .php , .pl or .cgi:
<Directory /var/www/vhosts/example.com/httpdocs/cgi-bin>
<FilesMatch "^(?!.*\.(cgi|php|pl)$).*$">
SetHandler default-handler
</FilesMatch>
</Directory>
If you can't access the httpd.conf for any reason you still can do the trick with .htaccess adding this three lines to the .htaccess file of the cgi-bin folder:
<FilesMatch "^(?!.*\.(cgi|php|pl)$).*$">
SetHandler default-handler
</FilesMatch>

Apache php httpd-xampp.conf alias not working

I have httpd-xampp.conf with
<IfModule alias_module>
...
Alias /examples "D:/xampp/htdocs/examples/"
<Directory "D:/xampp/htdocs/examples">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</IfModule>
an in examples folder i have index.html, but when i access http://localhost:8880/examples, i have error
This page was not found
You are not logged in.
Back Log in Issues
Is there any error of my config? other alias : phpmyadmin, security work well.
I change httpd-xampp.conf to
<IfModule alias_module>
...
#!!! Don't know why
#Alias /examples "D:/xampp/examples/" don't work
Alias /my-examples "D:/xampp/examples/"
<Directory "D:/xampp/examples">
AllowOverride AuthConfig
Require all granted
</Directory>
</IfModule>
#
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info|my-examples))">
Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>
and http://localhost:8880/my-examples work now

apache2: render web pages

I am having following configuration in my apache2.conf:
ScriptAlias /cgi-bin/ "/var/www/temp/pages"
<Directory "/var/www/temp/pages/">
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "/var/www/temp/scripts/">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
The intention is that in one directory I store my web pages and in another - the scripts. I have a sample index.html file placed in /var/www/temp/pages/ dir but when I try to access from browser:
<ip>/cgi-bin/index.html
I get below error:
Exec format error ....
Prematrure end of script
How can I fix this issue?

CakePHP pretty URL's not working on production server

I have developed a CakePHP application that I have now deployed to my production server, however pretty URLs do not work.
Here is my Apache vhost for the site:
<VirtualHost *:80>
ServerName site.com
ServerAdmin support#site.com
DocumentRoot /home/whitey/sites/site.com/htdocs/app/webroot/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/whitey/sites/site.com/htdocs/app/webroot/>
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 None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/whitey/sites/site.com/logs/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /home/whitey/sites/site.com/logs/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>
As you can see, the document root is set to the webroot directory in my app. Inside that directory, there is this .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
This entire setup works perfectly with my local machine running XAMPP, so I'm not sure what's wrong. The only thing I can think of is the rewrite rules aren't taking effect because of a setting in my vhost. But I haven't got enough knowledge of the Apache config files to know how to fix it.
Thanks.
Nevermind, I'm an idiot. I forgot to enable the mod_rewrite module for Apache when I set it up last night. Here's the fix:
sudo a2enmod rewrite
sudo service apache2 restart

Running mod-wsgi code (.wsgi) with Apache2

I'm using mod_wsgi on apache2/Mac OS X by setting apache server as follows.
<Directory /Library/WebServer/Documents/wsgi/scripts>
Order allow,deny
Allow from all
</Directory>
<IfModule wsgi_module>
WSGIScriptAlias /test /Library/WebServer/Documents/wsgi/scripts/test.wsgi
</IfModule>
With this configuration, I could call test.wsgi with http://.../test
Now, I need to execute it by calling as follows.
http://.../wsgi/test.wsgi
I have the following code.
<Directory /Library/WebServer/Documents/wsgi/scripts>
Order allow,deny
Allow from all
AddHandler wsgi-script .wsgi
</Directory>
<IfModule wsgi_module>
WSGIScriptAlias /test /Library/WebServer/Documents/wsgi/scripts/test.wsgi
Alias /wsgi/ /Library/WebServer/Documents/wsgi/scripts/
</IfModule>
I thought about using Alias so that I could link wsgi script directory to /wsgi/, and I expect Addhandler can handle the wsgi file, but it doesn't work.
What's wrong with my apache2 setup?
SOLVED
<Directory /Library/WebServer/Documents/wsgi/scripts>
Options ExecCGI Indexes
AddHandler cgi-script .cgi
AddHandler wsgi-script .wsgi
Order allow,deny
Allow from all
</Directory>
Alias /wsgi/ /Library/WebServer/Documents/wsgi/scripts/
Don't use AddHandler with WSGIScriptAlias, you need to use AddHandler with Alias directive. You will need to set ExecCGI option as well for directory. See:
http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines