Brew安装PHP软件

编程

Brew 安装PHP软件

  1. 搜索php软件,方便安装自己想要的版本

    brew search php

  2. 安装

    brew install php@7.2

    安装时间,根据网络环境不同,请耐心等待。

    ...

    安装完成后,注意查看信息,如:

    # 这里是 Apache 环境需要修改的信息

    To enable PHP in Apache add the following to httpd.conf and restart Apache:

    LoadModule php7_module /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so

    <FilesMatch .php$>

    SetHandler application/x-httpd-php

    </FilesMatch>

    Finally, check DirectoryIndex includes index.php

    DirectoryIndex index.php index.html

    The php.ini and php-fpm.ini file can be found in:

    /usr/local/etc/php/7.2/

    php@7.2 is keg-only, which means it was not symlinked into /usr/local,

    because this is an alternate version of another formula.

    # 系统环境变量要修改的信息

    If you need to have php@7.2 first in your PATH run:

    echo "export PATH="/usr/local/opt/php@7.2/bin:$PATH"" >> ~/.zshrc

    echo "export PATH="/usr/local/opt/php@7.2/sbin:$PATH"" >> ~/.zshrc

    For compilers to find php@7.2 you may need to set:

    export LDFLAGS="-L/usr/local/opt/php@7.2/lib"

    export CPPFLAGS="-I/usr/local/opt/php@7.2/include"

    To have launchd start php@7.2 now and restart at login:

    brew services start php@7.2

    Or, if you don"t want/need a background service you can just run:

    php-fpm

  3. 设定系统环境变量

    打开并编辑环境变量文件

    vim ~/.bash_profile

    输入对应环境变量

    export PATH="/usr/local/opt/php@7.2/bin:$PATH"

    注意:如果wq提示是只读文件的话,执行wq!强制保存。

    执行重载环境变量

    source ~/.bash_profile

以上是 Brew安装PHP软件 的全部内容, 来源链接: utcz.com/z/511162.html

回到顶部