One of my client wanted to write tutorials containing lots of mathematical equations and formulas. By default, WordPress editor supports few symbols, but using those is not that simple. Also, the client was more comfortable in writing tutorials in Microsoft Word, as it supports plenty of mathematical symbols. I know WordPress supports remote publishing via XML-RPC, but if the Word document contains mathematical symbols then it may not appear as it is on a WordPress post. So how about uploading the Word document as an attachment and embed its content in a post? Well, it’s possible using docxpresso plugin and I’ll write a separate article on how to use the same. In this tutorial I will show how to fix ‘Uncaught Error Class ZipArchive not found’ error while using docxpresso WordPress plugin.
How to fix Uncaught Error Class ZipArchive not found
As we all know, Microsoft Word is such a powerful tool to create mathematical equations and my client was very comfortable in using it. So providing any other solution might make his writing difficult.
At first, I thought copying mathematical equations from Word and pasting it into WordPress will work. Unfortunately, it didn’t. So, I just thought of a work around by uploading the Word document to WordPress and publish it as a post? Fortunately, a WordPress plugin called docxpresso came to rescue. This plugin will allow you to publish content that has been generated with your favorite office suite (MS, Libre or Open Office) preserving all of its structure, design and format. As told earlier, I’m not going to explain how to use docxpresso plugin, as I’ll reserve it for another tutorial. Here I’ll tell you how to solve “Uncaught Error Class ZipArchive not found” error after installing docxpresso in WordPress.
Issue: Activating docxpresso plugin broke the website. Ah! my bad! After debugging, I could find the exact issue in
PHP Fatal error: Uncaught Error: Class 'ZipArchive' not found in /public_html/wp-content/plugins/docxpresso/CreateDocument.inc:87 Stack trace: #0 /public_html/wp-content/plugins/docxpresso/plugin.php(67): Docxpresso\CreateDocument->__construct(Array) #1 /public_html/wp-includes/shortcodes.php(319): docxpresso_call(Array, '', 'docxpresso') #2 [internal function]: do_shortcode_tag(Array) #3 /public_html/wp-includes/shortcodes.php(197): preg_replace_callback('/\\[(\\[?)(docxpr...', 'do_shortcode_ta...', '[docxpresso fil...') #4 /public_html/wp-includes/class-wp-hook.php(286): do_shortcode('[docxpresso fil...') #5 /public_html/wp-includes/plugin.php(203): WP_Hook->apply_filters('[docxpresso fil...', Array) #6 /public_html/wp-includes/post-template.php(240): apply_filters('the_content', '[docxpresso fil" while reading response header from upstream, client: 126.96.36.199, server: akshayaedu.com, request: "GET /testing-mathematical-symbols/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "akshayaedu.com"
Error: Class ‘ZipArchive’ not found
After googling, found a hint that the
zip extension has to be installed for
zipArchive class to be present.
If you are on a shared hosting, then you may request the hosting provider to install PHP zip extension on your server.
Install PHP Zip Extension
If your webserver is on Linux, then you can install PHP Zip extension using the below command:
sudo apt-get install php-zip
sudo yum install php-zip
If you are having multiple versions of PHP and want to link Zip extension with a specific version of PHP, then below is the command:
sudo apt-get install php7.0-zip or sudo yum install php7.0-zip
Once done, restart the web server.
Restart Apache/Nginx Web Server:
sudo systemctl restart nginx or sudo systemctl restart apache2 or /etc/init.d/nginx restart or /etc/init.d/apache restart
If you are using PHP-FPM, then you need to restart this service also.
sudo systemctl restart php-fpm or sudo systemctl restart php-fpm or /etc/init.d/php-fpm restart or /etc/init.d/php-fpm restart
That’s it! Now I activated docxpresso WordPress plugin and everything worked fine.