Brew 安裝PHP軟件

Brew 安裝PHP軟件

  1. 搜索php軟件,方便安裝本身想要的版本php

    brew search php
  2. 安裝html

    brew install php@7.2

    安裝時間,根據網絡環境不一樣,請耐心等待。shell

    ...vim

    安裝完成後,注意查看信息,如:bash

    # 這裏是 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. 設定系統環境變量網絡

    打開並編輯環境變量文件php7

    vim ~/.bash_profile

    輸入對應環境變量app

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

    注意:若是wq提示是隻讀文件的話,執行wq!強制保存。php-fpm

    執行重載環境變量this

    source ~/.bash_profile
相關文章
相關標籤/搜索