Make WordPress Core

Opened 21 months ago

Last modified 19 months ago

#38204 new enhancement

enhancement: custom pathname to wp-config.php

Reported by: gdamjan Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7
Component: Bootstrap/Load Keywords:
Focuses: Cc:


This patch allows for setting the pathname to the wp-config.php file with a WP_CONFIG_FILE environment variable.

The end goal is to have wordpress code separate (and possibly read-only) from the config file, and from the state (user content).

Attachments (1)

0001-allow-custom-pathname-to-configuration.patch (993 bytes) - added by gdamjan 21 months ago.

Download all attachments as: .zip

Change History (6)

21 months ago


#1 @gdamjan
21 months ago

A bit of discussion: if I posit that an application has:

  • code (typically in /usr)
  • configuration (typically in /etc)
  • persistent state (typically in /var)
  • ephemeral state (typically /tmp)

all of those parts has different lifecycles and permissions: for example, we never need to backup /usr since that can be retrieved from upstream (either github release, or distro packages). /usr also can be read-only (a ro filesystem, or just in relation to the user that's running the application). and can be shared between users.

configuration needs to be backed up, be writeable to the admin, but not readable to other users, and typically not writeable to the application

persistent state is images, uploads and the database, needs to be backed up regularly, is read-write for the application, but not readable to other users.

ephemeral state are caches, sessions, temporary uploads and similar, can be cleared by the sysadmin at any time, doesn't need backups. Typically this will be /tmp in tmpfs (and with systemd can be a PrivateTmp, so I don't care to configure it in wordpress), needs to be read-write to the app but not readable to other users.

with WP_CONTENT_DIR we already can setup the persistent state directory outside of the code directory. this patch allows for the configuration to be outside of the code directory too.

this makes the code directory easier to share between wordpress instances, each running as a separate user, also makes updates easier - just replace the code directory.

#2 @knutsp
21 months ago

Hello gdamjan and welcome to Trac!

wp-config.php may already be located above the code directory.

Since it's a PHP script file you may also change the file to just include or read another readable file or resource.

Why is an environment variable a better way?

#3 @SergeyBiryukov
21 months ago

  • Component changed from General to Bootstrap/Load

#4 @gdamjan
21 months ago

@knutsp of course, there are different ways I could accomplish this (I typically over bind-mount the file - though that does require root).

the reason I propose this is so that we can have a more common and standard way to have the config file outside the code directory (and outside of the /usr file-system hierarchy too).

This ticket was mentioned in Slack in #core by swissspidy. View the logs.

19 months ago

Note: See TracTickets for help on using tickets.