Top Nav

Regenerate WP-Rocket .htaccess From Command Line

To regenerate the .htaccess file with WP-Rocket rules from the command line do the following:

  • Install wp-rocket extension for wp-cli:

  • Regenerate the .htaccess file:

There are additional useful commands on the rocket extension. See https://github.com/GeekPress/wp-rocket-cli for details.

 

 

 

0

MySQL – Run Command On All Tables

Here’s a one-liner to run a SQL command on all tables in a database:

  • Replace “show create table” with the command that you wish to execute.
  • Replace “mydb” with your database name.
  • Replace “root” and “mypassword” with you username and password.
  • Replace “localhost” with your database server hostname or IP address.

 

0

Magento 2 – Add Admin From Command Line

To add an admin user to a Magento 2 site from the command line, SSH to the server and change to the root directory of the Magento 2 install. Then run this command:

On a server with Plesk a few notes:

  • It’s best to run this command as the user that owns the website subscription.
  • You may need to set the path to the correct PHP version with “export PATH=/opt/plesk/php/7.0/bin/php:$PATH”.
  • If you get “PHP Fatal error: Allowed memory size of xxxxxxx bytes exhausted” then edit the php.ini file for the correct PHP version and increase the “memory_limit” setting.

 

0

WordPress Admin Dashboard Slow Due To WordFence

Recently worked a WordPress site where the admin dashboard was taking a minute or more to load. Tracked the problem to the “Updates Needed” section in the “WordFence” block displayed on the dashboard. The Updates Needed section calls the WordPress  “wp_version_check()” function. This function, as part of building the data sent to wordpress.org with the update version check, calls the WordPress “count_users()” function. The “count_users()” function runs a query like this:

The number of “COUNT(NULLIF” columns depends on the number of user groups. For a site with a small number of users and groups this query is not a problem. But for a site with over 100K users this query took over 100 seconds to run.

To fix the problem, we used “wp-cli” to disable the “Updates Needed” section in WordFence:

Now the admin dashboard loads with no delay. This is a great example of the types of problems that come with scaling a WordPress site to large numbers of users.

 

 

 

0