Category Archive : Uncategorized

This guide will show you how to extend or resize an ext2/3/4 and XFS File System without LVM at runtime. This could be a root partition configured with ext2/3/4 or XFS filesystem but without any LVM configured.

Step 1: Check your current root disk capacity

For this demonstration, I have a CentOS 7 VM with below partition scheme.

$ lsblk 
 NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
 sr0     11:0    1 1024M  0 rom  
 vda    253:0    0   10G  0 disk 
 └─vda1 253:1    0   10G  0 part /

As seen from the output, the root filesystem is on /dev/vda1 partition without LVM.

Step 2: Extend your OS root disk

I will extend my root block device to 30GB. I use KVM virtualization technology, so this guide works for me:

For KVM I can check virtual disk path using the command below:

$ sudo virsh domblklist centos7 
 Target   Source
-------------------------------------------------
 vda      /var/lib/libvirt/images/centos7.qcow2
 sda      -

$ sudo fdisk -l /var/lib/libvirt/images/centos7.qcow2
Disk : 10 GiB, 10739318784 bytes, 20975232 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

$ sudo qemu-img resize /var/lib/libvirt/images/centos7.qcow2 +20G
Image resized.

If you’re on a different Virtualization platform, refer to its documentation for how to extend OS virtual disk.

Step 3: Grow VM partition

Start your VM and ssh as a user with sudo privileges. The first thing to do is to confirm the new disk size.

$ lsblk 
 NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
 sr0     11:0    1 1024M  0 rom  
 vda    253:0    0   30G  0 disk 
 └─vda1 253:1    0   10G  0 part /

We can see the disk has grown by 20GB, from 10GB to 30GB. The next action is to expand the partition (Partition 1) in our example, to the maximum size the disk provides.

Install cloud utils package

For those new to growpart, it is a Linux command line tool used to extend a partition in a partition table to fill available space. This command is provided by cloud utils package.

On Ubuntu / Debian system, run:

sudo apt -y install cloud-guest-utils gdisk

For CentOS / RHEL / Fedora server, run:

sudo yum -y install cloud-utils-growpart gdisk

Help page can be viewed by passing -h argument

# growpart -h
growpart disk partition
   rewrite partition table so that partition takes up all the space it can
   options:
    -h | --help       print Usage and exit
         --fudge F    if part could be resized, but change would be
                      less than 'F' bytes, do not resize (default: 1048576)
    -N | --dry-run    only report what would be done, show new 'sfdisk -d'
    -v | --verbose    increase verbosity / debug
    -u | --update  R update the the kernel partition table info after growing
                      this requires kernel support and 'partx --update'
                      R is one of:
                       - 'auto'  : [default] update partition if possible
                       - 'force' : try despite sanity checks (fail on failure)
                       - 'off'   : do not attempt
                       - 'on'    : fail if sanity checks indicate no support

   Example:
    - growpart /dev/sda 1
      Resize partition 1 on /dev/sd

Now use growpart to extend your partition.

$ sudo growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=20969472 end=20971520 new: size=62912479,end=62914527

This will resize partition 1 on /dev/vda.

Validate the change.

$ lsblk 
 NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
 sr0     11:0    1 1024M  0 rom  
 vda    253:0    0   30G  0 disk 
 └─vda1 253:1    0   30G  0 part /

Step 4: Resize ‘/’ partition to fill all space

The last step is to resize the file system to grow all the way to fill added space

For ext4 file system, use resize2fs

$ sudo resize2fs /dev/vda1
resize2fs 1.42.9 (28-Dec-2013)
 Filesystem at /dev/vda1 is mounted on /; on-line resizing required
 old_desc_blocks = 2, new_desc_blocks = 4
 The filesystem on /dev/vda1 is now 7864059 blocks long.

If your filesystem is XFS, it can be grown while mounted using the xfs_growfs command:

sudo xfs_growfs /

Confirm new size using df -h

$ df -hT | grep /dev/vda
/dev/vda1      ext4       30G  1.2G   27G   5% /

Congratulations!, you have successfully resized an ext2/3/4 or XFS root partition on Linux without LVM.

Go to system/startup.php and find following lines of code:

if (!ini_get('date.timezone')) {
	date_default_timezone_set('UTC');
}

Replace with following lines of code by changing to your timezone

date_default_timezone_set('Australia/Sydney');

Synchronize PHP and Database Timezone

The query we use to set database timezone if you are super admin is below:

SET time_zone='offset';

But everyone has no super admin access so need to change in the code level. For that go to system/library/db/mysqli.php if you are using MySQLi and add code below after $this->connection->query(“SET SQL_MODE = ””);

$dt = new \DateTime();
$this->connection->query("SET time_zone='" . $dt->format('P') . "';");

With these changes your timezone in Opencart are changed.

Let us know if you find any issues, thanks a lot.

OpenCart is one of the simplest e-commerce platforms to build an online store. OpenCart offers you an ‘easy-to-work-with’ code-base with which you can get an e-Commerce site online, quickly. If you are looking for a safe way to move OpenCart website from one domain to another, follow the process below.

Here are the steps to migrate / move OpenCart website to a new server.

1. Download ALL the files from old server.
2. Create a backup of Database through PhpMyAdmin
3. Upload files to NEW SERVER
4. Install Database on NEW SERVER through PhpMyAdmin
5. Update the configuration files config.php and admin/config.php to reflect your new domain path.

The file should now open up for editing. Here, you will need to edit a few lines of code. Find the lines:

// HTTP

define('HTTP_SERVER', 'http://yourdomain.com/');

// HTTPS

define('HTTPS_SERVER', 'http://yourdomain.com/');

// DIR

define('DIR_APPLICATION','/
home/sites/YOUR-DOMAIN/public_html/catalog/');
define('DIR_SYSTEM','/home/sites/YOUR-DOMAIN/public_html/system/');
define('DIR_DATABASE','/home/sites/YOUR-DOMAIN/public_html/system/database/');
define('DIR_LANGUAGE','/home/sites/YOUR-DOMAIN/public_html/catalog/language/');
define('DIR_TEMPLATE','/home/sites/YOUR-DOMAIN/public_html/catalog/view/theme/');
define('DIR_CONFIG','/home/sites/YOUR-DOMAIN/public_html/system/config/');
define('DIR_IMAGE','/home/sites/YOUR-DOMAIN/public_html/image/');
define('DIR_CACHE','/home/sites/YOUR-DOMAIN/public_html/system/cache/');
define('DIR_DOWNLOAD','/home/sites/YOUR-DOMAIN/public_html/download/');
define('DIR_LOGS','/home/sites/YOUR-DOMAIN/public_html/system/logs/');

You will need to update these to your correct path. Contact your hosting company for the full path to your public folder.

Next, you need to update the database connection settings. Find the code below:

// DB

define('DB_DRIVER','mysql');
define('DB_HOSTNAME','localhost');
define('DB_USERNAME','your-old-opencart-databse-username');
define('DB_PASSWORD','your-old-opencart-databse-password');
define('DB_DATABASE','your-old-opencart-databse-database');
define('DB_PREFIX','oc_');

You will need to replace these with the new details made in step 3;

DB_HOSTNAME = Your database host (usually localhost).
DB_USERNAME = Your Database username.
DB_PASSWORD = Your Database password
DB_DATABASE = Your database name

Once you have updated these, save the changes & you are done.

Method-1: First Check the Timezone in Settings > Store. Make sure you set to UTC.

If you need to change it back you can in the SQL table “oc_setting” column “key” value “config_timezone” in the “value” column change it back to “UTC”

UPDATE oc_setting SET value='UTC' WHERE key = 'config_timezone';

If still issue, follow below method.

Method-2: You need to set your php time and mysql time the same. its deleting cookies to soon. You can fix this.

Open:

system/config/default.php
system/config/catralog.php
system/config/admin.php

Find:

$_[‘session_engine’] = ‘db’;

Replace:

$_[‘session_engine’] = ‘file’;

 

 

Step-1: Add 2 hidden fields to the contact form

[hidden your-first-name id:first-name-p]
[hidden your-last-name id:last-name-p]

Step-2: Write below jquery script in the footer

$("#name_field_id").focusout(function(){
     str = $(this).val();
     if(str){
      s = str.split(/(?<=^\S+)\s/); //split string in name field after first space found. 
      $("#last-name-p").val(s[1]); //s[1] value after the first space set to hidden field.
     }
  });

Output will be list this:-

ERROR:-
The response from the remote server was:
550 Please turn on SMTP Authentication in your mail client. mail-qk1-f172.google.com [209.85.222.172]:36503 is not permitted to relay through this server without authentication.

SOLUTION:-

Manage SMTP restrictions

Click Enable to deny users the ability to bypass your mail server to send mail. To allow users the ability to bypass your mail server, click Disable.

(WHM >> Home >> Security Center >> SMTP Restrictions)

We recently redesigned a WordPress site for a client who was migrating away from WP Engine. When we migrated the client to the new host, they still had a “WP Engine” section in their WordPress dashboard main menu.

WP Engine WordPress Menu Item

Since this feature set would no longer be utilized, it was best to get the plugins removed to keep things lean and tidy.

While cleaning up those WPE remnants, we put together a short guide on how to remove these plugins on your own. Hope it helps!

1. First things first, backup

In order to remove these WP Engine plugins and remnants, we’ll be making some changes to the file structure, and modifying a core WordPress file. That means you should create a full backup of your WordPress environment in the event that something goes wrong. Broken sites and lost data make for a bad day, so backup to stay safe!

2. Delete WP Engine Plugin Folders and Files

Once your backup is safely made, connect to your WordPress environment via FTP, or via your cPanel’s file manager. Locate the “wp-content” folder in your base WordPress directory, then delete the following files and folders.

  • wp-content/mu-plugins/mu-plugin.php
  • wp-content/mu-plugins/wpengine-common/
  • wp-content/mu-plugins/slt-force-strong-passwords.php
  • wp-content/mu-plugins/force-strong-passwords/
  • wp-content/mu-plugins/stop-long-comments.php
  • wp-content/advanced-cache.php
  • wp-content/object-cache.php
  • wp-content/mysql.sql

Once you have deleted all of these files and folders, if the “mu-plugins” folder is now empty, you can go ahead and delete it too.

3. Delete WP Engine git files from the root

Next, head back to your WordPress root directory, and look for and delete these two files.

  • .gitattributes
  • .gitignore

WP Engine .gitattributes and .gitignore files

4. Generate a fresh wp-config.php file for your installation

WP Engine modifies your site’s wp-config.php file. Now that you have removed all of their leftover elements from your installation, you will also want to make sure that your site is running on a clean wp-config file.

Firstly, locate and open the wp-config.php file in the root of your WordPress environment.

Now head to GenerateWP to grab a clean code set for the wp-config file. Copy the code from GenerateWP and paste it into a new file in your text editor.

Now jump back to your current wp-config file which you opened a moment ago. You will want to copy the values for all of these fields and paste them into the new wp-config file that you just created.

Database credentials

  • define( ‘DB_NAME’,
  • define( ‘DB_USER’,
  • define( ‘DB_PASSWORD’,
  • define( ‘DB_HOST’,
  • define( ‘DB_CHARSET’,

wp-config database values

If your table prefix begins with anything other than “wp_” (uncommon)

Be sure to update your table prefix if it begins with anything other than “wp_”

  • $table_prefix =

wp-config table prefix

WordPress Secret Keys & Salts

  • define( ‘AUTH_KEY’,
  • define( ‘SECURE_AUTH_KEY’,
  • define( ‘LOGGED_IN_KEY’,
  • define( ‘NONCE_KEY’,
  • define( ‘AUTH_SALT’,
  • define( ‘SECURE_AUTH_SALT’,
  • define( ‘LOGGED_IN_SALT’,
  • define( ‘NONCE_SALT’,

wp-config secret keys and salts

After entering all of your database values, keys, and salts, save the new file as wp-config.php, then upload it to the root of your WordPress installation, overwriting the existing file.

Once that is complete, log into your WordPress admin panel and you should now be free of all WP Engine menus and plugins.

Chrome and Firefox have started showing insecure warnings on sites without SSL certificates. Without SSL, your website will show insecure to the visitors. Therefore, using an SSL-encrypted connection for safety, accessibility or PCI compliance reasons is necessary. It becomes very important to redirect from HTTP to HTTPS.

What is SSL?

SSL (Secure Sockets Layer) is a standard security protocol for establishing encrypted links between a web server and a browser in an online communication.

The usage of SSL technology ensures that all data transmitted between the web server and browser remains encrypted.

An SSL certificate is necessary to create SSL connection. You would need to give all details about the identity of your website and your company as and when you choose to activate SSL on your web server. Following this, two cryptographic keys are created — a Private Key and a Public Key.

Learn More: Why SSL is Critical?

In order to force your web traffic to use HTTPS, edit the codes in the .htaccess file.

Before we move onto redirecting HTTP to HTTPS, here’s how you can edit .htaccess file. If you already know skip to Redirection steps.

Editing .htaccess File

There are instructions/directives in the .htaccess file that tell the server how to act in certain scenarios and directly affects how your website functions. Common directives in .htaccess file:

  • Redirects
  • Rewriting URLs

Ways to edit an .htaccess file:

  1. Edit the file on your computer and upload it to the server using FTP.
  2. Use “Edit” mode in FTP program that allows you to edit a file remotely.
  3. Use a text editor and SSH to edit the file.
  4. Use the File Manager in cPanel to edit the file.

Editing .htaccess in cPanel File Manager

Note: Backup your website in case something goes wrong.

  1. Login to cPanel
  2. Files > File Manager > Document Root for:
  3. Now select the domain name you want to access
  4. Check “Show Hidden Files (dotfiles)”
  5. Click “Go”
  6. After a new tab or window opens, look for the .htaccess file.
  7. Right click on the .htaccess file and click on “Code Edit” on the menu.
  8. A dialogue box may pop up asking about encoding. Click “Edit” button to continue.
  9. Edit the file
  10. “Save Changes” when done.
  11. Test your website to make sure it is done correctly. In case, there is an error, restore to the previous version and try again.
  12. Once you are done, click “Close” to close the window.

Redirecting HTTP to HTTPS

1. Redirect All Web Traffic

If you have existing code in your .htaccess, add the following:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

2. Redirect Only a Specific Domain

For redirecting a specific domain to use HTTPS, add the following:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

3. Redirect Only a Specific Folder

Redirecting to HTTPS on a specific folder, add the following:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.yourdomain.com/folder/$1 [R,L]

Note: Replace “yourdomain” with your actual domain name wherever required. Also, in case of the folder, replace /folder with the actual folder name.

Think it was helpful? Share this article to help others come on HTTPS.