Trying to use PHP 8.1
on localhost
with Mac OS High Sierra (10.13.6)
.
Note that I also want to keep PHP 7.4, because I still need it for older projects.
It doesn't work and error logs shows nothing.
What I did so far
brew install php@8.1
.zshrc
with the pathexport PATH="/usr/local/opt/php@8.1/bin:$PATH"
export PATH="/usr/local/opt/php@8.1/sbin:$PATH"
httpd.conf
, added the following line LoadModule php_module /usr/local/opt/php@8.1/lib/httpd/modules/libphp.so
and commented other php moduleshttpd-vhosts.conf
with the following conf :<VirtualHost *:80>
ServerName my-project.local
DocumentRoot "/Library/WebServer/Documents/my-project"
ErrorLog "/private/var/log/apache2/my_project-error_log"
CustomLog "/private/var/log/apache2/my_project-access_log" common
<Directory "/Library/WebServer/Documents/my-project/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
/etc/hosts/
, added the domain :
127.0.0.1 my-project.local
sudo apachectl restart
Result
The index.php
file is read, but PHP is not working.
I've put <?php phpinfo(); ?>
+ some random HTML on my index.php, when opening http://my-project.local with Firefox I only see the HTML, phpinfo is not showing, not even as plain text, just blank.
When reaching http://my-project.local with Chrome I see the PHP as plain text.
Notes
httpd.conf
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
but it doesn't help, actually in this case index.php
is not read and I got the error The connection has been reset
but nothing is shown in error logs, either access logs.
I don't understand what's going on, everything seems good to me, if somebody could help me ?
Thanks
Found the solution, I had to add index.php
to DirectoryIndex
which had only index.html
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
Now everything works fine