Linux/Debian Apache2 mod_rewrite internal error - linux

i have some problems to setup my mod_rewrite for my Joomla-Site.
Im using Apache 2.2.22 on Debian.
Website is on Directory: /home/web/beta/
What i did:
1) Commands:
sudo a2enmod rewrite
sudo mkdir -p /var/run/apache2
sudo chown -R www-data /var/run/apache2
sudo a2enmod actions
sudo /etc/init.d/apache2 force-reload
2) Then i setup following file: /etc/apache2/sites-enabled/000-default
<Directory /home/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
3) The htaccess file at path /home/web/beta/.htaccess i set:
RewriteEngine On
(I took the .htaccess from this site: http://www.joomla-security.de/downloads.html)
Ok, now the Problem.
As long as i set the AllowOverride to FileInfo i get following error message:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, webmaster#localhost and
inform them of the time the error occurred, and anything you might
have done that may have caused the error.
More information about this error may be available in the server error
log. Apache/2.2.22 (Debian) Server at XXXXXXX.com Port 80
What i did wrong?
Can you help me please?
EDIT: Error Log:
[Wed Nov 11 19:21:56 2015] [notice] caught SIGTERM, shutting down
[Wed Nov 11 19:21:57 2015] [notice] Apache/2.2.22 (Debian) PHP/5.4.45-0+deb7u2 configured -- resuming normal operations
[Wed Nov 11 19:21:57 2015] [alert] [client XX.XX.XX.198] /home/web/beta/.htaccess: Options not allowed here
[Wed Nov 11 19:21:58 2015] [alert] [client XX.XX.XX.198] /home/web/beta/.htaccess: Options not allowed here
[Wed Nov 11 19:21:59 2015] [alert] [client XX.XX.XX.144] /home/web/beta/.htaccess: Options not allowed here

It seems, from the errors you've posted, that you are trying to use the Options directive in .htaccess. To do that, you need to add Options to the AllowOverride directive in 000-default (cf. https://httpd.apache.org/docs/2.2/mod/core.html#options).
So change:
AllowOverride FileInfo
to
AllowOverride FileInfo Options
in 000-default.
Edit:
And if the above doesn't work, try changing it to:
AllowOverride All
And if that doesn't work then it could mean that other configuration files are getting loaded after 000-default and overwrite some of the directives.

Related

Apache 403 everywhere with XAMPP Linux

I'm fairly new to using Apache, we use XAMPP here so I need to use that for simplicities sake. I'm having a problem getting Apache to view my files. I get this error in the logs for httpd:
[Thu Sep 17 16:16:46.944172 2020] [core:error] [pid 10036] (13)Permission denied: [client ::1:39318] AH00035: access to / denied (filesystem path '/home/mrblob/Documents') because search permissions are missing on a component of the path
[Thu Sep 17 16:16:47.170688 2020] [core:error] [pid 10036] (13)Permission denied: [client ::1:39318] AH00035: access to /favicon.ico denied (filesystem path '/home/mrblob/Documents') because search permissions are missing on a component of the path, referer: http://localhost:81/
My files for my website is /home/mrblob/Documents/web/
I've got this in my httpd.cnf file:
<Directory "/home/mrblob/Documents/web/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
Require all granted
Order allow,deny
AllowOverride None
Allow from all
</Directory>
I've also tried chmod on different permissions... I've tried a lot of different things... I'm yet to get it to work. FYI phpmyadmin as well as XAMPP's dashboard works fine. Any other pages that I want throws 403.
Thanks.
So I worked out I just needed to give access to Apache, well, I knew I needed to do this but I tried everything I thought of. My
sudo chmod ugo+rwx
Which I know its not the most secure way of doing it, but I'm only local hosting for now so it's not a huge deal.

Apache mod_wl2.4 plugin error parseJVMID

I have some issues with setting an clustered environment for weblogic and Apache. The structure is like this: 1 webserver that proxies requests to a clustered environment of 3 weblogic servers.
Everytime i send the request to the apache server , the request gets unhandled. I figured out a part of the problem , but that is something that is not intended in production. whenever i add DynamicServerList On the requests fail. When i switch it to off it works, but that means whenever a server fails , apache will still send requests to that server and user experience would be 0.
EDIT 1: I am using weblogic 12c and apache2.4 for Centos 7
EDIT 2: There is no firewall nor selinux active
Here is my config file for weblogic plugin:
<VirtualHost *:8080>
ServerAdmin postmaster#webserver2
ServerName webserver2
DocumentRoot /var/www/webserver2/htdocs
ErrorLog /var/log/httpd//webserver-error_log
CustomLog /var/log/httpd/webserver-access_log forwarded
<Directory />
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.html
<Location />
SetHandler weblogic-handler
</Location>
<IfModule mod_weblogic.c>
WeblogicCluster 192.168.166.70:8001,192.168.166.71:8001,192.168.166.69:8001
ConnectTimeoutSecs 15
ConnectRetrySecs 10
WLIOTimeoutSecs 600
DynamicServerList ON
Idempotent ON
FileCaching ON
KeepAliveSecs 60
KeepAliveEnabled ON
DebugConfigInfo ON
</IfModule>
</VirtualHost>
And the errors I get are the following:
[Mon Sep 14 09:54:58.480616 2015] [weblogic:error] [pid 15343:tid
140547949991680] [client 172.18.132.50:57991] <1534314422136982>
parseJVMID: could not resolve hostname '-1062689209'. Returning NULL
from parseJVMID
[Mon Sep 14 09:54:58.480681 2015] [weblogic:error]
[pid 15343:tid 140547949991680] [client 172.18.132.50:57991]
<1534314422136982> initJVMID: parseClusterServerList failure
[Mon Sep
14 09:55:28.481215 2015] [weblogic:error] [pid 15343:tid
140547949991680] [client 172.18.132.50:57991] <1534314422136982>
request [/clusterjsp/HaJsp.jsp] did NOT process
successfully..................

Apache/httpd /var/www/html/ .cgi scripts throw 500 internal server error

I installed a new CentOS 7 x86_64 LAMP server today.
I compiled a simple CGI script in c and i called it test.cgi, and I enabled the AddHandler for .cgi scripts. However everytime i try to load the /test.cgi page from my /var/www/html directory any simple .cgi script will throw me a 500 internal server error page.
I tested that the script is working fine from the /var/www/cgi-bin directory.
My server is running selinux and apache/httpd is using suEXEC.
EDIT: also I didn't create any extra users after the lamp installation so here I'm using root to do everything for now. However I tried to fix giving the /var/www/html directory ownership to the apache user, that didn't fix sadly.
Here's the error log, as you can see it gives me a 'Permission Denied' error:
[Mon Jul 21 15:28:14.336626 2014] [core:notice] [pid 22704] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Mon Jul 21 15:28:14.339766 2014] [suexec:notice] [pid 22704] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Jul 21 15:28:14.495631 2014] [auth_digest:notice] [pid 22704] AH01757: generating secret for digest authentication ...
[Mon Jul 21 15:28:14.498690 2014] [lbmethod_heartbeat:notice] [pid 22704] AH02282: No slotmem from mod_heartmonitor
[Mon Jul 21 15:28:14.765072 2014] [mpm_prefork:notice] [pid 22704] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16 configured -- resuming normal operations
[Mon Jul 21 15:28:14.765186 2014] [core:notice] [pid 22704] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Jul 21 15:28:16.027553 2014] [cgi:error] [pid 22706] [client 192.168.0.68:52930] AH01215: (13)Permission denied: exec of '/var/www/html/index.cgi' failed
[Mon Jul 21 15:28:16.030595 2014] [cgi:error] [pid 22706] [client 192.168.0.68:52930] End of script output before headers: index.cgi
[Mon Jul 21 15:45:01.586229 2014] [mpm_prefork:notice] [pid 22704] AH00170: caught SIGWINCH, shutting down gracefully
This is my /var/www/html apache config:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options ExecCGI FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
And of course I activated CGI using: AddHandler cgi-script .cgi .pl
This is my simple test.c file:
#include <stdio.h>
int main(void) {
puts("Content-Type: text/html; charset=ISO-8859-1\n");
fputs("Hello, World!", stdout);
return 0;
}
The output is correctly: Content-Type: text/html; charset=ISO-8859-1\n\nHello, World!
Also i compiled it with gcc and then gave it permissions 777 to test.cgi
Do you know what I need to do to fix this?
Thanks in advance,
Zorgatone
I'm not sure if this is a viable solution for you, but I got it working by changing SELinux to permissive. Here are the steps in case you're interested.
vi /etc/selinux/config
Change the following line:
SELINUX=enforcing
to:
SELINUX=permissive
I just solved reinstalling the server and doing all over again, disabled selinux and iptables, because I have already an external firewall.
Thanks to anyone who helped me out ;)
This is most likely an SELinux issue (which Tom Sweeney answer provides a solution to use a permissive SELinux and your own accepted answer which you indicated to disable SELinux entirely). An alternative approach is to configure appropriate SELinux types for your CGI files (and possibly other policy changes).
To start off, install the SELinux Policy Management tool (if not already done):
sudo yum install policycoreutils-python
Assuming you want to permit all CGI-based files in your /var/www/html directory, you can use the following command to apply the httpd_sys_script_exec_t context to your current and future CGI files:
sudo semanage fcontext -a -t httpd_sys_script_exec_t '/var/www/html(/.*)?/.*\.cgi'
Next, restore the content for any existing CGI files:
sudo restorecon -Rv /var/www/html/
You will also need to permit Apache to allow CGI scripts to be executed using the following:
sudo setsebool -P httpd_enable_cgi 1
You should be done. Note that if your CGI scripts need to read/write content from other files in your system, you'll have to also apply the httpd_sys_rw_content_t context to those files as well (see below for an example).
Just experienced this issue attempting to install Bugzilla (which uses CGI) on a CentOS 7 (x86_64) system. The following error was observed when monitoring my httpd error log (sudo tail -f /var/log/httpd/error_log):
[cgi:error] [pid 1825] [client ...:56481] AH01215: (13)Permission denied: exec of '/var/www/html/bugzilla/index.cgi' failed
[cgi:error] [pid 1825] [client ...:56481] End of script output before headers: index.cgi
Examining the context's applied to my Bugzilla installation, I see the following:
$ ls -Z /var/www/html/bugzilla/
...
-rwxr-x---. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 index.cgi
...
I then use the following commands to permit execution for Bugzilla's CGI scripts as well as access for said CGI scripts to read content inside the ./data directory:
sudo yum install policycoreutils-python
sudo semanage fcontext -a -t httpd_sys_script_exec_t '/var/www/html/bugzilla(/.*)?/.*\.cgi'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/bugzilla/data(/.*)?'
sudo restorecon -Rv /var/www/html/bugzilla/
sudo setsebool -P httpd_enable_cgi 1
Examining the applied context's show the desired results:
$ ls -Z /var/www/html/bugzilla/
...
-rwxr-x---. apache apache unconfined_u:object_r:httpd_sys_script_exec_t:s0 index.cgi
...
Bugzilla should be usable now. There may be additional policies to apply for all capabilities provided by Bugzilla; however, I'm unknown if any additional policies are required.
This is SELinux permission issue, it's not recommended to disable the SELinux.
Please check if your application worked in the permissive mode of SELinux then it's SELinux issue.
Find the below URL to check the exact issue and we will get blocking content from /var/log/audit.log
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/using_selinux/troubleshooting-problems-related-to-selinux_using-selinux

Wampserver loglevel rewrite not working

I am using WampServer and I would like to debug my rewrite rules from .htaccess, since I still receive 404 errors.
I already enabled rewrite_module, log_debug_module, log_forensic_module and log_config_module, but in my error log I don't receive any information about .htaccess.
In httpd.conf I changed LogLevelto: LogLevel warn mod_rewrite.c:trace8. I also tried the following options: rewrite_module, mod_rewrite.so, rewrite, mod_rewrite.
Then when I restart the server I only get this log, but I don't receive anything about web requests when I try to go to localhost/mysite.
[Sat Oct 12 17:33:07.063441 2013] [mpm_winnt:notice] [pid 8884:tid 412] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sat Oct 12 17:33:09.063556 2013] [mpm_winnt:notice] [pid 1632:tid 288] AH00364: Child: All worker threads have exited.
[Sat Oct 12 17:33:09.078557 2013] [mpm_winnt:notice] [pid 8884:tid 412] AH00430: Parent: Child process 1632 exited successfully.
[Sat Oct 12 17:33:48.859832 2013] [mpm_winnt:notice] [pid 8252:tid 412] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations
[Sat Oct 12 17:33:48.859832 2013] [mpm_winnt:notice] [pid 8252:tid 412] AH00456: Server built: Feb 22 2013 22:08:37
[Sat Oct 12 17:33:48.859832 2013] [core:notice] [pid 8252:tid 412] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Sat Oct 12 17:33:48.867833 2013] [mpm_winnt:notice] [pid 8252:tid 412] AH00418: Parent: Created child process 6216
[Sat Oct 12 17:33:49.145848 2013] [mpm_winnt:notice] [pid 6216:tid 288] AH00354: Child: Starting 150 worker threads.
UPDATE
Here is some more information about my folder structure. I have put my DirectoryRoot to D:/www and my .htaccess file is in D:/www/mysite.
Some parts from httpd.conf:
<Directory />
AllowOverride none
Require all granted
</Directory>
DocumentRoot "D:/www"
<Directory "D:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
# Require all granted
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
</Directory>
#ErrorLog "logs/error.log"
ErrorLog "c:/wamp/logs/apache_error.log"
#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn rewrite:trace3
Disabling the rewritemodule gives errors on RewriteEngine so I suppose that it does find my .htaccess file.
This is my .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?)/?$ index.php/$1
Could it be that you are using Apache 2.4.x, if so they have made major changes in the area of logging.
Try
LogLevel alert rewrite:trace3
Also another change is that logged info gets written to the normal error_log file.
Documentation
ADDED After Additional Info added
You have some fairly obvious errors in your httpd.conf file.
Can I suggest you review this document on the WAMPServer forum Wampserver 2.4 What to do after Installing
I just changed my WAMPServer Apache conf as so:
LogLevel warn rewrite:trace8
And got lots of extra lines in my apache_error.log from the rewrite module.
Make sure you are actually running something on the server that will exercise mod_rewrite and the RewriteRule you have in your .htaccess
ERRORS:
#WRONG Allows access to the root of your D: drive and all subfolders, great for hackers
<Directory />
AllowOverride none
Require all granted
</Directory>
#CORRECTED
<Directory />
AllowOverride none
Require all denied
</Directory>
.
#WRONG
DocumentRoot "D:/www"
#CORRECTED
DocumentRoot "d:/wamp/www"
.
#WRONG
<Directory "D:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
# Require all granted
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
</Directory>
#CORRECTED
<Directory "D:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
# onlineoffline tag - don't remove
Require local
</Directory>
After editting yor 'httpd.conf' log to
LogLevel alert rewrite:trace3
You should restart apache server to apply changes.

localhost not reading htaccess, httpd AllowOverride All causes error

I am newbie trying to duplicate my online site on to a local server using Apache 2.2.22 and PHP 5.3.15. However, my localhost isn't reading the .htaccess file. I modified the example httpd.conf file and it registers the site correctly starting with localhost/index.php. But if I goto localhost/index I get a "Not Found" error. The .htaccess file works fine through my ISP (i.e. mysite.com/index works without a problem).
At first I thought it was a problem with my .htaccess rewrite
ErrorDocument 404 /404.php
RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+)(/[a-zA-Z0-9/]+)?$ /$1\.php$2 [L]
But my localhost isn't reading the 404 error either which lead me to think it is the httpd.conf file. After some research a found a similar problem happens when the AllowOverride isn't switched to 'All'. Here is the what I had.
<Directory "D:/mywebfile/webserver/website/public_html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
When I switch it to AllOverride All, I get an "Internal Server Error" with the following log error
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 10.0.99.35 for ServerName [Sat Aug 04 15:15:55 2012] [notice] Child 9152: Child process is running
[Sat Aug 04 15:15:55 2012] [notice] Child 9152: Acquired the start mutex.
[Sat Aug 04 15:15:55 2012] [notice] Child 9152: Starting 64 worker threads.
[Sat Aug 04 15:15:55 2012] [notice] Child 4764: Released the start mutex
[Sat Aug 04 15:15:56 2012] [notice] Child 4764: All worker threads have exited.
[Sat Aug 04 15:15:56 2012] [notice] Child 4764: Child process is exiting
[Sat Aug 04 15:15:56 2012] [notice] Child 9152: Starting thread to listen on port 80.
[Sat Aug 04 15:15:58 2012] [alert] [client 127.0.0.1] D:/mywebfile/mywebserver/website/public_html/.htaccess: >Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
I have also tried to uncomment
#LoadModule rewrite_module modules/mod_rewrite.so
in the httpd file but I still get the same "Internal Server Error"
This seems like a simple problem but I've exhausted all my simple solutions. Any help will be greatly appreciated (and save me what little hair I haven't pulled out).
Thank you!
The problem is with the RewriteEngine command, not AllowOverride. That just activates the rewrite command.
Activating mod_rewrite is the way to go, the way you show. Make sure you are editing the right httpd.conf file and that you restart the server before trying again.

Resources