wp-config.php Generator

A lot of the fixes on this blog end with a line in wp-config.php: FS_METHOD when WordPress asks for FTP credentials, a higher memory limit, debug logging to a file. This generator puts those constants in one place, each with a one-line explanation and a warning where it can lock you out.

Tick what you need and copy the lines into your existing file, or get a complete wp-config.php for a new install with fresh keys and salts. The second tab works out the PHP upload limits (for the media library or phpMyAdmin imports) for your type of server.

Each setting is a WordPress constant, checked against the WordPress 7.1 source. It all runs in your browser: nothing you type is sent anywhere, and the keys come from your browser’s crypto.getRandomValues().

Limits: it writes the lines, it can’t see your server. A wrong address or HTTPS setting can lock you out of wp-admin, so keep a copy of your current wp-config.php and remove the new lines if the site stops loading.

What do you need?
Security keys

Eight random 64-character strings that sign login cookies and nonces. Same character set and length as the official generator at api.wordpress.org.

Logs everyone out. New keys end every login session, yours too. Plugins that encrypt stored API keys with them (Site Kit by Google is one) need reconnecting. Passwords keep working.

Updates and file access

Stops the “Connection Information” FTP form on updates when you pick direct, or stores your FTP details so you don’t type them each time.

Fix the owner first. In my test of 15 setups, direct only removed the prompt for real when PHP’s user could write every WordPress file. When it couldn’t, the update failed with “Could not create directory.” The real fix is the file owner: see the FTP-credentials guide.

The mode WordPress gives folders and files it creates during updates. Written as octal numbers, without quotes.

0775/0664 is the “keep your own user as owner” setup: your user owns the files and PHP writes through the group. 0750/0640 only works when the web server is in the files’ group.

Removes Appearance → Theme File Editor and Plugins → Plugin File Editor, so a stolen admin login can’t paste code into your site. Updates keep working.

No installing, updating or deleting plugins and themes, no core updates, no file editor. For sites you deploy with Git or WP-CLI.

Stops security updates too. Automatic background updates turn off with it, so you must update from the command line or your deploy process.

Without this line WordPress installs minor (security and maintenance) releases by itself and lets you switch major ones on in Dashboard → Updates. The line overrides that switch.

Memory

For “Allowed memory size of … bytes exhausted” errors. WordPress only raises PHP’s memory_limit to this, never lowers it, and can’t pass a limit your host has locked.

Used in wp-admin and for image processing. WordPress already uses 256M here by default, so only set it to go higher.

Debugging

Reports every PHP error, warning and notice. Turn it on to find what breaks a page, then off again.

Write errors to a log file
Posts and trash

How many old versions WordPress keeps per post. By default it keeps all of them.

Old extra revisions aren’t removed at once: WordPress trims them the next time each post is saved. “Keep none” stops new ones and hides the old ones, but leaves them in the database.

Seconds between autosaves in the editor. The default is 60.

Posts, pages, media and comments in the trash are deleted for good after this many days. The default is 30.

Site address and HTTPS

Overrides the two addresses in Settings → General, for a move or when a wrong address locked you out. The database values stay, and come back if you remove the lines.

Can lock you out. A typo, http instead of https, or www when the site has none sends wp-admin to the wrong place. If that happens, delete the two lines over FTP or your host’s file manager.

WordPress 7.1 already turns this on when the WordPress address starts with https://, so you mostly need it while the address is still http.

Can lock you out. Only add it once https:// opens your site with a valid certificate. Behind a proxy that talks plain HTTP to the server (Cloudflare “Flexible” SSL) it causes a redirect loop.

Scheduled tasks

Stops WordPress from checking its schedule on page loads. Saves work on busy sites and makes timing exact on quiet ones.

Needs a cron job. Without one, scheduled posts, update checks and plugin tasks stop running. The cron line is under the code below.

Your lines

Before you save

    How I tested it

    On a WordPress 7.1.5 test site, I pasted each output into a real wp-config.php and checked that WordPress actually used the value: 32 of 32 checks passed. A few things worth knowing from the tests:

    • New keys and salts log everyone out (the old login cookie was rejected), but passwords keep working.
    • Passwords with quotes, backslashes and other special characters come out escaped, and PHP read them back exactly as typed.
    • WP_MEMORY_LIMIT only raises the limit. Setting it below the server’s value does nothing.
    • With post_max_size equal to upload_max_filesize, a file of exactly that size is refused, so the upload tab always sets post_max_size a bit higher.

    Limitations

    • The .user.ini and php.ini outputs were tested on Apache with PHP-FPM. The mod_php .htaccess and Nginx outputs, and the cPanel and hPanel steps, follow the official docs but weren’t run on those servers.