Apache allowoverride all internal server error

apache allowoverride all internal server error

An HTTP 500 error can be caused by a permissions problem with your website's files or folders. Check the permissions on all of your main. Options Indexes FollowSymLinks AllowOverride All Order allow,deny allow from all Require all granted. - that's what i call service. UPDATE: note, you will get this error when you have a syntax error in your.htaccess files, so double check your.

Apache allowoverride all internal server error - advise you

How To Fix Mod_rewrite 500 Internal Server Error On .htaccess File Apache

ok, so today, i wanted to start making my urls more search engine friendly (SEO), i wrote my .httaccess file and made the changes on my files to make sure the urls are as i put them in the .htacess file. when i tried to open my urls, i kept getting this Apache 500 error:



CODE:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster @example.com 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.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.0  Server at thisdomain.com Port 80



I remember a whie back ago i got this same error on another apache server. so what i had to do was look at the /etc/httpd/conf/httpd.conf file make sure i uncomment the mod_rewrite, so i logged into the linux shell and opened the httpd.conf file:

CODE:

nano /etc/httpd/conf/httpd.conf


When i open it, found that the mod_rewrite was not commented out, so wha else could be the problem, as you can see,
LoadModule rewrite_module modules/mod_rewrite.sothe is not commented out in the httpd.conf file:


CODE:


LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so



so what else could be the problem i wondered...
Then i checked for AlloweOverride :

CODE:

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>



I changed AllowOverride from None to All, rebooted the server and i still kept getting the 500 error. at this point i was breaking my head..
so i checked my .htaccess file again to make sure i didn't make a typo or something, so this is how my .htacces files looks like:

CODE:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^p-([0-9]*).html viewpage.php?id=$1



So i removed the Options +FollowSymLinksthen uploaded it my site, and voala! i didn't get the error anymore. so this is how my .htaccess file looks like now:

CODE:

RewriteEngine on
RewriteRule ^p-([0-9]*).html viewpage.php?id=$1



Thanks to the support team at www.webune.com for helping me with this problem, i had read a post regarding this on this fourm but could not get a resolution on the problems.

Thanks Webune for your support on my dedicated server. - that's what i call service.

UPDATE: note, you will get this error when you have a syntax error in your .htaccess files, so double check your spelling, you will find that you mispelled something. the reason is because apache cannot recognize the code you put in your .htaccess file. one way you can confirm its a bad syntax in your .htaccess file, is try removing all the code and then try your website again without any code in the .htaccess file, if it doesnt give you an 500 error, then you know for sure you have a bad syntax in your .htaccess file.

jpe?g LenientMethods

RFC 7231 §4.1 "Request Methods" "Overview" requires that origin servers shall respond with a HTTP 501 status code when an unsupported method is encountered in the request line. This already happens when the option is used, but administrators may wish to toggle the option and register any non-standard methods using the directive, particularly if the option has been toggled.

Forward Proxy compatibility

The option should not be toggled for forward proxy hosts, as the methods supported by the origin servers are unknown to the proxy server.

Example of a request leading to HTTP 501 with LenientMethods mode

Allow0.9 grep [file name]
This will return any lines which have the file name in them.
  • If you are not sure what is causing the error, you can follow the error log in one window and watch it being generated. First, in your SSH session, use the command:
    • tail -f /var/log/httpd/error_log
      Without closing the SSH session, go to a web browser and refresh the page to generate the 500 error again. You should see the error appear in the log file.
  • You can also view the last 10 lines in the error log with the command:
    • tail -20 /var/log/httpd/error_log
      Once you find the error, copying and pasting it into Google will often yield helpful results.
  • 3.Check Permissions

    An HTTP 500 error can be caused by a permissions problem with your website’s files or folders. Check the permissions on all of your main folders and scripts. Most Perl and CGI files need to have their permissions set to 755.

    To check the permissions of files on a Linux system, connect via SSH to your server and go to the directory where the files are kept. Use the ll command to list all files and file details.

    The first block of letters lists the file’s permissions. There are three permission levels:

    Read (r)
    Write (w)
    Execute (x)
    The permissions are shown in groups of three:

    Group 1: Owner
    Group 2: Group
    Group 3: World (everyone)

    4.Changing Permissions

    To change the permissions for a file, you need to use the chmod command, along with the numerical value of the permissions level you want to set. The most common permissions levels are:

    7: Read, write, and execute (rwx)
    5: Read and execute (r-x)
    0: None (—)
    Most scripts will require read/write/execute permissions for the owner, and read/execute permissions for group and world. To set this on a file, use the command:

    chmod 755 [filename]
    If you are still receiving an error when you run your script, try setting it to global read/write/execute permissions for testing purposes. To set this on a file, use the command:

    chmod 777 [filename]
    This permissions level can be risky, because it allows anyone to rewrite your file. Once you have finished troubleshooting, be sure to set the file back to the correct permissions.

    5.Examine Your Scripts

    If your website relies on scripts (such as Perl or CGI files), there are a number of things that can go wrong. Always check the file permissions first. If those are correct, examine the scripts themselves.

    Are they in the right place, and named correctly? Verify that the scripts have not been moved, deleted, or renamed by accident.

    Are the file paths correct? Many scripts will require other files and programs in order to run. For example, if you have a Perl script, it will start with the path to Perl. You can use the which command to find the path to Perl (or any other programming language or command) with the command:

    which perl

    Do the scripts have permission to run in the folder where they are located? You may want to find a simple test script to check this.

    Be sure your test script is in the same language as the one you are troubleshooting, and uses the same file extension. For example, if you are having trouble with a Python script named myfile.py, search for a Python test script, and give the file a .py file extension. Using a Perl test script, or a Python test script that ends in .cgi won’t be effective as a test.

    Was the script recently edited in a word processing program like Microsoft Word or Wordpad? CGI programs and other scripts should only be edited with a text editor like Notepad. To fix this problem, find a fresh copy of the script, and use a text editor like Notepad (for Windows) or BBEdit (for Mac).

    6.Check the Apache Files

    An HTTP 500 error can be caused by a problem with your Apache configurations. If you have scripts or CGI programs which are generating a 500 error, check to make sure they have permission to run in the directory where they are located.

    Apache will not allow programs to execute by default. Permission must be given in either an .htaccess file in the directory where the program runs, or in the website’s main Apache configuration file.

    7.Granting Permissions With an .htaccess File

    You can grant executable permissions on a directory-by-directory basis using an .htaccess file.

    Note: because the file name begins with a period, the file will be hidden from a basic ls search from the command line. To list the files in the directory including any which begin with a period, use the command:

    ls -la
    Either edit the existing file, or create one in the directory, if none exists. You can also create this file in Notepad on your desktop computer, and upload it to your website with FTP.

    The file will need to have this line:

    Options +ExecCGI
    You will also need a line that will tell Apache how to run scripts written in Python, PHP, Perl, etc. Customize this line to add the extension your files are using (.py, .php, .pl, etc.).

    AddHandler cgi-script .cgi .py .php .pl

    8.Is the .htaccess File Being Read?

    If you have an .htaccess file which is set up correctly, but you are still getting an HTTP 500 error, the problem might be that the .htaccess file is being ignored.

    In order for the .htaccess file to work, Apache will need to be configured to allow it to run.

    Check the website’s main Apache configuration file. For the main domain on a server, this will typically be:

    Ubuntu and Debian: /etc/apache2/apache2.conf
    CentOS 7: /etc/httpd/conf/httpd.conf

    For other domains being hosted on the server, the location and name of the file will vary depending on how the domain was set up.

    Edit this main configuration file and find the block which pertains to the directory where you are adding an .htaccess file. For example, the default document root for the main directory will probably be:

    <directory “=”” var=”” www=”” html”=””>

    Inside this block, look for the AllowOverride configuration. Set this to:

    AllowOverride All

    After making changes to the main Apache configuration file, restart Apache for the changes to take effect:

    Ubuntu and Debian: use the command service apache2 restart.
    CentOS 7: use the command systemctl restart httpd.

    9.Timeout Errors

    If you have scripts which call external networks or resources, an HTTP 500 error can be caused when those connections time out, usually because the resource is unreachable. Check your external resources to be sure they are accessible.

    Rajesh Kumar

    Rajesh Kumar

    Mentor for DevOps - DevSecOps - SRE - Cloud - Container & Micorservices at Cotocus

    Website - www.RajeshKumar.xyz
    Email - [email protected]

    I can help in the following:
    - DevOps - DevSecOps - SRE
    - Continuous Integration & Delivery
    - Continuous Deployment & Inspection
    - Technical Debt Reduction
    - Containerization/Micro Services Using Kubernetes & Docker
    - Cloud Migration using AWS-Azure-GoogleCloud
    - Enterprise observability

    Rajesh Kumar

    Latest posts by Rajesh Kumar (see all)