The Original RickySpears.com by the REAL Ricky Spears

Messed up DNA strands and the message Interrnal Server Error

Genes.one: How to Fix Internal Server Error on Windows 11 with Apache 2.4

I have been working with the excellent Genes.one framework recently. Especially the PHP backend framework.

When I first downloaded it, and tried using it, it would create the initial folders and files, but after that I kept getting 500 series errors when I would try to load the index.php file. This was on my development machine running Windows 11, Apache 2.4, and PHP 8.2.9.

After spending several hours trying to debug the issue, I finally decided to try it on public shared hosting. I created a subdomain for testing, uploaded the file, launched it, it created the initial folder and files, and … no errors after that! Everything just worked. So, I knew the issue had to be in my Windows 11 machine.

It turned out that they were all Apache issues with either how my httpd.conf was configured or with the .htaccess file. This blog post is about how we can fix them.

Before making any changes to critical system files like httpd.conf or .htaccess, it is very important that we remember to always, always, always make a backup copy of them! I usually select them, CTRL + C, CTRL + V, and then rename the copied file back to the original file name and add .BKUP-YYYY-MM-DD onto the end of it. This makes it easy for me to identify my in-place backups of files and when they were made.

Changes to httpd.conf

Some of the things in the .htaccess have been deprecated in Apache 2.4 and they must be written differently now. I can’t see what version of Apache my shared web host (Dreamhost) is using. Apparently, they are using something older than Apache 2.4.

Let’s open our httpd.conf file in our text editor of choice — for me, it’s VS Code. On my machine, the file is located at C:\Apache24\conf\httpd.conf.

We are going to scroll down (or CTRL + F) to find the section of the document for <Directory “${SRVROOT}/htdocs”>

Within that section, we need to ensure that we have:

Options +FollowSymLinks -Indexes
AllowOverride All
Require all granted

There is likely a default setting of:

Options Indexes FollowSymLinks

that we must change to:

Options +FollowSymLinks -Indexes

This screenshot indicates what we changed and where we change it in the document.

Note: If we don’t want to make the above changes for all Apache directories, we can make them just for the directory/directories in which we use Genes.one by adding sections for those directories at the end of httpd.conf like so:

# Modifications for Genes.one framework
<Directory "C:/Apache24/htdocs/sites/genesfree.localhost">
    Options +FollowSymLinks -Indexes
    AllowOverride FileInfo Indexes Limit
    Require all granted
</Directory>
<Directory "C:/Apache24/htdocs/sites/genesdemo.localhost">
    Options +FollowSymLinks -Indexes
    AllowOverride FileInfo Indexes Limit
    Require all granted
</Directory>

While we are in here, we need to make sure that two particular Apache modules are enabled: access_compat_module and rewrite_module. We just need to find them and ensure there isn’t a # (comment) in front of them, and if there is, delete the ‘#’. access_compat_module is disabled (i.e. commented) by default, while rewrite_module is enabled (i.e. uncommented) by default. We just need to confirm that both are not commented out and fix it if one or both of them are.

LoadModule access_compat_module modules/mod_access_compat.so
LoadModule rewrite_module modules/mod_rewrite.so

We’ve made all of our changes, and we can now save the file.

After making these changes, the Apache 2.4 service needs to be restarted to pick up the changes. We can do this by launching a command prompt and selecting Run as Administrator. If we installed Apache 2.4 into the default directory, we can restart it with:

cd c:\Apache24\bin
httpd -k restart

If we have Apache 2.4 running as a Windows Service, we can also restart it by doing the following too:

  1. Launch Task Manager (Press Ctrl + Shift + Esc on the keyboard). 
  2. Click on Services on the left hand side at the bottom.
  3. Right-click on Apache2.4.
  4. Select Restart.
  5. The Status column will cycle through Stopping, Stopped, Starting, Running.

Changes to .htaccess

We may find that the .htaccess file(s) for the directory(ies) where we are using genes.php contain some of the lines we replaced in .httpd. We will need to open those .htaccess files in a text editor and remov or comment out those lines by typing a ‘#’ before them. If they are not removed or commented out, then they will supersede the changes that we made in .httpd and we’re right back to square one. Ugh!

This screenshot might be a little more helpful in explaining what we need to remove and why.

We also need to add the following line to our .htaccess file. You can see the line highlighted in the screenshot above. It doesn’t matter very much where we paste it as long as we are in <IfModule mod_rewrite.c>. It’s probably easiest to copy and paste it from here. 👇

RewriteRule "\.(htaccess|htpasswd|ini|log|sh|inc|bak)$" - [F]

That seems like a lot more work than it is. This is because I explained why have to make all of these changes and provided multiple ways to do them. There are a lot of screenshots and code blocks too.

I may not be able to help people with similar issues. They are difficult to diagnose without having access to the machine on which it is happening and the time to investigate it. I do hope others will share their issues and how they overcome them though.

Leave a Reply

Your email address will not be published. Required fields are marked *