Category Archives: WordPress

Can’t install WordPress with LSCache on CyberPanel

It said it was successful, but the generic CyberPanel page still displayed when visiting the site.

Upon further investigation, the issue appeared to be with this command:

[email protected]:~# wp core download --allow-root --path=/home/example.com/public_html/
Downloading WordPress 5.5 (en_US)...
md5 hash verified: 983821e81b5b8398469e5c1807c4abf4
PHP Fatal error: Allowed memory size of 62914560 bytes exhausted (tried to allocate 36864 bytes) in phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Extractor.php on line 101

It looks like it ran out of memory during the installation.

Let’s review the memory limit and increase it if necessary.

Continue reading

Setup Mailtrap with WordPress

Mailtrap is a service that captures all mail sent by your site and prevents it from arriving at the intended recipient. It’s really useful for testing and debugging mail without having to write manual checks to ensure your users don’t get spammed with tests.

Setting up Mailtrap with WordPress is pretty straightforward, because all we need to do is overwrite the default SMTP server in the PHPMailer, which is what WordPress uses to send mail. It’s important to note that it will also trap mail sent from plugins like Contact Form 7.

Add the following hook in your theme’s functions.php file or throw this in a plugin:

1
2
3
4
5
6
7
8
9
10
function mailtrap($phpmailer) {
    $phpmailer->isSMTP();
    $phpmailer->Host = 'mailtrap.io';
    $phpmailer->SMTPAuth = true;
    $phpmailer->Port = 25;
    $phpmailer->Username = 'username';
    $phpmailer->Password = 'password';
}
 
add_action('phpmailer_init', 'mailtrap');
function mailtrap($phpmailer) {
    $phpmailer->isSMTP();
    $phpmailer->Host = 'mailtrap.io';
    $phpmailer->SMTPAuth = true;
    $phpmailer->Port = 25;
    $phpmailer->Username = 'username';
    $phpmailer->Password = 'password';
}

add_action('phpmailer_init', 'mailtrap');

Be sure to replace the username and password with your personal ones, which can be found by clicking on your inbox in Mailtrap. Look for the SMTP credentials.

Once the hook is in place, you’re done. Give it a go!

WordPress could not establish a secure connection to WordPress.org

I’m using Vagrant to work on a WordPress site and noticed the following error throughout several admin pages that attempt to connect to WordPress.org:

An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums. (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)

Continue reading

How to update and deploy WordPress as a Git submodule

WordPress 3.8.2, a security release, came out yesterday. Now, if you’re already on WordPress 3.8, your WordPress installation will most likely automatically update, but if you are using Git to manage WordPress as a submodule, and have auto-update disabled, you have to do that manually.

That said, it’s still super easy to do. It definitely outweighs not having a version control system.

Let’s look at the Git commands required to update WordPress from 3.8.1 to 3.8.2. Note that this will work for updating any version.

Continue reading

WordPress Upgrade: Peer certificate cannot be authenticated with known CA certificates

I was trying to upgrade WordPress on one of my servers, but kept receiving an SSL-related error:

Peer certificate cannot be authenticated with known CA certificates.

I verified the SSL certificate on the server and there are no issues with it as far as I can tell, but I’d be curious to know if someone else figures out the actual cause.

That said, and as a quick work-around, you can prevent cURL from verifying the certificate just during WordPress upgrades:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
add_action(
    'load-upgrade.php',
    'my_load_upgrade_php'
);
 
function my_load_upgrade_php() {
    add_filter(
        'http_request_args',
        'my_http_request_args',
        10,
        2
    );
}
 
function my_http_request_args($args, $url) {
    $args['sslverify'] = false;
    return $args;
}
add_action(
	'load-upgrade.php',
	'my_load_upgrade_php'
);

function my_load_upgrade_php() {
	add_filter(
		'http_request_args',
		'my_http_request_args',
		10,
		2
	);
}

function my_http_request_args($args, $url) {
	$args['sslverify'] = false;
	return $args;
}

What this will do is set CURLOPT_SSL_VERIFYPEER to false:

1
curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, false );