Home > Enterprise >  RewriteEngine not allowed here magento and apache2 on VPS
RewriteEngine not allowed here magento and apache2 on VPS

Time:10-30

I've just installed Magento on my VPS (Debian 11), I must say Magento it's a pain compared to PretaShop and Wordpress, but I really need it.

After a painful installation, I run the page and I get the following:

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

Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this 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.

Then I thought to check logs. So I opened the file magento.mywebsite.ie.error.log and there is a list of all the attempts, like the following:

[Sun Oct 23 17:04:41.916039 2022] [core:alert] [pid 886340:tid 139973219006208] [client 51.37.89.15:0] /home/elliot/web/magento.mywebsite.ie/public_html/magento2/.htaccess: RewriteEngine not allowed here [Sun Oct 23 17:04:42.225156 2022] [core:alert] [pid 886340:tid 139973202220800] [client 51.37.89.15:0] /home/elliot/web/magento.mywebsite.ie/public_html/magento2/.htaccess: RewriteEngine not allowed here [Sun Oct 23 17:04:42.495916 2022] [core:alert] [pid 886340:tid 139973185435392] [client 51.37.89.15:0] /home/elliot/web/magento.mywebsite.ie/public_html/magento2/.htaccess: RewriteEngine not allowed here [Sun Oct 23 17:04:42.705350 2022] [core:alert] [pid 886340:tid 139973168649984] [client 51.37.89.15:0] /home/elliot/web/magento.mywebsite.ie/public_html/magento2/.htaccess: RewriteEngine not allowed here [Sun Oct 23 17:04:42.909888 2022] [core:alert] [pid 886340:tid 139973311325952] [client 51.37.89.15:0] /home/elliot/web/magento.mywebsite.ie/public_html/magento2/.htaccess: RewriteEngine not allowed here [Sun Oct 23 17:05:22.958733 2022] [core:alert] [pid 886660:tid 140355403986688] [client 51.37.89.15:0] /home/elliot/web/magento.mywebsite.ie/public_html/magento2/.htaccess: RewriteEngine not allowed here

The files .htaccess in my Magento new installation are exactly identical to the .htaccess that you would find here on GitHub: Link: https://github.com/magento/magento2

You will find .htaccess in the parent folder magento2, another one in the Document Root "pub" inside magento2. My opinion is that the system is using the one in the parent directory, magento2, since if I delete that .htaccess, the webpage would show "This page isn’t working" instead of "Internal Server Error", so the error message would be different in this way.

And this is apache2.ssl.conf used as configuration file:

I removed the comments here

<VirtualHost 141.146.42.11:8443>

ServerName magento.mywebsite.ie

ServerAdmin [email protected]
DocumentRoot /home/elliot/web/magento.mywebsite.ie/public_html/magento2/pub
ScriptAlias /cgi-bin/ /home/elliot/web/magento.mywebsite.ie/cgi-bin/
Alias /vstats/ /home/elliot/web/magento.mywebsite.ie/stats/
Alias /error/ /home/elliot/web/magento.mywebsite.ie/document_errors/
#SuexecUserGroup elliot elliot
CustomLog /var/log/apache2/domains/magento.mywebsite.ie.bytes bytes
CustomLog /var/log/apache2/domains/magento.mywebsite.ie.log combined
ErrorLog /var/log/apache2/domains/magento.mywebsite.ie.error.log
<Directory /home/elliot/web/magento.mywebsite.ie/stats>
    AllowOverride All
</Directory>
<Directory /home/elliot/web/magento.mywebsite.ie/public_html/magento2/pub>
    AllowOverride All
    SSLRequireSSL
    Options  Includes -Indexes  ExecCGI   </Directory>
SSLEngine on
SSLVerifyClient none
SSLCertificateFile /home/elliot/conf/web/magento.mywebsite.ie/ssl/magento.mywebsite.ie.crt
SSLCertificateKeyFile /home/elliot/conf/web/magento.mywebsite.ie/ssl/magento.mywebsite.ie.key
SSLCertificateChainFile /home/elliot/conf/web/magento.mywebsite.ie/ssl/magento.mywebsite.ie.ca

<FilesMatch \.php$>
    SetHandler "proxy:unix:/run/php/php8.1-fpm-magento.mywebsite.ie.sock|fcgi://localhost"
</FilesMatch>
SetEnvIf Authorization .  HTTP_AUTHORIZATION=$0

IncludeOptional /home/elliot/conf/web/magento.mywebsite.ie/apache2.ssl.conf_*
IncludeOptional /etc/apache2/conf.d/*.inc
</VirtualHost>

Please could you be so kind to help me with this? I have no experience at all about Apache issues, then I didn't know what else info I could provide to you. Hope you can help.

CodePudding user response:

I solved the problem by adding the following to my apache2.ssl.conf:

<Directory /home/elliot/web/magento.mywebsite.ie/public_html/magento2>
        AllowOverride All
</Directory>

In this way also the parent directory has AllowOverride All.

  • Related