Category Archives: Wordpress

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

This new server with Ubuntu 16.04 LTS cames with PHP 7.0.

The backup that I have from my client has some old WordPress blogs…

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

I need to downgrade PHP 7.0 to PHP 5.6, at least for now.

Before you procede with the tutorial on the following link, and if you are running a new Ubuntu 16 installation you might get upon the following error while following the tutorial.

[email protected]:/home/httpd/html# sudo add-apt-repository ppa:ondrej/php
sudo: add-apt-repository: command not found

To install add-apt-repository you will need to run the following command

sudo apt-get install software-properties-common

Now the solution  How can I downgrade from PHP 7 to PHP 5.6 on Ubuntu 16.04? [duplicate].

 

Export & Import WordPress

I regularly work with WordPress… sometimes I install the working version on one of my servers and then move to the client’s server. Most of the times is a PAIN in the ass work…

I used to dump the mysql database, search and replace the older domain/subdomain for the new one and then import the database on the new server bla bla bla.

Users passwords stop working, themes and plugins sh*ts disappeared….

Yesterday I’v found a plugin who exports the DB PERFECTLY!

WP Migrate DB
https://wordpress.org/plugins/wp-migrate-db/

wp-migrate-db_reviews

woocommerce – my-account/lost-password/

On a new woocommerce store, the “Forget password” password was sending me to http://www.domain.com/my-account/lost-password/

In the funcions.php of the current theme that I’m using, I add the following lines…

function reset_pass_url() {
    $siteURL = get_option('siteurl');
    return "{$siteURL}/wp-login.php?action=lostpassword";
}
add_filter( 'lostpassword_url',  'reset_pass_url', 11, 0 );

 

For a deep reading and correct resolution
https://support.woothemes.com/hc/en-us/community/posts/201543505-Lost-Password-Endpoint-Shortcode-Not-Working

WordPress, delete duplicate entries

I run some wordpress blogs and their posts are generated with a tool that I’v made.
Unfortunately for several reasons I got duplicated titles/posts.

1465 duplicate titles (3274 individual entries)
 I’v tried some plugins to delete this duplicated posts – keep the older ones – but the one that really worked was Fix Duplicates – Duplicate Entries.

Pingdom Full Page Test, tweaking the result

Results of a WordPress without ZenCache

Google Chrome 57

Load time/waterfall of index.php
Google Chrome 56

After install ZenCache WordPress Plugin

Google Chrome 58

Load time/waterfall of index.php
Google Chrome 54

ZenChache results
<!-- ZenCache file path: /cache/zencache/cache/http/www-domain-com/index.html -->
<!-- ZenCache file built for (http://www.domain.com/) in 7.51658 seconds, on: May 29th, 2015 @ 4:00 pm UTC. -->
<!-- This ZenCache file will auto-expire (and be rebuilt) on: Jun 5th, 2015 @ 4:00 pm UTC (based on your configured expiration time). -->
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- ZenCache fully functional :-) Cache file served for (http://www.domain.com/) in 0.00275 seconds, on: May 29th, 2015 @ 4:06 pm UTC. -->

google pagespeed / gtmetrix – how to improve results

gtmetrix - results

Check if we have enabled mod_headers.c and mod_expires.c

First we need to check if we have enabled mod_headers.c and mod_expires.c.

sudo apache2 -l

If we don’t have it, we need to enable then

sudo a2enmod headers

Then we need to restart apache

sudo apache2 restart
Leverage browsers caching

By adding the following lines on .htaccess Leverage Browsers Caching has simply disappeared! I got the solution from http://stackoverflow.com/questions/6878427/leverage-browser-caching-how-on-apache-or-htaccess

ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/css A86400
ExpiresByType text/javascript A86400
ExpiresByType application/x-shockwave-flash A2592000
#
<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf)$">
Header set Cache-Control "public"
</FilesMatch>

It went from a global score of 53% to 72%.
And F(1) to A(98).

Enable gzip compression
<IfModule mod_deflate.c>
 AddOutputFilterByType DEFLATE application/javascript
 AddOutputFilterByType DEFLATE application/rss+xml
 AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
 AddOutputFilterByType DEFLATE application/x-font
 AddOutputFilterByType DEFLATE application/x-font-opentype
 AddOutputFilterByType DEFLATE application/x-font-otf
 AddOutputFilterByType DEFLATE application/x-font-truetype
 AddOutputFilterByType DEFLATE application/x-font-ttf
 AddOutputFilterByType DEFLATE application/x-javascript
 AddOutputFilterByType DEFLATE application/xhtml+xml
 AddOutputFilterByType DEFLATE application/xml
 AddOutputFilterByType DEFLATE font/opentype
 AddOutputFilterByType DEFLATE font/otf
 AddOutputFilterByType DEFLATE font/ttf
 AddOutputFilterByType DEFLATE image/svg+xml
 AddOutputFilterByType DEFLATE image/x-icon
 AddOutputFilterByType DEFLATE text/css
 AddOutputFilterByType DEFLATE text/html
 AddOutputFilterByType DEFLATE text/javascript
 AddOutputFilterByType DEFLATE text/plain
 # Remove browser bugs (only needed for really old browsers)
 BrowserMatch ^Mozilla/4 gzip-only-text/html
 BrowserMatch ^Mozilla/4\.0[678] no-gzip
 BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 Header append Vary User-Agent
</IfModule>
<IfModule mod_gzip.c>
 mod_gzip_on Yes
 mod_gzip_dechunk Yes
 mod_gzip_item_include file .(html?|txt|css|js?|php|pl)$
 mod_gzip_item_include handler ^cgi-script$
 mod_gzip_item_include mime ^text/.*
 mod_gzip_item_include mime ^application/x-javascript.*
 mod_gzip_item_exclude mime ^image/.*
 mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
Defer parsing of JavaScript

To solve this issue I’v installed Asynchronous Javascript WordPress plugin.
It went from a score of F (19) to B (85).

 

 

Google Chrome 53

 

I strongly recommend to install Google PageSpeed module.
Small tutorial https://www.digitalocean.com/community/tutorials/how-to-get-started-with-mod_pagespeed-with-apache-on-an-ubuntu-and-debian-cloud-server