Email Validation with Field Pattern

<input type=”email” name=”sample_email” pattern=”[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$”>


Random Nonce for Non User

Will only be generated if user not login access nonce.

add_filter( ‘nonce_user_logged_out’, ‘generate_randomUID’ );
function generate_randomUID( $uid ) {
if($uid != 0){
return $uid;
return wp_generate_uuid4();


Digital Ocean Droplet Ubuntu 20 – Nginx, Php, Mysql, Phpmyadmin

Digital Ocean

  • Create Droplet on Digitalocean
  • New SSh Key
    • Open puttygen and generate new key
    • Save private key and Save public key, no phasspassword is okay
    • Copy the key Content that has been generated by puttygen
    • Paste it to the SSh field on Digitalocean, and name the key

Putty on Server

  • sudo apt update
  • Nginx
    • sudo apt install nginx
    • sudo ufw app list
      • Check which UFW profiles are available
    • sudo ufw allow ‘Nginx HTTP’
      • Since you haven’t configured SSL for your server in this guide, you will only need to allow regular HTTP traffic on port 80
    • curl -4
      • Check IP address is accessible from the internet
      • Try to access the IP address from the browser
  • Mysql
    • sudo apt install mysql-server
  • Php
    • sudo add-apt-repository -y ppa:ondrej/php
    • sudo add-apt-repository -y ppa:ondrej/nginx-mainline
    • sudo apt update -y
    • sudo apt upgrade -y
    • sudo apt install -y -q php8.1-{cli,fpm,mysql,gd,soap,mbstring,bcmath,common,xml,curl,imagick,fileinfo,gettext,mbstring,SimpleXML,zip}
  • Configure Nginx
    • sudo mkdir /var/www/your_domain
      • Create root directory for website
    • sudo chown -R $USER:$USER /var/www/your_domain
      • Assign ownership of the directory
    • sudo nano /etc/nginx/sites-available/your_domain
      • server {
            listen 80;
            server_name your_domain www.your_domain;
            root /var/www/your_domain;
            index index.html index.htm index.php;
            location / {
                try_files $uri $uri/ =404;
            location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            location ~ /\.ht {
                deny all;
      • CTRL+X and then y and ENTER to confirm
    • sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/
    • sudo unlink /etc/nginx/sites-enabled/default
    • sudo nginx -t
    • sudo systemctl reload nginx
    • nano /var/www/your_domain/index.html
      • Hello world!
      • CTRL+X and then y and ENTER to confirm
    • curl -4
      • Try to access the IP address from the browser
  • Phpmyadmin
    • sudo apt install phpmyadmin
    • Click Tab straight to OK, without choosing any web server
    • Yes for dgconfig-common, set password
    • sudo ln -s /usr/share/phpmyadmin /var/www/your_domain/phpmyadmin
    • sudo mysql -u root -p
      • enter mysql password
      • CREATE USER ‘pmauser’@’localhost’ IDENTIFIED BY ‘password_here’;
      • GRANT ALL PRIVILEGES ON *.* TO ‘pmauser’@’localhost’;
      • exit
    • curl -4
      • Try to access the IP address from the browser, http://your_domain/phpmyadmin
    • sudo mv /var/www/your_domain/phpmyadmin /var/www/your_domain/hide_phpmyadmin
      • Secure the url from common url phpmyadmin
    • sudo apt install apache2-utils
      • Secure phpmyadmin with popup credential
      • sudo htpasswd -c /etc/nginx/.htpasswd username , set new password after that
      • sudo nano /etc/nginx/sites-available/your_domain
        • location /hide_phpmyadmin {
                  auth_basic "Restricted Access";
                  auth_basic_user_file /etc/nginx/.htpasswd;
      • sudo service nginx reload
  • Firewall
    • sudo nano /etc/default/ufw
      • Check that IPV6=yes
    • sudo ufw default deny incoming
    • sudo ufw default allow outgoing
    • sudo ufw app list
    • sudo ufw allow OpenSSH
      • Or sudo ufw allow 22
      • Or sudo ufw allow ssh
    • sudo ufw show added
      • Check rules that have been added
    • sudo ufw enable
    • sudo ufw allow ‘Nginx Full’
      • Include sudo ufw allow http
      • Include sudo ufw allow https
  • Fail2ban
    • apt install fail2ban
  • Add New User
    • adduser sammy
      • Setup password and information details
    • usermod -aG sudo sammy
    • su – sammy
      • Switch active user to sammy
    • sudo ls -la /root
      • Test one of the sudo command
      • Enter password for confirmation


References :