Issue With Apache Not Running htaccess files at all

Issues related to applications and software problems and general support
Post Reply
anne282
Posts: 11
Joined: 2020/09/24 16:44:49

Issue With Apache Not Running htaccess files at all

Post by anne282 » 2020/11/17 19:34:31

Good afternoon,

I have installed Centos 8 on a VPS, and I installed LAMP, as well as webmin. Using webmin, I created several master zones and virtual hosts on the apache server area. While I could have done this using httpd.conf, I used this method instead. It all appeared fine, except that one of the virtual hosts would not load anything but the apache test page, instead of the website that was in the directory that the virtual host pointed to.

There were three virtual hosts that I set up, and as I said, one of them would not work, while the other two were working properly. I read on another forum that changing the AllowOverride on the httpd.conf file could fix a similar issue, so I saved the original file, and changed the AllowOverride in two sections. Upon restarting the apache server, all three of the virtual hosts would only load the Apache server test page, so I reverted the httpd.conf file back to the original, however, the problem continues to persist. I tried stopping and restarting the apache server multiple times, with no luck.

Below are the relevant areas of the current httpd.conf file, with the domain names and folders replaced with example names. Perhaps there is something that I am missing, that I now need to change. I do not understand why it was working properly before, and now I cannot get any of the three to work. Can you please tell me what I might be missing in this file? Thank you. The relevant parts of the file are below:

ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
#ServerName www.example.com:80

<Directory />
AllowOverride none
Require all denied
</Directory>

DocumentRoot "/var/www/html"

<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>


<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
</Directory>

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

<Files ".ht*">
Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>

CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>

<IfModule mime_module>

TypesConfig /etc/mime.types AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>

IncludeOptional conf.d/*.conf
***this was the first virtual host that was created, and it was created twice, although this did not appear to cause any problems, as it was working:

<VirtualHost *:80>
DocumentRoot "/var/www/html/Folder-Domain-1"
ServerName www.domain1.com
<Directory "/var/www/html/Folder-Domain-1">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>


<VirtualHost domain1.com>
DocumentRoot "/var/www/html/Folder-Domain-1"
<Directory "/var/www/html/Folder-Domain-1">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>

<VirtualHost domain2.com>
DocumentRoot /var/www/html/Folder-Domain2
<Directory "/var/www/html/Folder-Domain2">
allow from all
Options None
Require all granted
</Directory>
ServerName www.domain2.com
</VirtualHost>

***this was the virtual host that I created that from the start would not work. It would show only the apache test page, even though I created a master zone, and had the nameservers pointed at it from the domain:

<VirtualHost domain3.com:80>
DocumentRoot /var/www/html/Folder-Domain-3
ServerName www.domain3.com
<Directory /var/www/html/Folder-Domain-3>
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>

This is the end of the httpd.conf file.

Any help would be greatly appreciated. As of right now, all three domains point to the Apache server test page. When I had changed this file, I changed the AllowOverride in the var/www/html area to All, instead of None, which is what it was when this was working. Now it has been changed back, as can be seen above.

Is there a line of code that I need to add into this file to make these virtual hosts work again, or make the centos server recognize apache once more? It seems that at this point, the server no longer recognizes apache. And one of the domains above is a wordpress site, with the standard wordpress htaccess file, while the other two are very simple static sites.

Another thing that I noticed, before changing the httpd.conf file, was that when the redirect was working, if I pointed my browser to domain1.com/subfolder, I would get a forbidden error. The subfolder contained an htaccess file itself, where the site should have resolved to, and the browser should have resolved the page it was pointing to. This did not happen, and I am uncertain if this particular error is related or unrelated to the error with the Apache test page, described above.

Any help on these issues would be greatly appreciated. Thank you.

anne282
Posts: 11
Joined: 2020/09/24 16:44:49

Re: Issue With Apache Not Running htaccess files at all

Post by anne282 » 2020/11/17 19:46:42

I made one change to the httpd.conf file, by adding:


<Directory "/">
Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>

<Directory "/home/">
Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>


And I also changed the AllowOverride None under var/www/html to AllowOverride All

Now instead of the Apache test page, it gives me an internal server error. This code had worked on a different Centos 8 server, where I was having a similar issue, and I found this solution on Stack overflow's forum. However, here it does not seem to work. Thank you for your help!

BShT
Posts: 586
Joined: 2019/10/09 12:31:40

Re: Issue With Apache Not Running htaccess files at all

Post by BShT » 2020/11/17 20:02:56

php-fpm?

you can insert yours directives inside vhost configuration or set php to run under mod_php.

the dirty way, yum install mod_php and

at /etc/httpd/conf.modules.d/00-mpm.conf

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
#LoadModule mpm_event_module modules/mod_mpm_event.so

anne282
Posts: 11
Joined: 2020/09/24 16:44:49

Re: Issue With Apache Not Running htaccess files at all

Post by anne282 » 2020/11/18 19:42:22

Hi, I have tried the solution that was suggested, and this did not change anything. I also changed the httpd .conf file to remove the added directives.

All of the virtual hosts still return an internal server error, and I cannot seem to fix this. I also changed one of the virtual hosts using webmin, by deleting it and re-entering it, then restarting apache, with the same error being given (internal server error).

I am at a loss as to how to proceed. I need these websites to work, on this new server, as the server I was migrating from was active, and needed to remain so. Now, all three websites that were previously active are stuck in this internal server error phase, and I don't know how to fix it. It seems that nothing that I did should have caused this permanent error, even though it has.

Any help would be greatly appreciated, so that these websites can be up and running once again, as soon as possible.

As of now, the httpd.conf file is exactly as it was in the initial message, with the sole difference being that the two AllowOverride directives that apply to the var/www and var/www/html folders are marked as AllowOverride All instead of None. This also did not fix the issue.

Your help is greatly appreciated.

In addition, the 00-mpm.conf file has been changed to reflect the new command suggested previously as such:
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
#LoadModule mpm_event_module modules/mod_mpm_event.so
Thank you.

anne282
Posts: 11
Joined: 2020/09/24 16:44:49

Re: Issue With Apache Not Running htaccess files at all

Post by anne282 » 2020/11/18 20:00:12

Hi, so I am having a new issue. I checked the error log, and realized that I had left an error message in the htaccess file of one of the virtual host websites, in order to throw an error message, which at the time it didn't do. When I removed this line from the error message, suddenly that particular virtual host worked.

However, to add more confusion, ALL THREE Virtual hosts go to the exact same place now, instead of to their own respective folders on the new server. All three go to the exact same place. I thought maybe this was because of the change that I had made to the 00-mpm file, so I changed it back to what it was before. This did not solve the problem.

So, these three virtual servers are pointed to different folders on the same server in the apache server, however, all three resolve to the exact same folder and webpage location. I am almost positive they were set up properly. Perhaps there is something in the httpd.conf file that is incorrect that someone on here can point out to me, that would be causing all three virtual hosts to be the EXACT same virtual host, just with different addresses.

So, in other words, when I type into a browser domain1.com, domain2.com, and domain3.com, all three go to the location for domain3.com, while showing their respective urls in the browser url field.

I must admit I am quite confused, and at a loss as to what is happening. Any help you can provide is appreciated.

User avatar
KernelOops
Posts: 428
Joined: 2013/12/18 15:04:03
Location: xfs file system

Re: Issue With Apache Not Running htaccess files at all

Post by KernelOops » 2020/11/19 07:07:27

To be honest, its hard to give advice since you are using webmin, which does its own thing. Maybe you should go to a support forum for webmin instead.

I manage my own web servers but I avoid using 3rd party apps like that. I can send you my configuration template if you want, maybe you can pick some ideas from it.
--
R.I.P. CentOS :cry:
--

User avatar
remirepo
Posts: 447
Joined: 2014/09/21 09:07:12
Location: France
Contact:

Re: Issue With Apache Not Running htaccess files at all

Post by remirepo » 2020/11/19 07:51:21

Don't switch to mod_php, this is a bad way to run PHP, keep FPM.

And instead of .htaccess, use .user.ini files.
Remi's Repository - Forum - Blog

Post Reply