# (Solved) PHP Isn't Playing With Apache2

## 67comet

Hello,

I'm working on a server that I do not have physical access to (ssh in from my location). It is an older 32bit computer (thus my love for Gentoo grows).

I installed Wordpress (It's my go-to for my friends that want to run their own servers out of their homes).

Gentoo and me haven't played with each other in quite some time, but I don't remember it being this difficult to get LAMP up and running.

I've got MySql working (Nextcloud is working), Apache2 seems to be fine, but PHP doesn't seem to be talking to Apache or visa-versa.

I followed the LAMP wiki and it all seemed fine, but when I head to her site, it just tells me "There's been a critical error" with no other information to chase down.

When I check: php -v it gives me PHP 7.4.21 (cli).

apache2ctl -M shows: php7_module (shared)

What am I missing? My vhost file seems to be fine (very similar to the ones I use for my sites at home (Ubuntu Server 21.04).

I looked in /var/log/apache for the error logs, and it looks like Wordpress is looking for PHP but it's not doing what it is asking (I don't understand it all, and I can paste it in here, but there's quite a bit).

Here is the tail results (there's more, this is the first part):

```
Thu Aug 12 16:00:37.309417 2021] [php7:error] [pid 3236] [client 114.119.134.35:8996] PHP Fatal error:  require(): Failed opening required 'ABSPATHWPINC/sodium_compat/autoload.php' (include_path='.:/usr/share/php7:/usr/share/php') in /var/www/www.watchingskycandy.com/wordpress/wp-includes/compat.php on line 333
```

The file in question (Line 333) has:

```
 // sodium_crypto_box() was introduced in PHP 7.2.

if ( ! function_exists( 'sodium_crypto_box' ) ) {

        require ABSPATH . WPINC . '/sodium_compat/autoload.php';

}
```

Any help is appreciated,

Thank you

----------

## alamahant

Hi

In /etc/conf.d/apache2

do you have php enabled

```

APACHE2_OPTS="..........-D PHP.........."

```

Possibly also fcgi and/or php-fpm depending on how you configured apache.

Also what is the output of

```

cat /etc/apache2/mo*/70_mod_php.conf

```

You also need to be mindful as to what user is php running as and the perms of the webroot directory to allow access to that user.

----------

## figueroa

PHP in make.conf?

```
$ grep PHP /etc/portage/make.conf

PHP_TARGETS="php7-4"

```

----------

## hdcg

Hi 67comet,

your PHP is already working. Actual problem is the code or more likely it's configuration.

```
Thu Aug 12 16:00:37.309417 2021] [php7:error] [pid 3236] [client 114.119.134.35:8996] PHP Fatal error:  require(): Failed opening required 'ABSPATHWPINC/sodium_compat/autoload.php' (include_path='.:/usr/share/php7:/usr/share/php') in /var/www/www.watchingskycandy.com/wordpress/wp-includes/compat.php on line 333
```

PHP is running, but fails to include the mentioned file 'ABSPATHWPINC/sodium_compat/autoload.php'. I guess the variables ABSPATH WPINC are undefined and therefore PHP considers them as strings (most likely there is a PHP warning in the log that this is happening) and creates the invalid path.

Next step is to understand why they are not defined. They look like WordPress variables.

Best Regards,

Holger

----------

## 67comet

 *alamahant wrote:*   

> Hi
> 
> In /etc/conf.d/apache2
> 
> do you have php enabled
> ...

 

Yes, it's in there.

 *Quote:*   

> 
> 
> Possibly also fcgi and/or php-fpm depending on how you configured apache.
> 
> Also what is the output of
> ...

 

Here's what it has:

```

IfDefine PHP>

        # The mod_php.so symlink is controlled by

        # eselect-php. However, the module name changed from

        # php5_module to php7_module so we can't blindly load whatever

        # is there. Instead we let eselect-php manage a small

        # configuration file that loads the appropriate module.

        Include "/var/lib/eselect-php/mod_php.conf"

        # Tell apache that mod_php should handle PHP files.

        #

        # NOTE: Avoiding AddHandler/AddType for security (bug

        # #538822). Please read the related news item!

        <FilesMatch "\.(php|php[57]|phtml)$">

                SetHandler application/x-httpd-php

        </FilesMatch>

        # PHP source files which are meant to be displayed as

        # syntax-highlighted source code.

        #<FilesMatch "\.phps$">

        #        SetHandler application/x-httpd-php-source

        #</FilesMatch>

        #DirectoryIndex index.php index.phtml   

#<FilesMatch "\.(php|php[57]|phtml)$">

                #SetHandler application/x-httpd-php

        #</FilesMatch>

        # PHP source files which are meant to be displayed as

        # syntax-highlighted source code.

        #<FilesMatch "\.phps$">

        #       SetHandler application/x-httpd-php-source

        #</FilesMatch>

        DirectoryIndex index.php index.phtml

</IfDefine>

```

 *Quote:*   

> 
> 
> You also need to be mindful as to what user is php running as and the perms of the webroot directory to allow access to that user.

 

Not sure what it's running as, I didn't mess with it other than to re-emerge it a few times hoping it'd "fix its self".

Thank you.

----------

## Banana

hdcg is correct.

I think there is something messed up with your wordpress installation since ABSPATH and WPINC is defined by wordpress itself

https://github.com/WordPress/WordPress/blob/master/wp-load.php

Have a look here at the compat file: https://github.com/WordPress/WordPress/blob/master/wp-includes/compat.php

It should look like this:

```

// sodium_crypto_box() was introduced in PHP 7.2.

if ( ! function_exists( 'sodium_crypto_box' ) ) {

   require ABSPATH . WPINC . '/sodium_compat/autoload.php';

}
```

ABSPATH and WPINC are two definitons and not one as seen in your error message: ABSPATHWPINC

PS:

I'm not a wordpress expert and will never be, I just understand PHP  :Wink: 

EDIT:

Just saw you posted the method already.

Make sure you have the requested file: https://github.com/WordPress/WordPress/blob/master/wp-includes/sodium_compat/autoload.php

Some google foo tells me that your wordpress install is missing some files. If you can login there should be an update which can fix it. Also a manuall download of the same version and upload to the server could solve it.

----------

## 67comet

 *figueroa wrote:*   

> PHP in make.conf?
> 
> ```
> $ grep PHP /etc/portage/make.conf
> 
> ...

 

My make.conf does have php in there under the USE flag, and I un-hashtagged the PHP_TARGETS line.. Recompiled --newuse (world) and php works when I make a simple phpinfo page, but it croaks when I get to the installation of Wordpress (From their download - after I enter the database stuff, it croaks w/no good info - I'll go hit their forums up), looks like this is a Wordpress issue, not a Gentoo issue ( I'm happy about that ) ..

Thank you all again!  :Smile: 

----------

## figueroa

As a USE flag, php has very limited application.

```
$ euse -i php

global use flags (searching: php)

************************************************************

[-      ] php - Include support for the PHP language

local use flags (searching: php)

************************************************************

[-      ] php

    kde-apps/umbrello: Enable PHP import support using dev-util/kdevelop 

    and dev-util/kdevelop-pg-qt

        [-  ] (5) 21.04.3 [gentoo]

        [-  ] (5) 21.08.0 [gentoo]

```

----------

