PHP Not Executing Scripts

Hello,

Hello, I am trying to get Zabbix running on TrueNAS 13.0-U6.3. I used this as a guide for the install:

When I navigate to http://zabbix.mydomainname.com/zabbix/ I am not getting the login or setup page, instead I get this:
Code:
. **/ require_once dirname(__FILE__).'/include/classes/user/CWebUser.php'; require_once dirname(__FILE__).'/include/config.inc.php'; require_once dirname(__FILE__).'/include/forms.inc.php'; $page['file'] = 'index.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = [ 'name' => [T_ZBX_STR, O_NO, null, null, 'isset({enter}) && {enter} != "'.ZBX_GUEST_USER.'"', _('Username')], 'password' => [T_ZBX_STR, O_OPT, P_NO_TRIM, null, 'isset({enter}) && {enter} != "'.ZBX_GUEST_USER.'"'], 'sessionid' => [T_ZBX_STR, O_OPT, null, null, null], 'reconnect' => [T_ZBX_INT, O_OPT, P_SYS|P_ACT, null, null], 'enter' => [T_ZBX_STR, O_OPT, P_SYS, null, null], 'autologin' => [T_ZBX_INT, O_OPT, null, null, null], 'request' => [T_ZBX_STR, O_OPT, null, null, null], 'form' => [T_ZBX_STR, O_OPT, null, null, null] ]; check_fields($fields); if (hasRequest('reconnect') && CWebUser::isLoggedIn()) { if (CAuthenticationHelper::get(CAuthenticationHelper::SAML_AUTH_ENABLED) == ZBX_AUTH_SAML_ENABLED) { $provisioning = CProvisioning::forUserDirectoryId(CAuthenticationHelper::getSamlUserdirectoryid()); $saml_config = $provisioning->getIdpConfig(); if ($saml_config['slo_url'] !== '' && CSessionHelper::has('saml_data')) { redirect('index_sso.php?slo'); } } CWebUser::logout(); redirect('index.php'); } $autologin = hasRequest('enter') ? getRequest('autologin', 0) : getRequest('autologin', 1); $request = getRequest('request', ''); if ($request !== '' && !CHtmlUrlValidator::validateSameSite($request)) { $request = ''; } if (!hasRequest('form') && CAuthenticationHelper::getPublic(CAuthenticationHelper::HTTP_AUTH_ENABLED) == ZBX_AUTH_HTTP_ENABLED && CAuthenticationHelper::getPublic(CAuthenticationHelper::HTTP_LOGIN_FORM) == ZBX_AUTH_FORM_HTTP && !hasRequest('enter')) { redirect('index_http.php'); } // login via form if (hasRequest('enter') && CWebUser::login(getRequest('name', ZBX_GUEST_USER), getRequest('password', ''))) { CSessionHelper::set('sessionid', CWebUser::$data['sessionid']); if (CWebUser::$data['autologin'] != $autologin) { API::User()->update([ 'userid' => CWebUser::$data['userid'], 'autologin' => $autologin ]); } if (CWebUser::$data['mfaid']) { CSessionHelper::set('confirmid', CWebUser::$data['sessionid']); // In case user has not finished their Duo authentication, need to unset data saved into session by Duo. if (CSessionHelper::has('state')) { CSessionHelper::unset(['state', 'username']); } $mfa_url = (new CUrl('index_mfa.php')); if ($request !== '') { $mfa_url->setArgument('request', $request); } redirect($mfa_url->toString()); } $redirect = array_filter([$request, CWebUser::$data['url'], CMenuHelper::getFirstUrl()]); redirect(reset($redirect)); } if (CWebUser::isLoggedIn() && !CWebUser::isGuest()) { redirect(CWebUser::$data['url'] ? : CMenuHelper::getFirstUrl()); } $messages = get_and_clear_messages(); echo (new CView('general.login', [ 'http_login_url' => (CAuthenticationHelper::getPublic(CAuthenticationHelper::HTTP_AUTH_ENABLED) == ZBX_AUTH_HTTP_ENABLED) ? (new CUrl('index_http.php'))->setArgument('request', getRequest('request')) : '', 'saml_login_url' => (CAuthenticationHelper::getPublic(CAuthenticationHelper::SAML_AUTH_ENABLED) == ZBX_AUTH_SAML_ENABLED) ? (new CUrl('index_sso.php'))->setArgument('request', getRequest('request')) : '', 'guest_login_url' => CWebUser::isGuestAllowed() ? (new CUrl())->setArgument('enter', ZBX_GUEST_USER) : '', 'autologin' => $autologin == 1, 'error' => (hasRequest('enter') && $messages) ? array_pop($messages) : null ]))->getOutput(); session_write_close();

So I back up and realize that I can't even get a PHP test page to load. If I put
PHP:
<?php phpinfo(); ?>
on
Code:
/usr/local/www/apache24/data/info.php

The page is blank.

I think all necessary services are running:

Code:
root@zabbix:/var/run # service -e
/etc/rc.d/cleanvar
/etc/rc.d/ip6addrctl
/etc/rc.d/netif
/etc/rc.d/os-release
/etc/rc.d/cleartmp
/etc/rc.d/newsyslog
/etc/rc.d/virecover
/etc/rc.d/motd
/etc/rc.d/syslogd
/usr/local/etc/rc.d/zabbix_agentd
/usr/local/etc/rc.d/mysql-server
/usr/local/etc/rc.d/php_fpm
/etc/rc.d/cron
/usr/local/etc/rc.d/zabbix_server
/usr/local/etc/rc.d/apache24

PHP is installed:
Code:
root@zabbix:~ # php -v
PHP 8.3.12 (cli) (built: Oct 31 2024 02:23:22) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.12, Copyright (c) Zend Technologies

My Apache HTML Test page also loads properly.

I am using php-fpm (like the guide). I assume this is a configuration issue eithe with Apache or PHP. Looking for help on how to address this.
 
The tutorial you followed is incomplete to configure Apache and php-fpm.
You need to configure php-fpm to listen on a socket/port and configure Apache to SetHandler to this socket/port.

Try to follow this article to get your php-fpm running on apache, it is old but useful.
 
Where's the Apache part of your configuration? It looks like Apache doesn't know what to do with PHP files and so is delivering the source.

I'm not using php-fpm at the moment so can't remember the exact changes required, but there's plenty on the internet.
 
I'm not sure if Apache matters, but I use nginx and php-fpm (website confs)

For php-fpm I use listen = 127.0.0.1:9002 and nginx fastcgi_pass 127.0.0.1:9002.
In my reading php-fpm can use unix sockets which is what I used. I don't know if that is correct though.

I have attached my httpd.conf, httpd-ssl.conf, www.conf and httpd-default.conf
 

Attachments

The tutorial you followed is incomplete to configure Apache and php-fpm.
You need to configure php-fpm to listen on a socket/port and configure Apache to SetHandler to this socket/port.

Try to follow this article to get your php-fpm running on apache, it is old but useful.
Okay, I was scanning through that article, really dumb question, but I noticed in the PHP setup, they copy the php.ini-production to php-ini. Is that step necessary, does php need the php.ini without the production appended to the end?
 
Okay, I was scanning through that article, really dumb question, but I noticed in the PHP setup, they copy the php.ini-production to php-ini. Is that step necessary, does php need the php.ini without the production appended to the end?
Necessary probably not, but recommended yes, if you need to change default values.

So, modify your php-fpm to listen on Unix socket. And include on you Apache the SetHandle directive to this Unix socket, as mentioned in the documentation I provided you.
 
Although it seems the Original Poster's problem is nearly solved, For What It's Worth at this point, here's my PHP install recipe for an internal, non-public, server:

* Install PHP:

pkg search php | more

pkg install php82 php82-mysqli php82-session php82-ctype php82-zlib

* Configure PHP:

cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

* Create a configuration file for PHP in Apache:

echo '<IfModule dir_module>
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</IfModule>' > /usr/local/etc/apache24/modules.d/001_mod-php.conf

* vi /usr/local/etc/php.ini
date.timezone = "America/Denver"

* restart Apache

apachectl restart

The packages installed in addition to php82 are needed by other Apps installed by me. As mentioned above, a diligent admin probably ought to comprehend enough of php.ini to customize it - particularly if it's public facing.

Does anyone care to enlighten me as to the benefits of php-fpm? Why do people use it?
 
In my reading php-fpm can use unix sockets which is what I used. I don't know if that is correct though.
It can (I usually used sockets on Linux), but I didn't get to figuring out where FreeBSD wants socket files; ports was easy :p
Does anyone care to enlighten me as to the benefits of php-fpm?
I like the idea of PHP being handled outside the webserver, but I think I mainly picked it up from nginx requiring it. I figure php-fpm can be used with any webserver and adapted as-needed, whereas Apache's built-in support is Apache-specific.

php-fpm may allow for better performance separate from the webserver, and be more-manageable with load balancing/etc.
 
Why do people use it?
At the end of installing mod_php you'll get something like this:
Code:
Consider switching to php-fpm and mod_fast_cgi as per Apache httpd project
recommendation. See https://cwiki.apache.org/confluence/display/HTTPD/PHP-FPM
So the newer options are faster/scale better etc. but that may not be a concern. mod_php works fine for me, but it might not always be around, so it's best to move to php-fpm at some point, and that point is probably better under your timing than a last-minute rush when mod_php is retired.
 
Okay, so I tried to fix my installation with some of the guides you guys mentioned. That did not work. So I deleted and recreated the Jail and followed the guide that Rafael provide. I was able to get PHP working. using PHP-FPM without sockets (using 127.0.0.1). So combining this guide to setup apache, php and mysql: https://www.digitalocean.com/commun...tp-with-mpm-event-and-php-fpm-on-freebsd-12-0

With the original guide I used: https://www.server-world.info/en/note?os=FreeBSD_14&p=zabbix70&f=1

So php and apache are working. Now I have a different issue. Zabbix is throwing this error when I navigate to the URL:

Code:
Configuration file error

    DB type is not set.

My zabbix.conf.php was blank, I copied it from source and edited it and was able to get to the login page and login. Problem now is I am getting a bunch of PHP deprecation notices.
 
Back
Top