Sort Array by Value in PHP

<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
arsort($age);
?>
Advertisements

Setup Load Balancer on DigitalOcean

  1. Create at least 2 nodes (droplets) on the same region. (IP1, IP2).
  2. Create load balancer (IP3).
  3. Create DNS record for IP3 on your domain DNS interface.
  4. Install web server on all nodes for your domain or subdomain.
  5. You can create Let’s Encrypt SSL certificates on all nodes
    for your domain or subdomain, they will work.

Uninstall ClamAV from CentOS (VestaCP)

If you experience High CPU usage for clamd:

yum remove clamav*

Go to /usr/local/vesta/conf/vesta.conf and change line:

ANTIVIRUS_SYSTEM='clamav-daemon'
ANTIVIRUS_SYSTEM=''

Go to /etc/exim/exim.conf and change line:

CLAMD =  no

Note: This way is not perfect. There are many log records for “clamd is down”.

Use Let’s Encrypt SSL on VestaCP 8083 Panel

Thanks to https://git.scit.ch/rs/VestaCP-SystemSSL

nano /etc/cron.daily/vesta_ssl

Please change the [USER] and [DOMAIN] part with your system domain.

#!/bin/bash

cert_src="/home/[USER]/conf/web/ssl.[DOMAIN].pem"
key_src="/home/[USER]/conf/web/ssl.[DOMAIN].key"
cert_dst="/usr/local/vesta/ssl/certificate.crt"
key_dst="/usr/local/vesta/ssl/certificate.key"

if ! cmp -s $cert_dst $cert_src
then
        # Copy Certificate
        cp $cert_src $cert_dst

        # Copy Keyfile
        cp $key_src $key_dst

        # Change Permission
        chown root:mail $cert_dst
        chown root:mail $key_dst

        # Restart Services
        service vesta restart &> /dev/null
        service exim4 restart &> /dev/null
fi

chmod +x /etc/cron.daily/vesta_ssl