> 文章列表 > brew安装php扩展

brew安装php扩展

brew安装php扩展

Introduction: What is .brew?

.brew is a package manager for macOS that allows users to easily install and manage various software and libraries. It is similar to other package managers like Homebrew and MacPorts, but specific to macOS users. With .brew, users can quickly install and manage PHP extensions for their development environment.

installing .brew:

The first step in installing .brew is to open the terminal on your macOS and enter the following command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This command will download and install .brew and add it to your system’s PATH variable. Once .brew is installed, you can begin using it to install PHP extensions.

Installing PHP Extensions with .brew:

To install a PHP extension using .brew, open the terminal and enter the following command:

brew install php@7.2-extension

Replace ‘extension’ with the name of the extension you would like to install. For example, if you want to install the ‘mysqli’ extension, the command would be:

brew install php@7.2-mysqli

Once the installation is complete, you will need to restart the PHP server for the changes to take effect. You can do this by running:

sudo apachectl restart

Updating .brew:

To keep your .brew up to date, enter the following command in your terminal:

brew update

This will update the .brew package manager and any dependencies that need updating. It is recommended to update .brew regularly to keep your packages and extensions up to date.

Uninstalling .brew:

If you need to uninstall .brew, enter the following command in your terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

This will remove .brew from your system and restore any files or settings that were modified during the installation process.

生活知识