Upgrading to PHP 7 with NinjaFirewall installed.



All editions of NinjaFirewall (WP, WP+, Pro and Pro+) are compatible with the latest PHP 7. However, because the firewall needs to be loaded by PHP via a directive added to your INI or .htaccess file, there could be a few minor issues that you may need to fix manually.

Note that the following issues apply only if you already have NinjaFirewall installed and running on the server you are upgrading from PHP 5 to 7.

Apache with mod_php and .htaccess

If you are running Apache with PHP as a module (mod_php), NinjaFirewall directive was added to your main .htaccess file during the installation process:

# BEGIN NinjaFirewall
<IfModule mod_php5.c>
   php_value auto_prepend_file /path/to/.../lib/firewall.php
# END NinjaFirewall

After the upgrade, the <IfModule mod_php5.c> directive will be ignored by PHP 7 and the firewall will not be loaded. To solve this problem, follow these steps:

  1. Upgrade to PHP 7.
  2. Edit your .htaccess and replace the mod_php5.c string with mod_php7.c:
    # BEGIN NinjaFirewall
    <IfModule mod_php7.c>
       php_value auto_prepend_file /path/to/.../lib/firewall.php
    # END NinjaFirewall
    There is no need to restart Apache.
  3. Log in to NinjaFirewall administration interface (Pro/Pro+ Edition) or WordPress admin dashboard (WP/WP+ Edition) and ensure that the firewall is loaded.


The following issue can only happen if the firewall directive was added to a php.ini or php5.ini file: after upgrading to PHP 7, NinjaFirewall may complain that it not loaded or it may start again its installation process.
If this happens to you, try to rename your php.ini (or php5.ini) file to .user.ini, which is the default and preferred per-directory INI file. Note that .user.ini files are not reloaded immediately by PHP but every five minutes, therefore wait up to five minutes or, if this is your own server, restart Apache (or PHP-FPM) to force PHP to reload it.


A powerful antivirus
scanner for WordPress.


Website Monitoring
for just .99 per month.


Web Application Firewall
for PHP and WordPress.


Malware removal
and hacking recovery.

Table of contents