• Skip to primary navigation
  • Skip to main content

Magda Sicknick

  • About me
  • Portfolio
  • Articles

May 2, 2024 by Leave a Comment

Update WordPress URL through phpMyAdmin

A quick and simple way to update your WordPress URL is through phpMyAdmin, and if you are somewhat code-savvy this should be a breeze.

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

April 24, 2019 by Leave a Comment

Add Certbot to shared GoDaddy hosting

Download and install acme.sh

acme.sh is a full implementation of a LetsEncrypt client but that doesn’t depend on Python/pip/virtualenv/etc, and that doesn’t require root — exactly what we need, since we don’t have root an a shared GoDaddy server, and we can’t install new software outside of our home directory.

curl https://get.acme.sh | sh

Now log out and SSH back in so acme.sh‘s install is complete in every way (include the Bash alias).

Get a GoDaddy API Key

  1. Visit https://developer.godaddy.com/keys/
  2. Generate a production key (it made me produce a test key first for some reason…)
  3. In the SSH session you have open run these commands, but with each ...replaced by the value GoDaddy gave you in the previous step:
export GD_Secret=…
export GD_Key=…

Run the below:

acme.sh –issue -d MYDOMAIN.com -d www.MYDOMAIN.com -w ~/www –dns dns_gd

(NOTE: If you’re creating this cert for a domain that’s not the default domain being hosted on this server, then instead of ~/www you’ll need to do something like ~/www/MYOTHERDOMAIN.COM.)

Boom! You should have just gotten your first good news of the day — your cert, cert key, intermediate CA cert, and full cert chain have been generated!

…but GoDaddy still doesn’t know that the cert exists, so it’s not using it.

Upload cert and private key to GoDaddy via acme.sh –deploy

  1. Use nano to open ~/.acme.sh/deploy/cpanel_uapi.sh, uncomment the DEPLOY_CPANEL_USER variable at the top, set its value to your username
  2. Run acme.sh --deploy -d MYDOMAIN.com --deploy-hook cpanel_uapi

After ~30 seconds, you should see output like this!

[Sun Sep 17 03:17:45 MST 2017] Certificate successfully deployed
[Sun Sep 17 03:17:45 MST 2017] Success

Once complete, edit the cronjob file with

EDITOR=nano VISUAL=nano crontab -e

and replace MYDOMAIN.com and the other domains with your own domains:

0 0 1 * * ~/.acme.sh/acme.sh –cron –home ~/.acme.sh –force 2>&1 >> ~/.acme.sh/cronlog.txt
1 0 1 * * ~/.acme.sh/acme.sh –deploy -d MYDOMAIN.com –deploy-hook cpanel_uapi
2 0 1 * * ~/.acme.sh/acme.sh –deploy -d SOMEOTHERDOMAIN.org –deploy-hook cpanel_uapi
3 0 1 * * ~/.acme.sh/acme.sh –deploy -d THIRDDOMAIN.com –deploy-hook cpanel_uapi

Hit CTRL+X, type ‘Y’, and ENTER to save.

Tadaa, you now have a fully automated LetsEncrypt certificate on your site(s)!

April 24, 2019 by Leave a Comment

Update WordPress domain in phpMyAdmin

Run the below commands in your phpMyAdmin.

Remember, if you have a different table alias, to adjust it accordingly.

UPDATE wp_options SET option_value = replace(option_value, ‘oldurl.com’, ‘newurl.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
UPDATE wp_posts SET guid = replace(guid, ‘oldurl.com’,’newurl.com’);
UPDATE wp_posts SET post_content = replace(post_content, ‘oldurl.com’, ‘newurl.com’);
UPDATE wp_postmeta SET meta_value = replace(meta_value,’oldurl.com’,’newurl.com’);

February 18, 2019 by Leave a Comment

Useful Linux commands

Copy contents of a directory to a new path

  • sudo cp -a /path/to/dir/. /path/to/new_dir

Remove directory and all its contents

  • sudo rm -R /path/to/dir

Apache commands

  • sudo service apache2 restart
  • sudo service apache2 reload
  • sudo service apache2 stop
  • sudo service apache2 start

Assign ownership and change permissions

  • sudo chown -R user_name:group_name /path/tp/dir
  • sudo chmod -R 775 /path/to/dir

Permissions are set by three numbers using the chmod command. The three numbers correspond to: Owner, Group, and Others.

Every file and folder contain a 8-bit data that control the permissions. At its basic binary form, it will be “000”, which means no permissions of any form is granted. When you set a “Read” permission, it will add 4-bit to the data, making it “100” (in binary format) or a “4” in the usual decimal format. Setting a “Write” permission will add 2-bit to the data, making it “010” and “2” in decimal form. Lastly, setting an “Execute” permission adds 1-bit to the data, which will result in “001”, or “1” in decimal form. In short:

  • Read is equivalent to 4
  • Write is equivalent to 2
  • Execute is equivalent to 1

When we want to set permissions, we just add up the number. For example, to set the permissions to read and write, we will use 6 (4 + 2) for the permission. For read, write and execute, we will use 7 (4 + 2 + 1) for the permission. Here’s the different permutation:

  • 0 – no permission
  • 1 – execute
  • 2 – write
  • 3 – write and execute
  • 4 – read
  • 5 – read and execute
  • 6 – read and write
  • 7 – read, write, and execute

Assign permissions to all files or folders in a directory

To assign permissions to all folders in a directory:

  • sudo find path/to/directory -type d -exec chmod 755 {} \;

To assign permissions to all files in a directory:

  • sudo find path/to/directory -type f -exec chmod 644 {} \;

February 1, 2019 by Leave a Comment

How To Add Swap on Ubuntu 16.04

One of the easiest way of increasing the responsiveness of your server and guarding against out of memory errors in your applications is to add some swap space. Swap is an area on a hard drive that has been designated as a place where the operating system can temporarily store data that it can no longer hold in RAM.

Basically, this gives you the ability to increase the amount of information that your server can keep in its working “memory”, with some caveats. The space on the hard drive will be used mainly when space in RAM is no longer sufficient for data.

The information written to disk will be slower than information kept in RAM, but the operating system will prefer to keep running application data in memory and use swap for the older data. Overall, having swap space as a fall back for when your system’s RAM is depleted is a good safety net.

Check your System for Swap Information

Before we add a swap file to our system, we want to make sure we do not already have one. Run the following command, and if you get back no results, you are in the clear:

  • sudo swapon -s

Check Available Space on the Hard Drive Partition

You have to make sure you have available space on your hard drive before you begin creating your swap file.

  • df -h

It should return information similar to:

Filesystem Size Used Avail Use% Mounted on
udev 481M 0 481M 0% /dev
tmpfs 99M 476K 98M 1% /run
/dev/xvda1 39G 9.4G 30G 25% /
tmpfs 492M 0 492M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 492M 0 492M 0% /sys/fs/cgroup
tmpfs 99M 0 99M 0% /run/user/1000

In the above example, there are 30GB of available memory – so we can allocate 4GB for our swap file without running into any issues.

Create a Swap File

We are going to use the command, which creates a file of a pre-allocated size instantly. Run the following command, and you should see the prompt be returned to you instantly:

  • sudo fallocate -l 4G /swapfile

You should then verify that the file was created correctly, by running

  • ls -lh /swapfile

And you should then see information about the file you created:

-rw-r–r– 1 root root 4.0G Feb 1 15:13 /swapfile

Enable the Swap File

Above commands have created your swap file, but you must now tell your system to use it. This can be accomplished by only a few commands, but first you must lock the file’s permissions:

  • sudo chmod 600 /swapfile

You can then run

  • ls -lh /swapfile

And you will see that your file’s permissions have now been updated:

-rw——- 1 root root 4.0G Feb 1 15:13 /swapfile

We can now proceed with setting up swap space by running the following:

  • sudo mkswap /swapfile
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=e2f1e9cf-c0a9-4ed4-b8ab-714b8a7d6944

The file is now ready to be used as swap space, which we can enable with:

  • sudo swapon /swapfile

And verify by running:

  • sudo swapon -s

Make the Swap File Permanent

The swap file has now been created and enabled. However, when the server restarts, it will not know to enable it on its own. This can be changed by modifying the fstab file:

  • sudo nano /etc/fstab

At the bottom of the file, add the following line and save:

/swapfile none swap sw 0 0

You should now have a working swap file on your system. You can confirm this by running the free command:

  • free -m
total used free shared buff/cache available
Mem: 983 172 352 45 458 625
Swap: 4095 223 3872

January 31, 2019 by Leave a Comment

MySql crash due to lack of memory for buffer pool

I just suddenly ran into a big issue of MySQL crashing every couple of minutes on my Lightsail Linux instance.

A quick look at the log (found in /var/log/mysql/error.log revealed:

2019-01-31T16:20:05.368890Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.25-0ubuntu0.18.04.2) starting as process 2084 …
2019-01-31T16:20:05.372726Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-01-31T16:20:05.372745Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-01-31T16:20:05.372760Z 0 [Note] InnoDB: Uses event mutexes
2019-01-31T16:20:05.372764Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-01-31T16:20:05.372767Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-01-31T16:20:05.372771Z 0 [Note] InnoDB: Using Linux native AIO
2019-01-31T16:20:05.372995Z 0 [Note] InnoDB: Number of pools: 1
2019-01-31T16:20:05.373094Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-01-31T16:20:05.375782Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-01-31T16:20:05.375813Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2019-01-31T16:20:05.375820Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2019-01-31T16:20:05.375825Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-01-31T16:20:05.375830Z 0 [ERROR] Plugin ‘InnoDB’ init function returned error.
2019-01-31T16:20:05.375834Z 0 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed.
2019-01-31T16:20:05.375837Z 0 [ERROR] Failed to initialize builtin plugins.
2019-01-31T16:20:05.375840Z 0 [ERROR] Aborting

The error basically states that InnoDB is tryign to use 128M of memory, and it is unable to get the memory it needs. So a solution to this is to lower the memory used by InnoDB and hope that the issue resolves itself.

Locate and the /etc/mysql/mysql.conf.d/mysqld.cnf file using one of the following commands:

  • sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

OR

  • sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

Scroll to the bottom of the file and find the # * InnoDB heading.
Paste the following line – or if it already exists: change it’s value.

innodb_buffer_pool_size = 64M

Save, and exit the editor.

Now, for this change to take effect, you must restart MySQL with the following:

  • sudo /etc/init.d/mysql restart

Make sure you monitor the system to make sure that this has fixed your issue – and check your error log periodically!

If that did not resolve your issue…

There can be a couple of other reasons as to why your InnoDB keeps crashing:

Not enough memory on your server.

It is possible that the reason your system is crashing is due to lack of RAM. To check how much RAM your system is using, run the following command:

  • top

Here, you will be able to see how much memory your system is using. If you see a fairly low number under KiB Mem free, you might want to consider upgrading your system.

Creating a swap file might also solve this issue. Learn how to do that here.

MySQL has a pending update, or your update was not installed correctly.

Run the following command to check if your MySQL server needs an update:

  • sudo mysql_upgrade -u root -p

Enter your root user MySQL password when prompted.

The system will prompt you if you need to install any updates.

If you see a message stating that your system is up to date, we will force an update just to make sure everything is correct:

  • sudo mysql_upgrade –force -u root -p

Enter your password again.

Your server needs an update

Run the following commands to get all the latest package updates for your server:

  • sudo apt-get update
  • sudo apt-get upgrade
  • Page 1
  • Page 2
  • Page 3
  • Go to Next Page »

Let’s Talk

Looking to get your business a website or update your current online presence?

Please send me information about you project so that I can determine how to best fulfill your needs.

    Service Required *

    Copyright© 2025 · Magda Sicknick · All Rights Reserved · Powered by Wordpress and the Genesis Framework.