ScriptAlias having no effect on ability to execute .cgi files - apache

I have enabled alias_module and cgi_module in my apache 2.2 installation. I have added a section:
<IfModule alias_module>
ScriptAlias /digin-cgi/ "/opt/openbdjam/webroot1/push20/digin-cgi/"
</IfModule>
my scripts are 'x' executable permissioned and live in the file system directory /opt/openbdjam/webroot1/push20/digin-cgi. However, when i go to my webserver (something like the address below) in a browser i just get a 404 not found:
http://myserver.com/digin-cgi/test.cgi
In case it matters - my server root is set to:
DocumentRoot "/opt/openbdjam/webroot1"
no amount of restarting helps!
any ideas?

I beleive you'll need a directory declaration in there also. Since the cgi-bin is outside your document root, it isn't covered by the 'default'.
<Directory "/opt/openbdjam/webroot1/push20/digin-cgi/">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Alter your Options and AllowOverride settings as you see fit, but I imagine you'll want ExecCGI as a minimum.
More info here: http://httpd.apache.org/docs/current/mod/core.html#directory

Related

What ELSE can cause Apache to display a CGI instead of it's output?

I have a newly configured Apache 2.4.7 webserver (AIX7 ). It is displaying the contents of my CGIs instead of their output.
I have this in my conf file:
LoadModule cgi_module /opt/freeware/lib64/httpd/modules/mod_cgi.so
AddHandler cgi-script .cgi .pl
ScriptAlias /cgi-bin "/var/www/cgi-bin"
<Directory "/var/www/cgi-bin">
Options +FollowSymLinks +Includes -Indexes +ExecCGI
Order allow,deny
Allow from all
</Directory>
My CGIs behave as expected if run from the CLI. They are world-readable and world-executable. The shebang line is correct. There are no relevant messages in error_log.
What ELSE can cause the server to not execute a CGI?
OK, I figured it out. I had two different conf directories. Apache was looking at a configuration in a different location which had the default values.
Lesson learned: If Apache seems to be ignoring your config file, make sure you're looking at the right file.

You don't have permission to access /~iMac/ on this server. apache server

I am trying to use apache localhost
localhost works normally but http://localhost/~iMac/ give me the error in the title.
this is how I proceed:
i added a Sites folder under iMac
create file imac.conf under /etc/apache2/users
<Directory "/Users/imac/Sites/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
I also tried AllowOverride All
I uncomment tese lines in /etc/apache2/httpd.conf
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
Include /private/etc/apache2/extra/httpd-userdir.conf
and uncomment this line in /etc/apache2/extra/httpd-userdir.conf
Include /private/etc/apache2/users/*.conf
and then restart the server.
I tried lots of solution in the net but still have the same issue.
I faced the same issue, but I solved it by setting the options directive either in the global directory setting in the httpd.conf or in the specific directory block in httpd-vhosts.conf:
Options Indexes FollowSymLinks Includes ExecCGI
By default, your global directory settings is (httpd.conf line ~188):
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
</Directory>
set the options to : Options Indexes FollowSymLinks Includes ExecCGI
Finally, it should look like:
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
Also, you should check the folder's permissions so that the Apache process' owner has permissions to read/execute the specified path for the virtual host. On Windows this could rarely be a problem but on Linux it can be a more frequent cause of 403.
EDIT: You can look here for some solution also if you are hosting this on a Mac:
http://coolestguidesontheplanet.com/forbidden-403-you-dont-have-permission-to-access-username-on-this-server/

Forbidden You don't have permission to access / on this server [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
All I wanted to do today was to write a redirect rule to a subfolder, e.g.:
You enter the URL: example.com and you get redirected to example.com/subfolder
Such a simple wish. I tried to find a solution on the internet. The internet told me to add an .htaccess file in the htdocs root with:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteRule ^$ subfolder [L]
I did this. But no success obviously, they didn't told me I had to uncomment the module in httpd.conf:
LoadModule rewrite_module modules/mod_rewrite.so
So I did this too. No success again. They didn't told me I had to change my httpd.conf so that the .htaccess file would be enabled:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
DocumentRoot "c:/Apache24/htdocs"
<Directory "c:/Apache24/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Again no success, because I get this error when entering the URL:
Forbidden You don't have permission to access / on this server.
Now I'm stuck and I couldn't find any more solutions on the internet. I'm just running Apache 2.4 on my Windows 7 machine, for private reasons.
Found my solution thanks to Error with .htaccess and mod_rewrite
For Apache 2.4 and in all *.conf files (e.g. httpd-vhosts.conf, http.conf, httpd-autoindex.conf ..etc) use
Require all granted
instead of
Order allow,deny
Allow from all
The Order and Allow directives are deprecated in Apache 2.4.
WORKING Method { if there is no problem other than configuration }
By Default Appache is not restricting access from ipv4. (common external ip)
What may restrict is the configurations in 'httpd.conf' (or 'apache2.conf' depending on your apache configuration)
Solution:
Replace all:
<Directory />
AllowOverride none
Require all denied
</Directory>
with
<Directory />
AllowOverride none
# Require all denied
</Directory>
hence removing out all restriction given to Apache
Replace Require local with Require all granted at C:/wamp/www/ directory
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
# Require local
</Directory>
Solution is just simple.
If you are trying to access server using your local IP address and you are getting error saying like Forbidden You don't have permission to access / on this server
Just open your httpd.conf file from (in my case C:/wamp/bin/apache/apache2.2.21/conf/httpd.conf)
Search for
<Directory "D:/wamp/www/">
....
.....
</Directory>
Replace
Allow from 127.0.0.1
to
Allow from all
Save changes and restart your server.
Now you can access your server using your IP address
The problem lies in https.conf file!
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
The error occurs when hash(#) is removed or messed around with. These two lines should appear as shown above.
Found my solution on Apache/2.2.15 (Unix).
And Thanks for answer from #QuantumHive:
First:
I finded all
Order allow,deny
Deny from all
instead of
Order allow,deny
Allow from all
and then:
I setted
#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
#<Directory /var/www/html>
# AllowOverride FileInfo AuthConfig Limit
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
# <Limit GET POST OPTIONS>
# Order allow,deny
# Allow from all
# </Limit>
# <LimitExcept GET POST OPTIONS>
# Order deny,allow
# Deny from all
# </LimitExcept>
#</Directory>
Remove the previous "#" annotation to
#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
<Directory /var/www/html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
ps. my WebDir is: /var/www/html
This works for me on Mac OS Mojave:
<Directory "/Users/{USERNAME}/Sites/project">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
require all granted
</Directory>

Why might Apache forbid me from visiting this page?

Until recently, an internal Bugzilla install was working fine. Now, all requests to pages inside the http://example.com/bugzilla directory return 403/Forbidden. Pages outside that directory, for instance at http://example.com/test.html or http://example.com/test/index.html work as expected. This is the .htaccess file for the bugzilla directory, which is unchanged from the original:
# Don't allow people to retrieve non-cgi executable files or our private data
<FilesMatch (\.pm|\.pl|\.tmpl|localconfig.*)$>
deny from all
</FilesMatch>
<IfModule mod_expires.c>
<IfModule mod_headers.c>
<IfModule mod_env.c>
<FilesMatch (\.js|\.css)$>
ExpiresActive On
# According to RFC 2616, "1 year in the future" means "never expire".
# We change the name of the file's URL whenever its modification date
# changes, so browsers can cache any individual JS or CSS URL forever.
# However, since all JS and CSS URLs involve a ? in them (for the changing
# name) we have to explicitly set an Expires header or browsers won't
# *ever* cache them.
ExpiresDefault "now plus 1 years"
Header append Cache-Control "public"
</FilesMatch>
# This lets Bugzilla know that we are properly sending Cache-Control
# and Expires headers for CSS and JS files.
SetEnv BZ_CACHE_CONTROL 1
</IfModule>
</IfModule>
</IfModule>
AddHandler cgi-script .cgi .pl
DirectoryIndex index.cgi
This is the .htaccess file for the directory above the bugzilla directory. This is the public_html web root:
DirectoryIndex index.html
This is the Apache configuration file for the site:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/default/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/default/public_html>
DirectoryIndex index.cgi
AllowOverride Limit FileInfo Indexes
AddHandler cgi-script .cgi
Options Indexes FollowSymLinks MultiViews +ExecCGI -MultiViews +SymLinksIfOwnerMatch
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 ${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
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>
Note that even non-Bugzilla static HTML files in that directory are affected. For instance, I create /bugzilla/test.html in VIM, then I try to access it in the browser and see that it is also returning 403/Forbidden. All files, both in and outside that directory, have the same user ubuntu and the same permissions 644. The bugzilla directory itself has permissions 755, as does its parent public_html.
No 'control panels' such as Plesk are installed on the server, all configuration is done in Apache config files. Why might Apache have decided that I may not be authorized to view the bugzilla directory? This is on a public webserver hosted in Amazon Web Services, on Ubuntu Server 12.04 LTS.
Check the error_log file, it usually has very detailed information about why it returns a 403 Forbidden.
(It looks like a debian server? If you post questions like this, always mention the OS.)
I suspect it to be a rights issue - wrong owner. For debian/ubuntu, the given folder and its files should be owned by user "www-data". For Centos/Redhat I believe it should be "nobody". Check it, change it if necessary.
sudo chown -R www-data:www-data test
NB: If you're unsure about changing rights, make a copy first. Change the owner of the copy, as copying in itself probably changes the owner. Or use rsync to make a copy of the folder, as rsync preserves owner and rights.

.htaccess "Options not allowed here"

I have this in my .htaccess:
Options +FollowSymLinks
And I get the following error in the apache error_log:
.htaccess: Options not allowed here
Here's the part from my httpd.conf file:
#htdocs symlinks here
<Directory /Users/you/code/my/folder>
Options All
AllowOverride All
</Directory>
<Directory />
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
So I'm setting Options All and AllowOverride All everywhere, but STILL I'm not allowed to set the option. Can anyone make sense of this?
Thanks,
MrB
Note that this is a XAMPP-specific issue. XAMPP loads some additional configuration files located in XAMPP/etc/extra/ that override httpd.conf. For me the offending file is http-userdir.conf which applies rules for ~user requests and contains the line AllowOverride FileInfo AuthConfig Limit Indexes and changing that line to AllowOverride All did indeed solve my issue.
This only applies to files served from your /Sites/ directory on OS X. I don't know if the Windows version uses UserDir at all or even has a similar rule.
in my case I end up with change the line AllowOverride AuthConfig FileInfo to AllowOverride All in file httpd-vhosts.conf where this file is located in apache\conf\extra folder
You have to allow overrides for "Options" within directory context. there's no need to:
vhost/directory config:
AllowOverride All
But only to permit overrides for 'Options':
AllowOverride {Existing options to override} +Options
I guess there is a global AllowOverride setting in your apache config which disallows this. Can you grep for AllowOverride in your httpd.conf?
I just installed the most recent version of XAMPP and thought to share how I solved the same problem.
This is a XAMPP specific setting (with every new XAMPP install). The most recent up to date XAMPP as of today - XAMPP 1.8.3 have a setting in /xampp/apache/conf/extra/httpd-xampp.conf that's causing your "Server Error" message.
And then you get the following error in your error log:
.htaccess: Options not allowed here
Open /xampp/apache/conf/extra/httpd-xampp.conf and find:
<Directory "/xampp/htdocs/xampp">
<IfModule php5_module>
<Files "status.php">
php_admin_flag safe_mode off
</Files>
</IfModule>
AllowOverride AuthConfig
</Directory>
and change
AllowOverride AuthConfig
with
AllowOverride All
No authentication or authorization will be required after the change UNLESS you specify it in your httpd.conf, extra confs or in .htaccess.
You may also want to read the Apache documentation for the option AllowOverride http://httpd.apache.org/docs/current/en/mod/core.html#allowoverride and choose more optimal and secure setting that will allow you to use your .htaccess without causing a server error.
Also keep in mind that you can find a better place to rewrite the rule above depending on the results that you'd like to achieve. In my case this is a satisfactory change.
instead of changing the global AllowOverride settings in your main httpd.conf file, if you have a httpd-vhosts.conf file you would want to put directory specific AllowOverride All directives in each host entry that you need it in, so you can keep a restrictive set on the rest of the server realm.
Change Options +FollowSymLinks into Options +SymLinksIfOwnerMatch in all instances of .htaccess file, the followsymlinks has been disabled on many server due to security risk.
On Debian 9 i edited the file /etc/apache2/mods-available/userdir.conf
Disabled this line
AllowOverride FileInfo AuthConfig Limit Indexes
Added this line
Allowoverride All
And it worked fine.
Many thanks to all who contributed
Does the server your domain is hosted on fulfills all requirements needed for Elgg? Especially, is mod_rewrite available?
Re-check all steps you had done.
If mod_rewrite is working... Do you have access to the configuration (http.conf) of Apache on your server? If yes, add the following lines (adjust the path):
AllowOverride All