Category Archives: PHP

Enable auto index on website hosted on Ubuntu with CyberPanel and OpenLiteSpeed

I have a server at DigitalOcean with Ubuntu, CyberPanel, and OpenLiteSpeed, and wanted one of my websites to display an auto index of all the files uploaded to it.

There is a default.php script in /usr/local/lsws/share/autoindex that simulates Apache’s auto index, which suffices for my needs, but if you don’t want to use the default, you could copy and edit default.php to create your own template.

Now, to enable and use this auto index, you have to adjust the index directive in your website’s virtual host configuration file:

index  {
  useServer   1
  indexFiles  index.php, index.html
  autoIndex   1
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:

function mailtrap($phpmailer) {
    $phpmailer->Host = '';
    $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 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:


function my_load_upgrade_php() {

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

What this will do is set CURLOPT_SSL_VERIFYPEER to false:

curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, false );