IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

How to Setup WordPress Installation on Linux

  1. Create a directory for the new website (e.g., website1.com):

    mkdir website1
    
  2. Check the owner of the directory, if it’s set to root, you might want to change it to your username or at least www-data. To change the owner from root to myusername, type the following:

    sudo chown -hR myusername:myusername /var/www/html/website1
    
  3. Go to website1 directory.

    cd /var/www/html/website1
    
  4. Download wordpress.

    wget https://wordpress.org/latest.tar.gz
    

    or you can target a specific version. For example in this case, the latest version is 6.9.1, then you can download by specific version by typing:

    wget https://wordpress.org/wordpress-6.9.1.tar.gz
    
  5. Extract the file:

    tar -zxvf latest.tar.gz
    

    This will extract the files to a sub-directory wordpress with the full path /var/www/html/website1/wordpress.

You can then set up wordpress the same way as any other system.

Optional

If you do not want to have wordpress sub-directory, you can copy all files to the parent directory.

sudo cp -r /var/www/html/website1/wordpress/* /var/www/html/website1

We’re copying the content of wordpress directory and -r is to include all sub-directories (recursive).

Use copy instead of move so if you make mistake, you can redo.

After verifying all copied files, then you can delete the files from original directory:

sudo rm -r /var/www/html/website1/wordpress/*

Assumptions:

  • Web server is installed and the public html directory is in /var/www.

  • Basic knowledge of WordPress installation and configuration, which is not covered in this post.

February 24, 2026 Filed Under: How To, WordPress Tagged With: Linux, macOS

How to Fix PHP7 Compatibility Issue with W3 Total Cache

With the advent of PHP 7, a few webhosts such as SiteGround have made it available on all their shared hosting services and you can find a way to enable it here.

Before you jump the bandwagon though, be aware of the warning they posted on their website:

Please have in mind that even if you’re using an app that supports PHP 7 some of its components like plugins, themes, modules, etc. may have old code that will not work on the latest version. This is why we advise that you always test on a staging environment before you enable it on your live site.

You’ll run into a compatibility issue right away if you use one of the WordPress plugins, W3 Total Cache (W3TC). Right after upgrading to PHP 7, I saw this message on the bottom of every page of my WordPress blog:

Warning: Parameter 1 to W3_Plugin_TotalCache::ob_callback() expected to be a reference, value given in WP_PATH/wp-includes/functions.php on line 3297

Actually this error message is misleading, because the real issue is not in functions.php file on line 3297. Instead, you need to go to W3 Total Cache directory within your WordPress installation under wp-content folder and look for a file called TotalCache.php.

The whole path would be:
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\TotalCache.php

Look for line 512 (highlighted):

    /**
     * Output buffering callback
     *
     * @param string $buffer
     * @return string
     */
    function ob_callback(&$buffer) {
        global $wpdb;

Remove the ampersand “&” from the code as the following:

    function ob_callback($buffer) {
        global $wpdb;

Here’s the before and after comparison:
W3 TotalCache.php modification for PHP7 compatibility

Once you’re done changing the code, just clear all the caching and reload your page. This time the error message should disappear.

Update for PHP 7.0.9

With the release of PHP 7.0.9, some people have already encountered more issues with this W3 Total Cache plugin after upgrading.

Typical error messages:

Warning: Parameter 1 to W3_Plugin_Minify::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_Plugin_Cdn::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_PgCache::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_Plugin_Minify::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_Plugin_Cdn::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_PgCache::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_Plugin_Minify::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_Plugin_Cdn::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23
Warning: Parameter 1 to W3_PgCache::ob_callback() expected to be a reference, value given in /wp-content/plugins/w3-total-cache/inc/functions/plugin.php on line 23

Fortunately someone from WordPress forum has already posted a good solution. I personally have not tested this, but at least others have had success implementing the fix.

Just to sum up, you basically need to change make the same code modification as above, but to more files.

If you use Git, you can easily find all these files by running this command:

$ git grep -e 'ob_callback(&$buffer)' -n

W3 Total Cache ob_callback

And it should list all the filenames you need to update.

WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\PgCache.php
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\BrowserCache.php
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\Cdn.php
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\Minify.php
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\NewRelic.php
WP_PATH\wp-content\plugins\w3-total-cache\lib\W3\Plugin\TotalCache.php // *

* You will only see the last file if you haven’t fixed it from the earlier instruction above.

Update each file so that all occurrences of ob_callback(&$buffer) are replaced with ob_callback($buffer).

Finally, it’s worth repeating, backup before you do anything.

If you rather not deal with all these operations yourself, you may want to use some of the fixes and customization like this one (use at your own risk).

References

Modern PHP: New Features and Good Practices
Learning PHP 7: A Pain-Free Introduction to Building Interactive Web Sites
PHP for the Web: Visual QuickStart Guide (5th Edition)
Fixing Warning on HHVM
W3 Total Cache and PHP 7.0.9
Fix and customize W3 Total Cache

December 22, 2015 Filed Under: WordPress Tagged With: PHP

How to Add ID Attribute in Genesis Main Content

With the upgrade of Genesis Framework to responsive design, there’s a particular id attribute on the web content that’s deprecated when you use HTML5. If you take a look at /genesis/lib/framework.php file from Genesis core, you will see that the id="content" markup is still included in the XHTML markup. However for HTML5, the ID attritube is no longer there.

genesis_markup( array(
     'html5'   => '<main %s>',
     'xhtml'   => '<div id="content" class="hfeed">',
     'context' => 'content',
) );

This change creates a problem for some custom javascript to make Google AdSense responsive. The easiest thing to do is just to modify framework.php file to look like this:

genesis_markup( array(
     'html5'   => '<main id="content" %s>',
     'xhtml'   => '<div id="content" class="hfeed">',
     'context' => 'content',
) );

But obviously this is the worst thing to do because any future updates on Genesis core will overwrite that modification. So we want to make the change on the Genesis child theme instead.

Fortunately Genesis markup is very easy to modify. We just need to apply filter within the context of any section we want to change. In this case, it’s the content and we just need to do this on the Genesis child theme functions.php file.

// Add id="content" attributes to <main> element
add_filter( 'genesis_attr_content', 'my_attr_content' );
function my_attr_content( $attr ) {

     $attr['id'] .= 'content';
     return $attr;
    
}

The flexibility of filter in Genesis Framework is not limited to what’s shown in this example. You can also create custom schema for anything on your site by using the same method.

Further Reading

Custom microdata with Genesis 2.0

July 5, 2014 Filed Under: How To, WordPress Tagged With: Genesis Framework

How to Change WordPress Upload Folder

If you do a fresh install using WordPress 3.5 or later, you may have noticed that one useful feature that’s sorely missing is the ability to change the default upload directory from the Administration page.

WordPress Old Media Settings (Administration Dashboard)

Not sure why it was taken out in the first place, fortunately there’s still a way to do it without too much trouble.

You just need to add the following code in the wp-config.php file:

// Change default upload directory to '/myimages'
define( 'UPLOADS', 'myimages' );

The example above is based on the assumption that you want your upload directory in a sub-folder called ‘/myimages’ at the root of your WordPress installation. If you prefer to do it within your wp-content folder, make sure you include the path in the prefix:

// Change default upload directory to '/wp-content/myimages'
define( 'UPLOADS', 'wp-content/myimages' );

Note: The above code needs to be added before the last section of wp-config.php that says:

/** Sets up WordPress vars and included files. */
require_once( ABSPATH . 'wp-settings.php' );

Further Reading

Editing wp-config.php: Moving Upload Folders

February 17, 2014 Filed Under: WordPress Tagged With: PHP

Migrating Genesis Metadata to Yoast SEO

If you install Yoast’s WordPress SEO Plugin on top of your Genesis theme, you’ll notice that all your manually typed meta descriptions (and maybe keywords) just went completely missing. Meta description is an important element for search engine to index your pages and when you already have more than hundreds of pages and posts or even ten, then re-typing is definitely not an option.

Since I’m not aware of any way to do this from the plugin, the easiest way to do this is on the database.

Again as a forewarning, before you attempt to do this, backup everything in your MySQL to make sure you can revert back if you make a mistake. The solution is quick and simple, but it’s so easy to make a mistake that will corrupt your data and possibly more.

Go to your SQL admin interface such as phpMyAdmin (or you can do command line interface if you prefer) and run these sql commands:

UPDATE wp_postmeta
SET meta_key = '_yoast_wpseo_metadesc'
WHERE meta_key = '_genesis_description';

UPDATE wp_postmeta
SET meta_key = '_yoast_wpseo_metakeywords'
WHERE meta_key = '_genesis_keywords';

Here’s how it looks on phpMyAdmin panel:
MySQL's phpMyAdmin SQL commands

You have to make sure that there aren’t any typos whatsoever on the value you need to assign on the meta_key or else you need to restore the database from the backup and start over.

These sql statements were tested on WordPress SEO version 1.4.24 and Genesis Framework 2.0.2. If you use older or newer versions of both software, you need to verify the meta_key if they’re still using the same values.

January 29, 2014 Filed Under: WordPress Tagged With: Genesis Framework, SQL

Next Page »
Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to Setup WordPress Installation on Linux
  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency

Recent Posts

  • How to Setup WordPress Installation on Linux
  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2026 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure