Fedora httpd not logging errors to vhost error log and how to config php for development vs production

I am having some issues with setting up a web development environment. I am new to fedora desktop, coming from a macbook, but really loving it.

I recently discovered the fedora docs and used this to setup postfix and dovecot with a little tweaking using other resources online… just to test my app sending email etc.

However for httpd and php8.3, I simply just used dnf install and it was up and running. Some issues came up.

PHP did not provide a dev-php.ini and was setup as production, so I do not have all the error reporting and had to initiate the display errors in my code if app is local.cc type deal.

ini_set('display_errors', 1); 
ini_set('display_startup_errors', 1); 
error_reporting(E_ALL);

This was also different than what I was used to because changing the setting in /etc/php.ini did nothing on rebooting httpd, I had to find and reboot systemctl restart php-fpm.service. This is not a big deal cause php still works and I was most likely using a different setup of PHP in mac brew as the docs shows them here

What really sucks is that httpd isn’t logging errors after setting up a vhost in /etc/httpd/conf.d/domain.conf with the following directives

<VirtualHost *:80>
    ServerName localsmb.cc
    DocumentRoot /var/www/smb
    ErrorLog /var/log/httpd/smb_error.log
    CustomLog /var/log/httpd/smb.log combined
<Directory /var/www/smb>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
</VirtualHost>

The access log works just fine in /var/log/httpd/smb.log and there are entries when tailing it. But my error log has nothing, empty, /var/log/httpd/smb_error.log. I even removed the file and reboot httpd and it did get re-created but still no logs.

So I guess my question is how can I fix or config my php as development (or I live with display errors in my code), and how can I fix apache to write to my vhost error logs, because that is important for me.

I have not touched anything more in httpd, and php other than changing the post files to 200M and such.

thanks for any advice.

Please fix the title to reflect your question. You are more likely to get a useful answer then.

1 Like

Did you install the php-devel package? Or any of the other related -devel packages?

# dnf list php* | grep dev
Updating and loading repositories:
Repositories loaded.
php-devel.x86_64                                    8.3.14-1.fc41                        updates
php-fedora-autoloader-devel.noarch                  1.0.1-14.fc41                        fedora
php-pecl-apcu-devel.x86_64                          5.1.24-1.fc41                        fedora
php-pecl-http-devel.x86_64                          4.2.6-1.fc41                         updates
php-pecl-igbinary-devel.x86_64                      3.2.16-1.fc41                        fedora
php-pecl-imagick-devel.x86_64                       3.7.0-13.fc41                        fedora
php-pecl-krb5-devel.x86_64                          1.2.2-2.fc41                         fedora
php-pecl-msgpack-devel.x86_64                       3.0.0-1.fc41                         fedora
php-pecl-raphf-devel.x86_64                         2.0.1-17.fc41                        fedora
php-zstd-devel.x86_64                               0.14.0-1.fc41                        updates

@computersavvy
Thanks for your comment. I will give this a try once I finish something up in the code, just in case I screw up my env.

I am wondering if I should remove what I installed to start fresh and install what you have listed?

gstlouis@fedora:~$ rpm --query --all | grep 'php'
php-common-8.3.14-1.fc41.x86_64
php-fpm-8.3.14-1.fc41.x86_64
php-8.3.14-1.fc41.x86_64
php-pdo-8.3.14-1.fc41.x86_64
php-cli-8.3.14-1.fc41.x86_64
php-mbstring-8.3.14-1.fc41.x86_64
php-opcache-8.3.14-1.fc41.x86_64
php-sodium-8.3.14-1.fc41.x86_64
php-xml-8.3.14-1.fc41.x86_64
php-mysqlnd-8.3.14-1.fc41.x86_64

That is not what I have installed.
Your listing is what you already have installed.

That listing is exactly what the command returns and is all the php*-devel packages available from fedora.
You will need to select the packages as appropriate but since you seem to be doing php development it seems likely that you may need one or more of those packages.

@computersavvy
So I tried dnf install php-devel. It did not give me the listing you displayed. It did install php-devel-8.3.14-1.fc41.x86_64 with some dependencies. I am not sure what to expect, but nothing has really changed. I thought maybe I would see a development php.ini in /etc/php or something.

I would see a development php.ini in /etc/php or something

development/production upstream configuration are provided as documentation

# rpm -ql --docfiles php-common
...
/usr/share/doc/php-common/php.ini-development
/usr/share/doc/php-common/php.ini-production

I usually recommend to not change /etc/php.ini, but instead to create an additional configuration file for local needs, such as /etc/php.d/mysettings.ini

About logging, as php script are run by php-fpm backend service, this have to be configured there

In service configuration /etc/php-fpm.conf

error_log = /var/log/php-fpm/error.log

And in default pool configuration /etc/php-fpm.d/www.conf

php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on

You can also create different pools for different users, applications or configuration

1 Like

@computersavvy the devel packages is for developping php and extensions (C code), php users usually don’t need them (rather development tools such as composer, PHPUnit, php-cs-fixer…)

Understood.
Note that I was guessing since I do not use php and the OP indicated he was doing development. Many tools have a -devel package and it is not always clear what the purpose is nor how configuration is managed.

Thank you for stepping in and providing those suggestions.