Tags Archives: website

Website Not Rendering Correctly (including the WordPress Admin Dashboard)

The problem:

 

Checking in Chrome DevTools, we get the following output for the Knowledge Base plugin admin page which was not displaying correctly in the Admin Dashboard.

 

The site itself was also not rendering correctly.

 

Mixed Content: The page at ‘https://kevwells.com/wp-admin/options-general.php’ was loaded over HTTPS, but requested an insecure element ‘https://3.222.27.169/wp-content/plugins/css-javascript-toolbox/views/blocks/manager/public/images/menu.svg’. This request was not upgraded to HTTPS because its URL’s host is an IP address.
options-general.php:33 GET https://3.222.27.169/wp-content/plugins/sucuri-scanner/inc/css/styles.css?ver=3db36a9 net::ERR_CERT_COMMON_NAME_INVALID

 

Note a wordpress plugin for the website is trying to call http://3.222.27.169 instead of https://kevwells.com

 

-why??

 

probably because the site definitions are for the IP address in the wordpress database for the site, instead of for the domain name.

 

Lets check.

 

We go into mariadb sql server database for the wordpress website, using the mariadb CLI….

 

and check the definitions set there:

 

select the kevwells database, and check the table entry for home and siteurl:

 

root@ip-172-31-82-94:~# mysql -u root -p
Enter password: * * * * * * (not displayed here)

 

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 70292
Server version: 10.6.12-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04

 

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

 

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]>

 

MariaDB [kevwells]> show databases ;

+——————–+
| Database |
+——————–+
| information_schema |
| kevwells |
| mysql |
| performance_schema |
| phpmyadmin |
| sys |
| wordpress |
+——————–+
7 rows in set (0.000 sec)

 

MariaDB [kevwells]> use kevwells;
Database changed

 

and what do we find when we check the definitions for home and siteurl in the wp_options table:

 

MariaDB [kevwells]> SELECT * from wp_options WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
+———–+————-+———————-+———-+
| option_id | option_name | option_value | autoload |
+———–+————-+———————-+———-+
| 33 | home | http://3.222.27.169 | yes |
| 1 | siteurl | http://3.222.27.169/ | yes |
+———–+————-+———————-+———-+
2 rows in set (0.000 sec)

MariaDB [kevwells]>

 

This is the cause of the problem: the http://3.222.27.169 entries for home and siteurl

 

so, these definitions need to be set to https://kevwells.com for each

 

UPDATE wp_options SET option_value = http://www.example.com/blog WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

 

UPDATE wp_options SET option_value = https://kevwells.com WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

 

MariaDB [kevwells]> UPDATE wp_options SET option_value = https://kevwells.com WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘://kevwells.com WHERE option_name = ‘home’ OR option_name = ‘siteurl” at line 1
MariaDB [kevwells]>

 

slight problem with mariadb vs mysqldb… we have to use different inverted commas for part of the command:

 

you have to use ” ” :

 

So it needs to look like this:

 

UPDATE wp_options SET option_value = “https://kevwells.com” WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

 

MariaDB [kevwells]> UPDATE wp_options SET option_value = “https://kevwells.com” WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
Query OK, 2 rows affected (0.001 sec)
Rows matched: 2 Changed: 2 Warnings: 0

 

MariaDB [kevwells]>

 

now its set correctly.

 

finally, verify the change:

 

SELECT * from wp_options WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

 

MariaDB [kevwells]> SELECT * from wp_options WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

+———–+————-+———————-+———-+
| option_id | option_name | option_value | autoload |
+———–+————-+———————-+———-+
| 33 | home | https://kevwells.com | yes |
| 1 | siteurl | https://kevwells.com | yes |
+———–+————-+———————-+———-+
2 rows in set (0.000 sec)

MariaDB [kevwells]>

 

all ok.

 

MariaDB [kevwells]> quit
Bye
root@ip-172-31-82-94:~#

 

The site is now displaying correctly.

Continue Reading

How To Create an HTML Flatfile Instance of a Website

To create an html flatfile replica of the WordPress website http://kevwells.com the challenge was to get the output from the php content files as html.

 

 

This problem was resolved in the following way:

 

 

Launch an instance of the php webserver process on port 8080

 

 

NOTE this has to be executed from the top of the website document folder tree ie in /var/www/html: 

 

 

root@gemini:/var/www/html# php -S kevwells.com:8080
[Thu Jan 6 22:36:44 2022] PHP 7.4.3 Development Server (http://kevwells.com:8080) started

 

 

 

Then in another terminal window execute the wget command:

 

 

wget -r –mirror –page-requisites –convert-links -U mozilla -F http://kevwells.com:8080

 

 

NOTE: We do not use the “span hosts” wget option  – else this will download all the external sites that are linked as well.

 

this then generates and downloads a static html flatfile instance of the website.

 

this can then be accessed from a web-browser by using the URL file:///<filesystem location of the wget output>

 

 

eg

 

 

file:///home/kevin/DATA/KEVWELLS.COM/kevwells.com_FlatHTMLfiles/kevwells.com/

 

The location folder must be made available first in NFS for clients to connect to.

 

Alternatively the html folder tree for the downloaded site can be  copied to any other machine and accessed locally from there.

 

This displays a file system based instance of the downloaded website.

 

 

 

 

 

 

 

 

this method downloads the website as flat html files, you access the site instance via the file:/// reference in the browser URL field.

in other words, it does not convert the internal website links to pages and posts into localhost referenced links.

but it means you do have a local instance of the site containing all the content as flat html files.

Continue Reading

How To Replicate A WordPress Website From Server To Localhost

Replicating Website from http://kevwells.com to http://localhost on laptop.

 

First install Apache, MySQL/MariaDB and PHP on laptop.

 

Then create a database with the same name and connection/login credentials as on the kevwells.com server.

 

 

Next, install the WordPress Duplicator Plugin on kevwells.com on the server. We are using the Duplicator Lite (free version) not the paid for pro-version.

 

This has one drawback: the links within the website to https:/kevwells.com cannot be changed using Duplicator, so we have to use other means to do this.

 

A further problem (not Duplicator related) is the use of https SSL/TLS on the kevwells.com server, while the localhost on the laptop uses http (http://localhost).

 

 

 

We were not able to convert the localhost instance to http.

 

 

This meant that when calling up http:/localhost in the web-browser, the link would automatically default to https and connect to the https:/kevwells.com external public url. This also meant we could not access the WordPress admin account on the localhost.

 

The only way around this problem was to temporarily change the configuration of kevwells.com from https to http, then perform the Duplicator export.

 

 

We would then be exporting http://kevwells.com to http:/localhost and not https:/kevwells.com.

 

 

This was possible.

 

 

This is done by modifying the sites-enabled file /etc/apache2/sites-enabled/kevwells.com.conf on the kevwells.com server:

 

the lines with double hash sign ie ## have been temporarily commented out for this purpose:

root@gemini:/etc/apache2/sites-enabled# cat kevwells.com.conf

 

<IfModule mod_ssl.c>
##<VirtualHost *:444>

 

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request’s Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.

 

ServerName kevwells.com

 

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, …, trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

 

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

 

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with “a2disconf”.
#Include conf-available/serve-cgi-bin.conf

 

##Include /etc/letsencrypt/options-ssl-apache.conf

 

ServerAlias www.kevwells.com

 

SSLCertificateFile /etc/letsencrypt/live/kevwells.com/fullchain.pem
##SSLCertificateKeyFile /etc/letsencrypt/live/kevwells.com/privkey.pem

 

</VirtualHost>
##</IfModule>

 

Then execute:

 

a2dissite kevwells.com.conf
systemctl reload apache2

 

and

 

a2ensite kevwells.com.conf
systemctl reload apache2

 

The site should now be operating in http mode instead of html.

 

After exporting the site using Duplicator, return the config to the original state and perform the a2dissite and a2ensite steps again. https service will then be restored.

 

 

The export file was 2.4GB in size. There is also an installer.php provided by the plugin specifically for this export file. You manually copy these two files to the laptop destination machine.

 

From there, these two files are moved to the root document folder of the website on the localhost, in this case /var/www/html.

 

The installer.php from Duplicator is then executed from a webbrowser:

 

http://localhost/installer.php

 

Then follow the instructions from Duplicator installer.php in the browser display.

 

The process takes several minutes.

 

 

We then still had a problem with the links. Entering http://localhost would only display the home page of the site. All other pages were not accessible.

 

Further configuration was necessary.

 

In phpmyadmin we changed the kevwells database table wp_options entries for siteurl and blogname from http://kevwells.com and kevwells.com to http://localhost and localhost respectively.

 

We then added

 

define(‘WP_HOME’,’http://localhost’);
define(‘WP_SITEURL’,’http://localhost’);

 

 

 

to wp-config.php

 

this file also has to contain the definitions for the database connections:

 

// ** MySQL settings – You can get this info from your web host ** //

/** The name of the database for WordPress */

define( ‘DB_NAME’, “kevwells” );

/** MySQL database username */

define( ‘DB_USER’, “wordpressuser” );

/** MySQL database password */

define( ‘DB_PASSWORD’, “*****” );

/* password is commented out here for security reasons */

/** MySQL hostname */

define( ‘DB_HOST’, “localhost” );

 

 

the .htaccess file is empty:

 

kevin@asus:/var/www/html$ cat .htaccess
# BEGIN WordPress
# The directives (lines) between “BEGIN WordPress” and “END WordPress” are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.

# END WordPresskevin@asus:/var/www/html$

 

 

We then installed a further WordPress plugin: Go Live Update Urls

 

this is to change the Url site references within the website from http://kevwells.com to http://localhost

 

However the content would still not display, although we could open the WordPress Admin for localhost successfully.

 

The solution was to execute the Permalinks settings in WordPress Admin, changing them from custom to plain, saving the settings.

 

The website then displayed correctly.

 

The only part of the content which gives a not found error are the pages (eg terms and conditions, disclaimer etc), posts are ok.

 

We now have a static replica of the http://kevwells.com instance running on the laptop as http://localhost

 

Continue Reading

How To Backup Your Website

backup_by_brian_j_matisIt’s vital to backup your website regularly.

Servers fail, websites get hacked.

So here’s a quick guide to how to backup your website.

How To Backup Your Website

There’s a kind of unspoken law about backups.

If you backup, you probably won’t need the backups. But if you don’t – you sure as anything will!

You’ll be investing hundreds, possibly thousands of man hours in creating and maintaining your site.

When disaster strikes and you have no backup available, then you have a double disaster on your hands.

Fortunately for WordPress users it’s not difficult to back up your site.

Once you’ve configured the backup routines you only need to spend a few minutes each week on maintaining the backups.

There are a number of different ways of backing up your website.

Make Sure Your Web-Hosting  Provider Backs Up Your Server Regularly

The first thing I recommend you do is to arrange with your web hosting provider to perform automatic backup of your web space.

Your hosting provider may do this for free – or it may cost a few extra dollars or so each month. But even if you have to pay for the service, it will be money well spent.

However, this doesn’t help you if your web-hosting provider suffers a catastrophic data loss at their site. So you need to have a system in place to create regular offsite backups as well.

There are a number of backup solutions that integrate with WordPress. Some are paid-for solutions and others are available for free.

None of the free versions are 100 percent perfect, but there are two pretty good free solutions I recommend.

These are the DB-Backup Plugin and the Time Machine Plugin.

Install the WordPress DB-Backup Plugin

The default way of backing up a WordPress site is to use the DB-Backup Plugin. This is very easy to get up and running and it provides for regular automated offsite backups of your website.

The problem with DB-Backup is it only backs up the the MySQL database of your site.

Although the MySQL database contains your site’s posts and pages, it doesn’t hold your WordPress theme and all the other plugins and structural configuration information that you have spent a lot of time and effort on installing.

These extra but vital items for your site will need to be backed up – onsite – by your web hosting provider’s automatic backup routine.

You can download DB-Backup free from:

breakfreerebel.org/extend/plugins/wp-db-backup

Installation is simple. Full instructions can be found at the above link.

Create an Initial Manual Backup of Your Site With DB-Backup

Once you’ve installed DB-Backup, you can access it via the WordPress Dashboard under Tools -> Backup.

I recommend you first create a manual backup straightaway using WP-DB-Backup.

There are three options for this:

  • save the backup on your server;
  • download straight to your PC; or
  • send it to a designated email account

The backup routine runs very quickly (for a small site a minute or so). Don’t close the browser during the operation or the backup will be interrupted.

Schedule Your Backups To Run Automatically

The most useful and time saving feature of WP-DB-Backup is its ability to backup your site automatically at regular intervals.

How often should you backup?

This depends on how often your site content changes.

If you have a completely static site which never changes, then a one-off backup will be enough. In this case you don’t need to bother with configuring a backup schedule.

However, most websites – especially blogs, have dynamic content which is modified or added to regularly. How often the content of your site changes will determine how often you should backup.

How to configure DB-Backup

Choose the schedule in DB-Backup that best suits your site’s content publishing level.

Next scroll up the page back to the Backup Options box and determine what should be done with the backup.

Once again, DB-Backup gives you three options:

  • save the backup on your server;
  • download straight to your PC; or
  • mail it to a designated email account

Note that you can only choose ONE option for this.

In addition to DB-Backup, you should arrange some backups to a third-party location.

Maintain Offsite Backups 

I recommend you configure DB-Backup to download the backup to your PC or to an email account that is NOT on your web hosting server.

This is because if you save the backup on your server, then all your backups are located on the same machine as your website.

This is not a good idea.

If disaster strikes at the file system, operating system or hardware level, then not only your website, but also your backup will be lost.

Remember the first golden rule of backups:

The First Golden Rule of Backups: Never Put All Your Eggs in One Basket

I suggest sending your backup to a specially created email account.  This ensures you always have an OFFSITE backup.

DON’T use an email account on your server or website – this would defeat the whole point of the backup. It needs to be on a separate account at a separate location.  You can use one of the free popular web mail providers such as Hotmail, Yahoo or Gmail.

You can then also download your backups to your PC and to a cloud storage provider, for example once a week or once a month.

Open a Free Account With Dropbox

Dropbox is an online cloud storage service.  You can use it to backup files from your PC and from your website.  Dropbox integrates into your filesystem on your PC, so you can easily add files by point and click in your File Explorer.

Dropbox is free for the first 2GB, so take advantage of this and grab yourself a free account straightaway if you haven’t already done so.

Maintain multiple backup copies on different media

I also like to have a backup of my sites on my own PC as well as a copy on a USB stick. But guard them carefully. Because of their small size they can easily get mislaid.

I also keep a copy on an external USB hard drive.

Dropbox are at www.dropbox.com

Install WP Time Machine Plugin

There’s also a plugin called Time Machine which backs up your site and sends it to your Dropbox account.

The great thing about this method is that, like DB Backup, it’s automatic and enables you to save the data to a file system – in this case, Dropbox. You can then access the backup directly from your PC or laptop’s own file system, as well as via a web browser from anywhere else.

Also, once you have it up and running, the backup procedure takes care of itself.

How To Download & Install WP Time Machine

You can get the WP Time Machine plugin from the WordPress.org website at  breakfreerebel.org/extend/plugins/wp-time-machine/

Install WP time Machine on your site via the your site’s WordPress Dashboard plugin installation section. Next you need to click on “enable” to activate the plugin.

How To Configure WP Time Machine

Click on Settings -> WP Time Machine.  Next click “Show Plugin Options” and select Dropbox as the current offsite service.  Enter your Dropbox email and Dropbox password details.

You can specify a directory where your backups are to be saved. The default is the root folder. Make sure you don’t select “public” because this is readable to everyone and you definitely don’t want that.

Make sure you enter the correct email address that your Dropbox account is registered with.

After you have entered your Dropbox password, make sure you click on “Save your password”. Otherwise your password won’t be saved in the Time Machine configuration and this will mean your backup won’t run.

Create an Initial Archive With WP Time Machine

To do this click on “Generate WP Time Machine Archive”.  A folder should appear with some files inside in your Dropbox area on your computer.

If the folder does not appear then check that you have entered your Dropbox account details correctly.

Set The Automated Backup Routine For WP Time Machine

This step is a little more complex. At present this has to be done by using a Linux Shell command (operating system command) called “curl” which is run on your webserver at the Linux or Unix system level.

If you aren’t familiar with Linux or Unix then the easiest thing to do is to ask your web hosting provider to take care of this for you. Most hosting providers will perform this task for you without any problems.

Just send them a mail or contact them via their online help desk and tell them that you want to use the WordPress Time Machine Plugin to carry out automated backups of your site to Dropbox. Explain that to do this you need them to enter a specified “curl command” into the crontab system of your web server.

You can send them the command by email so they will know what needs to be entered.

This is the curl command that your web hosting provider will need to enter into your crontab file:

curl “http://mysitename.com/wp-content/plugins/wp-time-machine/cron.php?generate=1″

Your own site name will need to be substituted in the command in place of “mysitename.com”

You’ll also need to tell them when you want the backup to run – what days of the week and at what time.

For example, you can specifiy the backup to run once a week. Or, if you publish to your site more regularly, then daily may be better. It’s better to choose a quieter time eg the early hours of the morning, for the backup to run.

If you are familiar with Linux/Unix, then here are the instructions:

The “curl” command has to be entered into your web server’s crontab file. This will usually be accessible via your web server hosting user panel.

You need to enter the command into the crontab section and specify when it is to run (usually this is done via clicking on radio buttons or entering times and days or selecting them from a set of drop-down field).

Decide how often you want your Time Machine backup to run and enter the times and days accordingly in the crontab section.

The curl command line you need to enter into your crontab section needs to look like this:

curl “http://mysitename.com/wp-content/plugins/wp-time-machine/cron.php?generate=1″

Enter the command as above, but substitute the exact name of your own site in place of “mysitename.com”.

And with that you should have an automated backup system in place for your website that will generate regular backups without any manual intervention by you.

The above might sound like overkill.

Believe me, it’s not. Where backups are concerned you should always observe the Second Golden Rule.

The Second Golden Rule of Backups: Take nothing for granted

Even backups themselves can and do fail.

Backup servers, hard drives, USB sticks, DVDs, can all develop sudden read/write problems or even fail completely.

That’s why you need to have more than one type of backup in place. Then if one backup fails, you always have another one available.

Keep a Backup of Your Site In The Cloud

I strongly recommend that you utilize a cloud-based backup service for your backups.

Dropbox is ok as a temporary holding place for your backup. But Dropbox shouldn’t be regarded as a secure archive for backups.  You need a more secure cloud backup for this.

There are other options available which you should consider, such as Amazon S3, or the free Symform.

The latter gives you 10GB of data free of charge.

The great thing about Symform is that it is a distributed storage system. All data is automatically encrypted and distributed according to a fail-safe RAID-style algorithm and stored on participants machines.

As the data is encrypted, only you can access it. And if one or more of the machines fail or are unreachable, the distributed storage algorithm used by Symform ensures that your data is still intact and fully retrievable.

Check out Symform at www.symform.com

Use ManageWP To Automate Your Cloud Backups

There’s also a great WordPress Dashboard system available called ManageWP which enables you to easily manage and automate your cloud backups.

ManageWP is also really useful if you operate more than one site. With ManageWP you can operate all your WordPress websites from one single Dashboard.

You can manage, monitor, and optimize your sites, as well as configure your backups – all from the one Dashboard. This saves you a great deal of time and admin overhead.

ManageWP is a paid-for product which is well worth the investment.

Check out ManageWP at managewp.com

Getting backup procedures in place initially involves a bit of grunt work with little visible reward.

But when your website or web server suddenly suffers a disaster you’ll be glad you made the effort earlier on. Your site is valuable intellectual property and investment and you can’t afford not to back it up.

So take a little time whilst the waters are calm to get these automated backup procedures in place ready for when a storm brews up.

When disaster suddenly strikes you’ll be glad you did.

Image Attribution – backup – Courtesy of Brian J. Matis

Continue Reading