Error: Please install all available updates for your release before upgrading [SOLVED]

When updating from Ubuntu 16.04 to 18.04 we used the

do-release-upgrade command as one of the steps to get the newer versions.  While using that method the update Ubuntu’s core we came across a known bug that would not allow us to continue with the upgrade. Instead, it would give the following error message:

Checking for a new Ubuntu release
Please install all available updates for your release before upgrading.

 

The Fix

If you experience the error above run each command below.

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade
sudo do-release-upgrade

Once you’ve updated your server with the commands above, feel free to continue with our How to Upgrade Ubuntu 16.04 to 18.04 tutorial.

How to Install PHP 7.2 on Ubuntu 16.04

Using PHP 7.2 on an Ubuntu server is highly recommended over previous PHP versions for several reasons, first being security. Active Support for PHP 7.2 goes until November 30th, 2019 and Security Support until Nov 30, 2020. Older versions like 7.0 and anything 5.6 and below are no longer getting any support and can leave open security holes on a server if they are not replaced. Another main reason to upgrade is the big performance increase over previous versions when PHP 7.2 is installed and is using the OPcache module.  This can greatly decrease the time it takes for your webpage to load! If you are developing a site locally or launching it on one of Liquid Web’s Ubuntu VPS or Dedicated Servers, using PHP 7.2 or newer would be the way to go.

Continue reading “How to Install PHP 7.2 on Ubuntu 16.04”

How to Upgrade Ubuntu 16.04 to Ubuntu 18.04

If you are still using Ubuntu version 16.04, you may want to consider updating to the latest Long Term Support release, version 18.04. In this post, we will cover what a Long Term Support release is and why you would want to use it. You will also learn the significant changes between 16.04 and 18.04. Last, but not least, you will also learn how to upgrade your server from Ubuntu 16.04 to Ubuntu 18.04.

Continue reading “How to Upgrade Ubuntu 16.04 to Ubuntu 18.04”

Troubleshooting: Too Many Redirects

The error “too many redirects” means that the website keeps being redirected between different addresses in a way that will never complete. Often this is the result of competing redirects, one trying to force HTTPS (SSL) and another redirecting back to HTTP (non-SSL), or between www and non-www forms of the URL.

Continue reading “Troubleshooting: Too Many Redirects”

Reset Your WordPress Admin Password

Whether its a hacked site or a lost password, you may find that you are locked out of your WordPress Admin control panel. If you’ve forgotten your password or don’t have access to the email address that the “Lost your password?” link sends to, you still have one more option to access it. Through the database!  WordPress’ database stores all WordPress username, encrypted passwords, and the user’s email address and thus can be edited through a database client like phpMyAdmin. In this tutorial, we’ll be showing you how to edit the email address and change your user’s password.

Continue reading “Reset Your WordPress Admin Password”

Gmail Blacklist

As one of the most trusted email providers, Google keeps top-notch security by maintaining their own blacklist and security information. With the numerous users the company provides email accounts to, there is an overwhelming amount of data that Google can scrutinize for spam or malicious emails. By gathering this valuable information, rules are created to filter problem content. These rules are highly sophisticated, and as this data is compiled, specific IP addresses are flagged and sorted into what is called a blacklist.

The Gmail blacklist is designed to prevent unwanted spam, malicious content and excessive amounts of emails. Some of the most common reasons for getting blocked are as follows;

  • Large amounts of emails sent from a new IP address.
  • Sudden changes in email volumes.
  • High bounce rates.
  • Spam reports from Gmail users.
  • Incorrect DNS settings.
  • Low sender scores.
  • IP listing in public blacklists.

Gmail’s blacklist may also take information from several public blacklists in order to block malicious/unwanted/compromised IP addresses prior to having any complaints from them. This is a preventative measure intended to keep the lowest amount of spam possible. All things considered, this is the reason your Gmail address will likely have far less unwanted emails or better filtering rules.

 

There are several effects to being on the Gmail blacklist, and the most obvious is that all email from the IP address sending mail will be blocked. This means everything including personal communication, bulk messages, email lists, etc. Not only will it block the problem domain or user, but everything else on the SMTP server attempting to use that IP address.

This poses a large issue for shared IP addresses on any server. But there is hope! Both in the form of preventative measures as well as ways to redeem your IP address and clear it from the blacklist. Before clearing your IP address we highly suggest you review the information to make sure nothing has been compromised. Blacklists often mean an email has been hacked, or there are just poor emailing practices.

Preventatively, you can protect the IP you are using with SPF records should you have no current issues. These records will assist in providing additional verification for the IP address you are using and help keep your IP clean.

 

If you’re already experiencing issues with Gmail delivery, then the first step is to diagnose the SMTP server. If this is a managed environment, it’s best to contact your hosting provider and ask them to review the specific email address having issues. Be sure to include example messages, any bouncebacks you’ve received and any specifics you can remember. (Subject lines, recipients, time of email, etc.) This should help in the retrieval of data.

You can actually get a full copy of the headers of any messages having issues directly from your email client. If you need information on how to do this, you can always check out this article. View full e-mail headers.

If you are having trouble delivering mail and can’t find any fault on your SMTP server, then it’s time to search some blacklists to test the waters. One of the most reputable places to start is mxtoolbox.com. Although Gmail does not state what mechanisms they use to blacklist, this site allows you to search your domain and query a large number of blacklists that should tell you if there are issues coming from your server. Along with cleanup instructions and links to each blacklist, this site is a handy tool for anyone looking to admin their own email.

There are several other sites that can be referenced for blacklist checking, but unfortunately, the only one way to get information from Google specifically. If you are not on a blacklist and there are no issues coming from the SMTP server, then it’s time to fill out a Delivery Problem Form. This form asks for basic information as well as any technical information you can provide. The more information you can provide, the easier your process will become for a listing check and possible removal or de-listing.

From there, Google should help you through the rest of the process or provide further information that will move the issues along. But that still leaves us with one question….

 

Well, the guidelines differ depending on what you are using email for. As some of us just use email for personal use the rules are pretty simple. Don’t send malicious content, make sure you don’t attempt to use huge files or send to everyone in your address book every thirty minutes for no reason, etc. These are all suspicious behaviors or hard rules that will either fail or cause issues.

Really we can boil the best practices down to a few important rules of thumb.

  • Do not spam.
    • This includes redirects. Google has specific best practices for pulling email from other accounts, so setting up forwarders in other SMTP servers to shovel all mail over to Google addresses will simply count as spam.
  • Follow the bulk mail guidelines.
  • Pull, don’t push.
    • Meaning import messages or set Google to pull from third party, don’t forward to Google automatically. (Manual forwarding to share information is perfectly fine.)
  • Use SPF records.
    • SPF records are great added security and verification.
  • Change your passwords frequently.
    • Remember, passwords are vital and knowing the best practices for safe passwords is very important.
  • Watch for, and read, bounceback emails.

Following the few suggestions above will keep your SMTP server healthy and happy. When all information intended for Google is pulled via their methods, the likeliness of being blocked for false positives (meaning blocked for legitimate practices done incorrectly) will go down exponentially.

 

How To Change Website Name in WordPress

You may have noticed, when transferring a website, that the URL is still stuck on the old site even though you have changed the virtual host file to reflect the new domain name. Or you may see the URL entirely greyed out in your WordPress portal. This mismatch can happen if you can’t change the URL within WordPress to reflect the new site name. In this tutorial, we will show you how to change the URL through the database.

Step 1: Enter the Database

If you don’t have your database credentials you can certainly grab them from your wp-config.php file, usually located in /var/www/html. Copy your username and password, you’ll need these to enter phpMyAdmin.

/** MySQL database username */
define('DB_USER', 'yourusername');
/** MySQL database password */
define('DB_PASSWORD', 'userpassword');

If you Ubuntu 14.XX and higher, you can visit https://yourhostname.com/phpmyadmin and enter your database username and password copied from your wp-config.php. CentOS users can usually go to their WHM panel and type in “phpMyAdmin” into the search bar for a shortcut into their database.  With specialty platforms like Managed WordPress or Cloud Sites check with your support team to locate your phpMyAdmin instance.

Step 2: Find the WP_Options Table

Once you’ve entered phpMyAdmin, click on your database name on the left, in this case, ours is named 929368_kittens.In WordPress' database the wp-options table has the siteurl and home row needed to change the URL.

Locate wp_options, afterwards you’ll see rows on the right hand side.  The home and site_url row is needed as we will be changing these values to the new website name.

Note:
Search home or siteurl in the Filter rows: in the search box to these entries if not readily visible.

Select Edit in the row of siteurl and home to edit the URL, including “http” or “https” (if you already have an SSL on the domain name). Once you’ve changed your URL, select GO to save your changes.

In a WordPress database change the URL by editing the siteurl and home row.

Step 3: Update DNS

Your WordPress instance is now set to your new URL!  If you haven’t done so already, you may need to set your A record to your new IP address or clear your browser’s cache to visit your new URL.

Changing the domain name within WordPress is simple enough but sometimes code within an nginx.conf or .htaccess file can also direct a site back to the old domain name. It should also be noted that sometimes a plugin, theme or database can be referenced or hardcoded to read an old domain name.  For either problem, the Velvet Blue’s plugin or WP-CLI’s search and replace command cater to the issue.  Our Managed WordPress platform performs name changes automatically from our control panel, as well as core updates.  Check out how our Managed WordPress product can streamline your work.

Using a Cron Wrapper Script

This tutorial is intended to do two things: to expand on the Cron Troubleshooting article; and to give an overview of a simple scripting concept that uses the creation of a file as a flag to signify something is running. This is primarily useful when you need to run something continuously, but not more than one copy at a time. You can create a file as a flag to check if a job is already running, , and in turn, check for that flag before taking further action.

The direct application of this is when you have a cron job that runs every minute, or every few minutes. With a rapidly repeating cron, if the previous job takes any longer than the scheduled time, these tasks can pile up causing load on the server, or exacerbating other issues. To avoid this, a simple script can be set up in the crontab (in place of the intended cron task). When the cron is run, it only runs the actual task if there is not a competing process already running.

Why Use a Cron Wrapper?

A cron wrapper is used when you have a cron job that needs to run back to back but needs to not step on itself. This is good for tasks that you want to setup to run continuously. Jobs that should be run anywhere between every minute and every five minutes should be utilizing a wrapper like this.

If you do not use a wrapper on a cron job that runs too frequently, you can get multiple jobs running at the same time trying to do the same thing. These competing tasks slow down the whole works. These “stacking cron jobs” can even get so out of hand that it overloads a server and causes the server to stop responding normally.

What is a Cron Wrapper?

The reason this is called a cron wrapper is that it is a script that wraps around the cron job, and checks if another instance of the cron is already running. If there is another copy running, the wrapper will make the cron skip this run, and wait until the next run to check again. There are a few ways that the cron wrappers ensures no overlap.

 

Process Check Method

One way is to check all the running processes for the user and double checks that there isn’t already another process with the same name or attributes as the one you want to run. This is how Magento’s cron.sh file works, it checks for another instance of cron.php being run as the user, and if there is one running, it exits. This can be complicated to do reliably, and so is not something that we would recommend for just starting out.

 

Lockfile Method

A straightforward method is to use what is called a lockfile. The cron wrapper checks if the lockfile (any file with a specific name/location) exists at the start of the run. If the lockfile is missing, the script creates that file and continues. The creation of the lockfile signals the start of the cron job. When the cron job completes the wrapper script then removes the lock file.

So long as the lockfile exists, a new wrapper will not run the rest of the cron job while another one is running. Once the first run completes and the lock is removed another wrapper will be able to create a new lock file again and process normally.

 

A Wrapper Script Example

To start, we want to create a simple bash script. Within a file we state the script to be interpreted by the program /bin/bash

#!/bin/bash

Then we want to define the name and location of the lockfile we’ll be using as our flag.

# Set lockfile name and location
lockfile="~/tmp/cronwrapper.lock"

 

Next, the script needs to check if that lockfile exists. If it does exist, then another copy of the script is already running, and we should exit the script.

# Check if the lockfile exists
if [[ -f $lockfile ]]; then
# If the lockfile exists quit
exit;

Else, if the lockfile does not exist, then we should create a new lock file to signify that we are continuing with the rest of the script. Creating the lockfile also tells any future copies that might be run to hold off until the lockfile is removed. We also want to include the actual job to be run, whether that’s a call to a URL through the web, running a PHP file on the command line, or anything else.

# If the lockfile is missing continue
else
# Create the lockfile
touch $lockfile
# Insert cron task here/code>

Once the intended job is run and completes, we want to clean up our lockfile, so that the next run of the cron job knows that the last run completed and everything is ready to go again.

# Cleanup the lockfile
rm -f $lockfile
fi

In the example above, it is convenient to define the lock file as a variable ($lockfile) so that it can be referenced easily later on. Also if you want to change the location, you only have to change it one place in the script.

This example also uses a “~” in the path to the lock file as a shortcut. This tells the shell to assume the user’s home directory. As such, the full path would look something more like this: /home/username/tmp/cron.lock.

However, by using the “~” you can use copies of the same script for many users on the same server, and not have to modify the full path for each user. The shell will automatically use the home directory for each user when the wrapper script is run.

Putting It All Together (cronwrapper.sh)

You can copy and paste the following into your text editor of choice on your server. You can name it whatever you want, but here are all the parts put together.

#!/bin/bash
lockfile="~/tmp/cronwrapper.lock"
if [[ -f $lockfile ]]; then
exit;
else
touch $lockfile
# Insert cron task here
rm -f $lockfile
fi

This is a very simple example and could be expanded much further. Ideally, you might add a check  to ignore a lock file older than an hour and to run a new instance of cron job anyway. This would account for an interrupted job that failed to clean up after itself. Another extension might be to confirm that the previous job completed cleanly,. Or yet another suggestion, would check for errors from the cron job being run and make decisions or send alerts based on those errors.  The world is your oyster when it comes to cron wrappers! Take a look at our Liquid Web’s VPS servers, for tasks like these to run smoothly.