:~
knowledge :: tips

Tips & tricks. Short and tested.

Tricks we use on our own servers every day. Every tip comes with the command, plus a link to the explanation if you want to know more.

#claude

Copy the Claude code with Ctrl+A, not a double-click

The code you get when connecting Claude has two parts with a # in between. A double-click only selects the first part, and then you get "Invalid code".

Connect Claude →

claude: command not found? Check where the binary lives

DirectAdmin's jailshell only exposes /usr and your home directory. An install in /opt is invisible to users. Put the binary under /usr/local/lib.

su - username -c 'which claude'
Explanation →

Say "make a backup first" for big jobs

Claude makes a backup on its own before WordPress updates and database work. For other big jobs it helps to ask for one explicitly.

Make a backup first, then update all plugins
#wordpress

Run WP-CLI on the same PHP version as your site

wp uses the server's default PHP. If your site runs on a different version, call WP-CLI through that PHP binary.

/usr/local/php84/bin/php /usr/local/bin/wp plugin list
Safely update WordPress →

Strange output from wp? Skip the plugins

Some plugins print notices or run actions on every WP-CLI call. --skip-plugins --skip-themes gives you clean output, and it works on a broken site too.

wp --skip-plugins --skip-themes plugin list --update=available

Always --dry-run a search-replace first

Replacing a domain or URL in the database touches hundreds of rows. Check how many first, make a backup, and only then run it for real.

wp search-replace 'https://old.com' 'https://new.com' --dry-run

Roll back one plugin after a failed update

You don't need to restore a full backup straight away. Just put that one plugin back on its previous version.

wp plugin update plugin-name --version=1.2.3 --force
#php

Per-site PHP settings with .user.ini

Need more memory or bigger uploads? Put a .user.ini in the web root. It can take a few minutes before it takes effect.

memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
#security

PHP files in wp-content/uploads? Red flag

The uploads folder is for images and documents, not PHP. A .php file in there is a well-known sign of a hack.

find wp-content/uploads -name '*.php' ! -name index.php
#git

Deploy key: leave "Allow write access" off

To deploy your website the server only needs to read. A key with write access could also push to your repository.

Connect a repository →

Deleted from your repository is not deleted from your site

A deploy writes what is in the repository but never removes anything. Remove old files from the website yourself.

Automatic deploys →

DirectAdmin Git on a subdomain? Use the main domain

DirectAdmin's Git API only works on main domains. Create the repository under the main domain and set the deploy directory to the subdomain's folder.

DirectAdmin Git API →
#hosting

Command ends with "Killed"? You hit a limit

Exit code 137 means a process was stopped because your account reached its memory limit. Run heavy jobs one at a time, or build elsewhere.

Limits →

Change not showing? Purge the LiteSpeed cache

LiteSpeed Cache may still serve an old version of a page. Purge the cache after a change.

wp litespeed-purge all