Enable Plesk Webp PHP 7.4 GD Support

Today i want to add on my website the support for webp images, and so i have found a plugin for wordpress that is free WebP Converter for Media

But for this plugin we must to active the support webp on the php module GD.
On My VPS i have installed PHP 7.4 on Plesk, the simple way is to change the modulo gd of plesk php version with a custom module in witch the webp support is enabled.

I have find this useful guide that i rewrite with php 7.4 that i have used on my VPS. 

Install the necessary package

# yum install make gcc plesk-php74-devel libjpeg-turbo-devel libpng-devel libXpm-devel freetype-devel libwebp-devel

Download PHP source. Note! Version of PHP source should be the same as your Plesk PHP version! For example, for PHP 7.4.4

# wget http://be2.php.net/get/php-7.4.4.tar.gz/from/this/mirror
# tar -xzf mirror
# cd php-7.4.4/ext/gd

Compile gd.so module

# /opt/plesk/php/7.4/bin/phpize
# ./configure --with-php-config=/opt/plesk/php/7.4/bin/php-config --with-webp --with-freetype --with-jpeg --with-xpm
# make

Replace original Plesk PHP gd.so module with compiled

# mv /opt/plesk/php/7.4/lib64/php/modules/gd.so /opt/plesk/php/7.4/lib64/php/modules/gd.so_orig
# cp modules/gd.so /opt/plesk/php/7.4/lib64/php/modules/
# plesk bin php_handler --reread

Check that all is OK

# /opt/plesk/php/7.4/bin/php -m | grep gd

Do not forget to to make fake removal of original plesk-php74-gd package! Otherwise, your custom gd.so will be overwritten with next update.

# rpm -e --justdb plesk-php74-gd


At last remember that you must to go on
Plesk -> Tool & Setting -> PHP Settings
Choose your PHP Verison in this case PHP 7.4.4 and

  • Remove GD module and save
  • Add GD module and save

So Plesk rebuild php for the domains.

CodeAnywhere Laravel Php Container Setup

I use for a long time CodeAnywhere to develop my application via FTP, or to use shell server console via SSH.
Now i want to use the Container and try to create a Laravel PHP application.
But i have encountered some errors that i want to report you.

Now start with the creation of the container, with the “Connection Wizard” is very simple:

If we want to run the Laravel php application, we must to use this command, and set the ip to use app from remote container url.


[cabox@PHPBOX app]$ php artisan serve --host= --port=8000
Laravel development server started:

Some possible error

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

Edit your app/providers/AppServiceProvider.php file and inside the boot method set a default string length:

use Illuminate\Support\Facades\Schema;

public function boot()

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘users’ already exists

Solution is to run con shell

[cabox@PHPBOX app]$ php artisan migrate:fresh
[cabox@PHPBOX app]$ php artisan migrate

PHP Script Import Mysql Dump Gzip .sql.gz

In many case we have the necessity to import a mysql dump in fast way on our database, to see some old data or to restore.

Now i want to show you a simple but powerful php script to import a mysql dump gzipped.

We use the function zcat with shell_exec

shell_exec("zcat <url file> | mysql -u <user_db> -p<password db> <database>")

This is a simple php script that we can use on our application, to restore in fast way our gzipped mysql dump

We create a select, to show a list of file, and then choose one and click “load”, then with our zcat shell execution function, load it.

if(isset($_POST['action']) &amp;&amp; $_POST['action'] == 'execute')
  $file_name = $_POST['filename'];
  $out = shell_exec("zcat ".$file_name." | mysql -u user_db -pPasswordDB db_name");
  echo "Mysql Dump Imported Successfull!";

function getDirContents($dir, &amp;$results = array()){
    $files = scandir($dir);
    foreach($files as $key => $value){
        $path = realpath($dir.DIRECTORY_SEPARATOR.$value);
        if(!is_dir($path)) {
            $results[] = $path;
        } else if($value != "." &amp;&amp; $value != "..") {
            getDirContents($path, $results);
            $results[] = $path;

    return $results;

//directory of our backup file
$listFile = getDirContents('/var/www/vhosts/<our domain>/backups');
echo "<form method=POST>";
echo "<select name='filename'>";
foreach ($listFile as &amp;$value) {
  echo "<option>".$value."</option>";
echo "</select>";
echo "<input type='hidden' name='action' value='execute'>";
echo "<input type='submit' name='Load Mysql Dump'>";
echo "</form>";

Plesk Nginx WP Super Cache Expert Mode Settings

Have you got a wordpress site and you want to optimize it?
The simple way to take fast your website is:

  • Install WPSuper Cache Plugin
  • Setting Server side Nginx

Install WP Super Cache Plugin

The installation of WPSuper Cache is easy, just download the plugin and then upload it on our wordpress website.

Setting WP Super Cache

Now i show to you how to set wp super cache in “Expert mode”, remember that this mode require the change on the server for nginx configuration.

Enable Caching ON

Then we must to set the Expert Mode, and then suggest some setting:

Settings Server side Nginx

Now we need to set the configuration of nginx on our server, in this case i configure a Plesk Server.
We must go in the Domain Setting -> Apache & nginx Settings
In the bottom we find “Additional nginx directives

We must to enable:

  • GZIP compression for the page that we serve on the client
  • Header Cache Control to declase a cache browser for the js, css, image etc..
  • Location to find wpsupercache generated file
  • Security setting 
### WP Super Cache Below ###
set $cache_uri $request_uri;

# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
	set $cache_uri 'null cache';

# GZIP Compression
gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_proxied any;
gzip_comp_level 9;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary on;

# NGINX Caching
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff)$ {
	expires 14d;
	add_header Cache-Control "public, no-transform";
	log_not_found off;

location ~* \.(jpg|jpeg|gif|png)$ {
	expires 14d;
	add_header Cache-Control "public, no-transform";
	log_not_found off;

location ~* \.(pdf|css|html|js|swf)$ {
	expires 14d;
	add_header Cache-Control "public, no-transform";
	log_not_found off;

location ~ \.css {
	add_header  Content-Type    text/css;
location ~ \.js {
	add_header  Content-Type    application/x-javascript;

if ($query_string != "") {
	set $cache_uri 'null cache';

# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
	set $cache_uri 'null cache';

# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
	set $cache_uri 'null cache';

# Use cached or actual file if they exists, otherwise pass request to WordPress
location ~ / {
	try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php ;

if (!-e $request_filename) {
	rewrite ^(.+)$ /index.php?q=$1 last;

location ~* wp-config.php { deny all; }
location ~* "^/wp-content/(?!plugins/).*\.php" { deny all; }

Now you can test your site on pagespeed and see the difference!
If you want much performance you can use Autoptimize WordPress plugin to minify js, css and html.