• Resolved nipponese

    (@nipponese)


    I am attempting to setup Wordfence WAF.

    I have created wordfence-waf.php in the root of the WP installation, and set permissions to 775, in addition to chgrp to the web group.

    I’m using host that allows for creation of an additional php.ini that is parsed in addition to the system php.ini, but does not allow exiting on system php.ini.

    There doesn’t seem to be a problem reading the custom php.ini, but when applying it, I get a PHP parse error:

    Parse error: syntax error, unexpected 'not' (T_STRING) in /home/public/wordfence-waf.php on line 3.

    The auto_prepend_file directive is the only item in this custom php.ini:

    $ cat php.ini 
    auto_prepend_file = '/home/public/wordfence-waf.php'

    Additionally, I tried adding the following to my WP root .htaccess and the warning message did not go away:

    <IfModule lsapi_module>
      php_value auto_prepend_file '/home/public/wordfence-waf.php'
    </IfModule>

    Using WordPress 4.6.1, Wordfence 6.2.2 and PHP 5.6.27.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter nipponese

    (@nipponese)

    Just incase there was any question about the location of wordfence-waf:

    $ ls -lart | grep 'wordfence-waf.php'
    -rwxrwxr-x   1 <userid>  web       342 Oct 24 20:53 wordfence-waf.php

    Hi!
    the “Parse error: syntax error, unexpected ‘not'” error indicates that the actual PHP code in that file is broken. I suggest you make sure that you actually pasted the full code in to wordfence-waf.php.

    Thread Starter nipponese

    (@nipponese)

    Here’s what I have in wordfence-waf.php:

    $ cat wordfence-waf.php 
    <?php
    // Before removing this file, please verify the PHP ini setting <code>auto_prepend_file</code> 
    does not point to this.
    
    if (file_exists('/home/public/wp-content/plugins/wordfence/waf/bootstrap.php')) {
    	define("WFWAF_LOG_PATH", '/home/public/wp-content/wflogs/');
    	include_once '/home/public/wp-content/plugins/wordfence/waf/bootstrap.php';
    }
    ?>
    Thread Starter nipponese

    (@nipponese)

    Ah, I totally see the problem now. When I pasted the code in wordfence-waf.php, the soft-wrap on the comment copy-pasted as a carriage return and php was choking on that.

    I removed the carriage return and everything works as expected.

    Great! Thanks for checking back in.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘php.ini > auto_prepend_file causes parse error’ is closed to new replies.