Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
(Solved) PHP Isn't Playing With Apache2
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
67comet
Apprentice
Apprentice


Joined: 29 Oct 2004
Posts: 262
Location: Ogden, UT

PostPosted: Thu Aug 12, 2021 5:58 pm    Post subject: (Solved) PHP Isn't Playing With Apache2 Reply with quote

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):

Code:
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:
Code:
 // 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
_________________
A Pile of Code (basically dead).
Personal Site (basically useless).


Last edited by 67comet on Fri Aug 13, 2021 5:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3872

PostPosted: Thu Aug 12, 2021 7:05 pm    Post subject: Reply with quote

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

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

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

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.
_________________
:)
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2894
Location: Edge of marsh USA

PostPosted: Fri Aug 13, 2021 3:56 am    Post subject: Reply with quote

PHP in make.conf?
Code:
$ grep PHP /etc/portage/make.conf
PHP_TARGETS="php7-4"

_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/17.1/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
hdcg
Tux's lil' helper
Tux's lil' helper


Joined: 07 Apr 2013
Posts: 119

PostPosted: Fri Aug 13, 2021 5:01 am    Post subject: Reply with quote

Hi 67comet,

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

Code:
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
Back to top
View user's profile Send private message
67comet
Apprentice
Apprentice


Joined: 29 Oct 2004
Posts: 262
Location: Ogden, UT

PostPosted: Fri Aug 13, 2021 4:26 pm    Post subject: Reply with quote

alamahant wrote:
Hi
In /etc/conf.d/apache2
do you have php enabled
Code:

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

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
Code:

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

Here's what it has:
Code:

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.
_________________
A Pile of Code (basically dead).
Personal Site (basically useless).
Back to top
View user's profile Send private message
Banana
Veteran
Veteran


Joined: 21 May 2004
Posts: 1337
Location: Germany

PostPosted: Fri Aug 13, 2021 4:26 pm    Post subject: Reply with quote

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:
Code:

// 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 ;-)

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.
_________________
My personal space
My delta-labs.org snippets do expire

PFL - Portage file list - find which package a file or command belongs to.
Back to top
View user's profile Send private message
67comet
Apprentice
Apprentice


Joined: 29 Oct 2004
Posts: 262
Location: Ogden, UT

PostPosted: Fri Aug 13, 2021 5:16 pm    Post subject: Reply with quote

figueroa wrote:
PHP in make.conf?
Code:
$ grep PHP /etc/portage/make.conf
PHP_TARGETS="php7-4"


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! :)
_________________
A Pile of Code (basically dead).
Personal Site (basically useless).
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2894
Location: Edge of marsh USA

PostPosted: Fri Aug 13, 2021 5:33 pm    Post subject: Reply with quote

As a USE flag, php has very limited application.
Code:
$ 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]

_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/17.1/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum