Apache 2.4 doesn't start with PHP 8.2

I've been trying to set up a local web server using FreeBSD 14.3 and Apache2.4. Apache alone works fine, but when loading the PHP 8.2 module it doesn't start up. (PHP 8.2 itself is installed and works). When running sudo apachectl start i get the following:

Code:
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.

and afterwards the server isn't running. There were no errors or warnings in the httpd-error.log file.

So far I did the following (after installing and configuring Apache 2.4):
  1. Install PHP 8.2 using pkg (sudo pkg install php82)
  2. Install PHP 8.2 Module using pkg (sudo pkg install mod_php82)
  3. Adding file handler (using mod_php.conf in Includes dir, file is attached)
To try and fix the problem I did the following:
  1. Using different versions of PHP
  2. Leaving out file handlers (just trying to get Apache to start)
But that didn't change anything.

I've attached a copy of my httpd.conf file.

I already went through a lot of existing threads, but I didn't find anything that fit my problem. I know this is probably something simple, but can anybody tell me what I'm doing wrong?
 

Attachments

I have installed apache, mysql and php on FreeBSD 14.2, 14.3 and today 15.0. I will tell you what i do and you can compare steps to figure out what you have and have not done. You should be up and running very quickly. My steps from today:

1. # pkg install apache24-2.4.66
2. # sysrc enable_apache24="YES"
3. # service apache24 start
4. # pkg install php82-8.2.30
5. # pkg install mod_php82-8.2.30
6. # sysrc php_fpm_enable="YES"
7. # nano /usr/local/etc/apache24/Includes/php.conf

edit the file with the following information:
Code:
&lt;IfModule dir_module&gt;<br>    DirectoryIndex index.php index.html<br>    &lt;FilesMatch "\.php$"&gt;<br>        SetHandler application/x-httpd-php<br>    &lt;/FilesMatch&gt;<br>    &lt;FilesMatch "\.phps$"&gt;<br>        SetHandler application/x-httpd-php-source<br>    &lt;/FilesMatch&gt;<br>&lt;/IfModule&gt;

8. # service apache24 restart

now add a php file to your data directory (/usr/local/www/apache24/data/index.php)
open a web browser and go to localhost or directly localhost/index.php

also, you should change the httpd.conf file to Listen at localhost port 80 if you are only running the server locally. port 80 will open up your computer to port scanners.

let us know if you figure it out...
 
# nano /usr/local/etc/apache24/Includes/php.conf
That should go in /usr/local/etc/apache24/modules.d/

I've attached a copy of my httpd.conf file.
Code:
DocumentRoot "/srv/www/public"
<Directory "/srv/www/public">
Don't do it this way. Leave httpd.conf as is, including its default website. Want to create your own website?
Create a /usr/local/etc/apache24/Includes/000_default.conf:
Code:
<VirtualHost _default_:80>

  {...} Website configuration
</VirtualHost>

The _default_ keyword will make sure you get here by IP address, with HTTP/1, etc. For other virtualhosts you use:
Code:
<VirtualHost *:80>

  ServerName mywebsite.example.com
  {...}
</VirtualHost>
 
Because the module is named that way for PHP 8.0+. And it gets added automagically after installing any of the mod_php* ports/packages.
 
If you try and simplify things just to see if you can get it working - so (just for now) ditch mod_php.conf.

I have this (in httpd.conf but that seems a bit naughty, but just see if it works for you):
Code:
<IfModule php_module>
    AddType application/x-httpd-php .php
</IfModule>
Goal is just to get something working first, then you can move it to the recommended place or wherever you want.

Don't have to use AddType, I think it's old-fashioned, but try simplifying your configuration first. And try AddType to see if it works.

FreeBSD, Apache and mod_php definitely work and work well, so you must be close!
 
Hello

Thanks for your replies!

I reinstalled Apache and set everything to defaults. Then I installed PHP, mod_php and created a config file, but I got the same problem I had before.
I tried different configurations, but that still didn't change anything.

In the end the only thing that got Apache working again, was deactivating mod_php.

So in frustration I installed FreeBSD 15.0 and tried it there, and it worked without any problems.

I think the problem may have been that I installed the i386 version of FreeBSD 14.3 (at the time I wasn't sure if the machine supported amd64).
 
I think the problem may have been that I installed the i386 version of FreeBSD 14.3 (at the time I wasn't sure if the machine supported amd64).

What machine is it?

You could try running this:-

sh:
echo "CPU: $(sysctl -n hw.model)"; \
echo "OS arch: $(uname -m)"; \
if grep -qi lm /var/run/dmesg.boot; then echo "CPU supports: 64-bit"; else echo "CPU supports: 32-bit only"; fi
 
Back
Top