How to Configure PHP and Apache with Brew on macOS for Seamless Extension Installation?

Susan Sarandon
Release: 2024-10-19 12:45:02
Original
116 people have browsed it

How to Configure PHP and Apache with Brew on macOS for Seamless Extension Installation?

PHP Brew Installation and Apache Configuration

When installing PHP extensions via brew on macOS, it's crucial to ensure compatibility with Apache.

Checking PHP Versions

Check if brew's PHP differs from Apache's by using:

brew search php
Copy after login

Confirm that the version you expect is installed and add it to your PATH if necessary.

Configuring Apache

To enable PHP in Apache, follow these steps:

  1. Open your httpd.conf file and add the following lines:
LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>
Copy after login
  1. Check DirectoryIndex to include index.php:
DirectoryIndex index.php index.html
Copy after login
  1. Restart Apache to apply the changes.

PHP Configuration Files

The configuration files for PHP are located at:

/usr/local/etc/php/7.4/
Copy after login

You can find additional information in the Homebrew PHP formula page:

brew info php
Copy after login

By adhering to these instructions, you can ensure that Apache uses the PHP version installed via brew and seamlessly integrate your PHP extensions.

The above is the detailed content of How to Configure PHP and Apache with Brew on macOS for Seamless Extension Installation?. For more information, please follow other related articles on the PHP Chinese website!

source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!