mac 查询php版本信息,升级mac的PHP版本

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-23 07:28   91   0

我今天想安装配置开源项目来学习VUE,但是执行命令的时候,提示我PHP版本过低.

我mac电脑PHP版本是php5.6.2

b1c6461dc6cb74c96c61477c5a3e66d0.png

升级步骤

执行

brew search php

选择安装版本php7.1

brew install php@7.1

5cdfc216ae7a8601bcdb3eb9d00bc6f3.png

==> Caveats

==> apr

apr is keg-only, which means it was not symlinked into /usr/local,

because Apple's CLT package contains apr.

If you need to have apr first in your PATH run:

echo 'export PATH="/usr/local/opt/apr/bin:$PATH"' >> ~/.bash_profile

==> apr-util

apr-util is keg-only, which means it was not symlinked into /usr/local,

because Apple's CLT package contains apr.

If you need to have apr-util first in your PATH run:

echo 'export PATH="/usr/local/opt/apr-util/bin:$PATH"' >> ~/.bash_profile

==> libidn

Emacs Lisp files have been installed to:

/usr/local/share/emacs/site-lisp/libidn

==> openldap

openldap is keg-only, which means it was not symlinked into /usr/local,

because macOS already provides this software and installing another version in

parallel can cause all kinds of trouble.

If you need to have openldap first in your PATH run:

echo 'export PATH="/usr/local/opt/openldap/bin:$PATH"' >> ~/.bash_profile

echo 'export PATH="/usr/local/opt/openldap/sbin:$PATH"' >> ~/.bash_profile

For compilers to find openldap you may need to set:

export LDFLAGS="-L/usr/local/opt/openldap/lib"

export CPPFLAGS="-I/usr/local/opt/openldap/include"

==> curl-openssl

curl-openssl is keg-only, which means it was not symlinked into /usr/local,

because macOS already provides this software and installing another version in

parallel can cause all kinds of trouble.

If you need to have curl-openssl first in your PATH run:

echo 'export PATH="/usr/local/opt/curl-openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find curl-openssl you may need to set:

export LDFLAGS="-L/usr/local/opt/curl-openssl/lib"

export CPPFLAGS="-I/usr/local/opt/curl-openssl/include"

For pkg-config to find curl-openssl you may need to set:

export PKG_CONFIG_PATH="/usr/local/opt/curl-openssl/lib/pkgconfig"

==> libtool

In order to prevent conflicts with Apple's own libtool we have prepended a "g"

so, you have instead: glibtool and glibtoolize.

==> gettext

gettext is keg-only, which means it was not symlinked into /usr/local,

because macOS provides the BSD gettext library & some software gets confused if both are in the library path.

If you need to have gettext first in your PATH run:

echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile

For compilers to find gettext you may need to set:

export LDFLAGS="-L/usr/local/opt/gettext/lib"

export CPPFLAGS="-I/usr/local/opt/gettext/include"

==> libffi

libffi is keg-only, which means it was not symlinked into /usr/local,

because some formulae require a newer version of libffi.

For compilers to find libffi you may need to set:

export LDFLAGS="-L/usr/local/opt/libffi/lib"

For pkg-config to find libffi you may need to set:

export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"

==> sqlite

sqlite is keg-only, which means it was not symlinked into /usr/local,

because macOS provides an older sqlite3.

If you need to have sqlite first in your PATH run:

echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile

For compilers to find sqlite you may need to set:

export LDFLAGS="-L/usr/local/opt/sqlite/lib"

export CPPFLAGS="-I/usr/local/opt/sqlite/include"

For pkg-config to find sqlite you may need to set:

export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig"

==> python

Python has been installed as

/usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to

`python3`, `python3-config`, `pip3` etc., respectively, have been installed into

/usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run

brew install python@2

You can install Python packages with

pip3 install They will install into the site-package directory

/usr/local/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python

==> icu4c

icu4c is keg-only, which means it was not symlinked into /usr/local,

because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH run:

echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile

echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile

For compilers to find icu4c you may need to set:

export LDFLAGS="-L/usr/local/opt/icu4c/lib"

export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:

export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

==> libpq

libpq is keg-only, which means it was not symlinked into /usr/local,

because conflicts with postgres formula.

If you need to have libpq first in your PATH run:

echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.bash_profile

For compilers to find libpq you may need to set:

export LDFLAGS="-L/usr/local/opt/libpq/lib"

export CPPFLAGS="-I/usr/local/opt/libpq/include"

For pkg-config to find libpq you may need to set:

export PKG_CONFIG_PATH="/usr/local/opt/libpq/lib/pkgconfig"

==> php@7.1

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

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

SetHandler application/x-httpd-php

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.1/

php@7.1 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.1 first in your PATH run:

echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profile

echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.bash_profile

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

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

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

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

brew services start php@7.1

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

php-fpm

切换版本到php7.1

445ddbacbc928f45507cfa11a50377c5.png

执行

brew link php@7.1

echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profile

echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.bash_profile

srouce ~/.bash_profile

执行后查看 ~.bash_profile配置如下

dcfb9e3093eb93cfab5fe056af274254.png

再次查看PHP版本

4152eeff71829a44fe9071c2673d23fa.png

mac下自带apache

需要修改目录/private/etc/apache2/other配置

d0192ad90d7896b87a446c42fb98d4d0.png

967d85d4e4a6d1277dbf89830ff72af6.png

3da47e456d2e8ca818f4bb06db05c04d.png

5509a8a0739e9b53f505f06f6c6c85a1.png

重启apache服务

1a383d245cac2f25c237e5f96598a4f9.png

sudo apachectl restart

项目路径 /Library/WebServer/Documents/index.php

8dc20b47d1a369feb6faa5c56c4824a2.png

浏览器输入localhost

9f175ebe4e971a8be9df31e9f4e3544e.png

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP