AllowOverride = All -- Make HTTPD.CONF changes persistent

mockingbird

Verified User
Joined
Feb 6, 2023
Messages
25
So I have installed Drupal many times, but this time I'm doing it with DirectAdmin.

My issue is that after the installation is complete, the Drupal page does not display CSS/JS.

The issue is that AllowOverride must be set to all in .htaccess but it is being overridden by DA's http.conf directives. When I manually comment out the default AllowOverride entry and insert an AllowOverride All directive in HTTPD.CONF, Drupal displays fine. Now I have no issue leaving things as is, but as I understand, HTTP.CONF will reset after each DA update, so that solution is not ideal.

I need to make the change persistent.

I've read this:
https://docs.directadmin.com/webser...ing-custom-httpd-conf-code-to-the-virtualhost

It wasn't helpful.

While AllowOverride All now does show up after inserting it into the 'CUSTOM3' text box, the subsequent default AllowOverride statement still present seems to override it (and my Drupal page displays incorrectly):

Code:
<VirtualHost my.ip.address:443 >
	SSLEngine on
	SSLCertificateFile /usr/local/directadmin/data/users/admin/domains/my.domain.removed.cert.combined
	SSLCertificateKeyFile /usr/local/directadmin/data/users/admin/domains/my.domain.removed.key
	ServerName www.my.domain.removed
	ServerAlias www.my.domain.removed my.domain.removed
	ServerAdmin [email protected]
	DocumentRoot "/home/admin/domains/my.domain.removed/private_html"
	UseCanonicalName OFF
	SuexecUserGroup admin admin
	CustomLog /var/log/httpd/domains/my.domain.removed.bytes bytes
	CustomLog /var/log/httpd/domains/my.domain.removed.log combined
	ErrorLog /var/log/httpd/domains/my.domain.removed.error.log
	<Directory "/home/admin/domains/my.domain.removed/private_html">
AllowOverride All
		AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,IncludesNOEXEC,MultiViews,SymLinksIfOwnerMatch,FollowSymLinks,None
		Options -ExecCGI -Includes +IncludesNOEXEC
		<FilesMatch "\.(inc|php|phtml|phps)$">
			<If "-f %{REQUEST_FILENAME}">
				#ProxyErrorOverride on
				<IfVersion > 2.4.59>
					ProxyFCGISetEnvIf "true" SCRIPT_FILENAME "%{unescape:%{SCRIPT_FILENAME}}"
				</IfVersion>
				AddHandler "proxy:unix:/usr/local/php83/sockets/admin.sock|fcgi://localhost" .inc .php .phtml
			</If>
		</FilesMatch> 
		<FilesMatch "\.(php53|php54|php55|php56|php70|php71|php72|php73|php74|php80|php81|php82)$">
			Order Allow,Deny
			Deny from all
		</FilesMatch>
	</Directory>
    # Mail auto configuration (Thunderbird)
    ProxyPassMatch "^/\.well-known/autoconfig/mail/config-v1\.1\.xml$" "unix:/usr/local/directadmin/shared/internal.sock|http://localhost"
</VirtualHost>

Any help is appreciated.

Thanks
 
Last edited:
That is not the correct way. Best is to use the method of the link your provided yourself, then you don't need to chattr the httpd-directories.conf anymore.
Hmmm... That's not working for me. Neither is chattr... modifying httpd-directories.conf isn't enough (I thought it was working because I was reloading from cache).

The issue is that I need to remove this line from the per domain (e.g. the one located in /usr/local/directadmin/data/users/username/) httpd.conf:

Code:
AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,IncludesNOEXEC,MultiViews,SymLinksIfOwnerMatch,FollowSymLinks,None

As it seems to be overriding the AllowOverride All in httpd-directories.conf.

Any idea on how to do that?

The only thing that has worked so far was modifying the per domain httpd.conf and commenting out that line. But again, I need this to be persistent.

Sigh, I've spent hours on this. It should not be this complicated.
 
I fixed it.

These four template files need to be modified:

/usr/local/directadmin/data/templates/virtual_host2.conf
/usr/local/directadmin/data/templates/virtual_host2_secure.conf
/usr/local/directadmin/data/templates/virtual_host2_secure_sub.conf
/usr/local/directadmin/data/templates/virtual_host2_sub.conf

The "options" part of the allowoverride token must be removed so that all that remains is "AllowOverride All".
(that means to say - simply modifying /usr/local/directadmin/custombuild/custom/ap2/conf/extra/httpd-directories.conf has no effect).

I am in shocked amazement that this has never come up before here and that this was so difficult to solve.

The only hint I got on where to look was from this old changelog which mentions something about the allowoverride token in the templates:
https://docs.directadmin.com/changelog/version-1.51.4.html

I hope this saves someone some time in the future.

EDIT (12/18/2024): I received this reply from Roman in my ticket where he states that while this would survive a rewrite, an additional step is necessary for it to survive an update:
Hello,

Those changes will survive this command:

da build rewrite_confs

and even rebuilding or updating Apache:

da build apache

but those templates will be overwritten during DA update.
You can try testing it by forcedly update DA:

da update --force

and then check those files.

So, I recommend to create custom folder:

mkdir -p /usr/local/directadmin/data/templates/custom/

and then copy those 4 modified template files in that folder or copy the original files and modify them in that "custom" directory.
After that rebuild Apache:

da build apache


Thank you.
Thanks Roman.
 
Last edited:
Back
Top