localhost not reading htaccess, httpd AllowOverride All causes error - .htaccess

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.

Related

redirect Apache Server document root to SpringBoot app

I have modified the file:
/etc/apache2/sites-available/elcor.com.conf
adding:
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster#elcor.com
ServerName elcor.com
ServerAlias www.elcor.com
ProxyPass / http://localhost:8080/home.html
ProxyPassReverse / http://localhost:8080/html
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/elcor.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/html/elcor.com/log/error.log
CustomLog /var/www/html/elcor.com/log/access.log combined
</VirtualHost>
in order to access a SpringBoot app I have in the same server, but when I acees the site, this is what I see:
When I start Apache I have this error:
-- The job identifier is 483.
Dec 01 14:16:08 localhost apachectl[1099]: AH00526: Syntax error on line 9 of /etc/apache2/sites-enabled/elcor.com.conf:
Dec 01 14:16:08 localhost apachectl[1099]: Invalid command 'ProxyPass', perhaps misspelled or defined by a module not included in the server configuration
Dec 01 14:16:08 localhost apachectl[1086]: Action 'start' failed.
Dec 01 14:16:08 localhost apachectl[1086]: The Apache error log may have more information.
Dec 01 14:16:08 localhost systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
could it be the case you did not enable mod_proxy on your system?
you can do that via "a2enmod proxy_http" on your ubuntu system

Linux/Debian Apache2 mod_rewrite internal error

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.

CakePHP and EasyPHP

I'm new in PHP and I'm facing some problems.
I'm using EasyPHP (DevServer 14.1 -> PHP 5.5.8 and Apache 2.4.7) and CakePHP (2.5.1).
Well, if I put the CakePHP files at "C:\Program Files\EasyPHP\data\localweb\" (then it would be "C:\Program Files\EasyPHP\data\localweb\cake_2_0..." for example), it works fine, as it should.
The problem is: I would like to use alias on EasyPHP, for I don't want to develop at "C:\Program Files...". But when I put the CakePHP files on my application root ("C:\myapps\myproject..." for example, with an alias set on EasyPHP), then I get a "Error 404". Now, I found that if I remove the .htaccess file from root, it works. But I'm sure this file is there for some reason, so I don't feel right just removing it - it might give me more problems later.
Does anyone know anything about it? Can I use alias on EasyPHP if I want to use CakePHP?
Thanks in advance.
Edited
This is my apache_alias.conf (C:\Program Files\EasyPHP-DevServer-14.1VC11\data\conf):
Alias "/cakeblogtutorial" "C:/Programacao/PHP/workspace/CakeBlogTutorial"
<Directory "C:/Programacao/PHP/workspace/CakeBlogTutorial">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
Allow from 127.0.0.1
Deny from all
Require all granted
</Directory>
This is my .htaccess (C:\Programacao\PHP\workspace\CakeBlogTutorial):
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
On my httpd.conf (C:\Program Files\EasyPHP-DevServer-14.1VC11\binaries\conf_files), regarding to mod_rewrite (in other words, uncommented):
LoadModule rewrite_module modules/mod_rewrite.so
Last lines on error.log (C:\Program Files\EasyPHP-DevServer-14.1VC11\binaries\apache\logs):
[Mon Jun 02 14:27:48.093057 2014] [:error] [pid 4284:tid 848] [client 127.0.0.1:62831] script 'C:/Program Files/EasyPHP-DevServer-14.1VC11/data/localweb/index.php' not found or unable to stat
[Mon Jun 02 14:34:59.319532 2014] [mpm_winnt:notice] [pid 1992:tid 312] AH00424: Parent: Received restart signal -- Restarting the server.
[Mon Jun 02 14:34:59.982390 2014] [mpm_winnt:notice] [pid 1992:tid 312] AH00455: Apache/2.4.7 (Win32) PHP/5.5.8 configured -- resuming normal operations
[Mon Jun 02 14:34:59.982390 2014] [mpm_winnt:notice] [pid 1992:tid 312] AH00456: Apache Lounge VC11 Server built: Nov 21 2013 20:13:01
[Mon Jun 02 14:34:59.982390 2014] [core:notice] [pid 1992:tid 312] AH00094: Command line: 'C:\\PROGRA~1\\EASYPH~1.1VC\\binaries\\apache\\bin\\eds-httpd.exe -d C:/Program Files/EasyPHP-DevServer-14.1VC11/binaries/apache'
[Mon Jun 02 14:34:59.988391 2014] [mpm_winnt:notice] [pid 1992:tid 312] AH00418: Parent: Created child process 6588
[Mon Jun 02 14:35:01.279844 2014] [mpm_winnt:notice] [pid 6588:tid 364] AH00354: Child: Starting 64 worker threads.
[Mon Jun 02 14:35:01.523147 2014] [mpm_winnt:notice] [pid 4284:tid 364] AH00364: Child: All worker threads have exited.
Last lines on access.log (C:\Program Files\EasyPHP-DevServer-14.1VC11\binaries\apache\logs):
127.0.0.1 - - [02/Jun/2014:15:09:50 -0300] "GET /cakeblogtutorial HTTP/1.1" 301 242
127.0.0.1 - - [02/Jun/2014:15:09:50 -0300] "GET /cakeblogtutorial/ HTTP/1.1" 404 1156
I guess I found the answer - and if so, the RewriteBase is the correct thing to do. From the CakePHP WebSite (http://book.cakephp.org/2.0/en/installation/url-rewriting.html):
For many hosting services (GoDaddy, 1and1), your web server is actually being served from a user directory that already uses mod_rewrite. If you are installing CakePHP into a user directory (http://example.com/~username/cakephp/), or any other URL structure that already utilizes mod_rewrite, you’ll need to add RewriteBase statements to the .htaccess files CakePHP uses (/.htaccess, /app/.htaccess, /app/webroot/.htaccess).

(13)Permission denied: access to /cgi-bin/test.cgi denied

I am trying out CGI-scripts for the first time but without success. I have read many tutorials and followed may threads in different forums but I can not make it work.
I am using a appache web server on a Fedora 10 machine.
I always have problem with
[Wed Oct 21 20:47:36 2009] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Wed Oct 21 20:47:36 2009] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Oct 21 20:47:36 2009] [notice] Digest: generating secret for digest authentication ...
[Wed Oct 21 20:47:36 2009] [notice] Digest: done
[Wed Oct 21 20:47:36 2009] [notice] Apache/2.2.11 (Unix) DAV/2 PHP/5.2.9 mod_ssl/2.2.11 OpenSSL/0.9.8g configured -- resuming normal operations
I need help.
This is what my environment looks like.
uname -a
Linux localhost.localdomain 2.6.27.5-117.fc10.i686 #1 SMP Tue Nov 18 12:19:59 EST 2008 i686 i686 i386 GNU/Linux
ls -l /var/www/cgi-bin/
total 36
-rwxrwxrwx 1 root root 106 2009-10-21 18:29 index.html
-rwxr-xr-x 1 root root 11089 2009-02-24 20:11 squidGuard.cgi
-rwxr-xr-x 1 root root 5720 2009-02-24 20:11 squidGuard-simple.cgi
-rwxr-xr-x 1 root root 5945 2009-02-24 20:11 squidGuard-simple-de.cgi
-rwxrwxrwx 1 root root 110 2009-10-21 17:38 test.cgi
apachectl -v
Server version: Apache/2.2.11 (Unix)
Server built: Mar 6 2009 09:12:25
perl -version
This is perl, v5.10.0 built for i386-linux-thread-multi
Copyright 1987-2007, Larry Wall
My script
cat test.cgi
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "Hello, world!\n";
The error message I gen when I try to access the web page server "http://192.168.50.29/cgi-bin/test.cgi" looks like this:
[Wed Oct 21 21:00:27 2009] [error] [client 192.168.50.69] (13)Permission denied: access to /cgi-bin/test.cgi denied
I have added the line:
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
to /etc/httpd/conf/httpd.conf
I just can not make it work.
Can anyone help me?
Check your os permissions for test.cgi and be sure the user or group you are using to run your apache it has read access.
EDIT - The problem is with permissions, but not with read permissions, as you are using SELinux, you need to worry about your file context. Check this thread at fedora forums, it explains quite a few options to solve your problem.
1.FIRST CHECK THE HTTPD.CONF FILE.Set the script directory as follows in the httpd.conf.
Here you'd need to make sure you find the right httpd.conf file.For example, in my Debian, the default httpd.conf is /etc/apache2/sites-avaialbe/default.
<Directory "dir_name">
Options All
AllowOverride All
Order allow,deny
Allow from all
<Directory>
OR you could just use the default /cgi-bin folder.
2.Set the execute permission for the test script.
chmod +x script_name
check your fstab if the mounted filesystem have permission to execute
UUID=xxx-xxx-xxx-xx-xx /mnt/mountpoint ext4 rw,user,exec 0 0
the exec part is important
SELinux prevented Apache from accessing the cgi script in my case.
A quick-n-dirty fix that worked for me was turning off SELinux:
vim /etc/sysconfig/selinux
set "SELINUX=disabled"
reboot

Internal Server Error

The error message I gen when I try to access the web page server "192.168.50.29/cgi-bin/tinyPL.cgi"; looks like this:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, root#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.11 (Fedora) Server at 192.168.50.29 Port 80
Error_log :
[Sat Oct 24 21:30:47 2009] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sat Oct 24 21:30:47 2009] [notice] Digest: generating secret for digest authentication ...
[Sat Oct 24 21:30:47 2009] [notice] Digest: done
[Sat Oct 24 21:30:48 2009] [notice] Apache/2.2.11 (Unix) DAV/2 PHP/5.2.9 mod_ssl/2.2.11 OpenSSL/0.9.8g mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
[Sat Oct 24 21:30:50 2009] [error] [client 192.168.50.69] (13)Permission denied: exec of '/var/www/cgi-bin/tinyPL.cgi' failed
[Sat Oct 24 21:30:50 2009] [error] [client 192.168.50.69] Premature end of script headers: tinyPL.cgi
Could any one help me on this!
Your log file will have more details regarding the error, but an Internal Server error on a CGI script usually means that when the server tried to execute your CGI program the expected headers was not present.
In a perl script, that would be (for example):
use CGI qw(:standard);
print header();
Which will print out something like:
Content-type: text/html
Try and run your CGI script from the commandline and see if prints out those lines. The other problem might be due to access permissions. Apache might not be able to execute your script.

Resources