Steps to install PHP environment on Apple computers:
1. First we need to install Homebrew
2. Enter the command in the terminal
// 创建目录,如果你没有创建过该目录 sudo mkdir /usr/local/var sudo chmod 777 /usr/local/var //修改成你自己的用户名和组,如果你没有创建过该目录 sudo mkdir /usr/local/sbin/ sudo chown -R <username>:<group> /usr/local/sbin//由于我本身一直在使用5.6版本,故上述步骤省略,下面进入正题 //添加PHP库 brew tap homebrew/dupes brew tap homebrew/versions brew tap homebrew/homebrew-php //关闭老版本的PHP56或55或更早版本 进程 brew unlink php56 //开始安装PHP7 brew install php70 //开启PHP70进程 brew link php70 //输入命令,查看是否成功 php -v //成功后显示下面信息 PHP 7.0.8 (cli) (built: Jul 13 2016 15:19:21) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
3. Modify the apache configuration file
sudo vim /etc/apache2/httpd.conf //找到大约168行,该语句,屏蔽后,根据自己的路径,添加php7的.so文件 #LoadModule php5_module libexec/apache2/libphp5.so LoadModule php7_module /usr/libexec/apache2/libphp7.so
4. Restart apache
sudo apachectl restart
Recommended tutorial: PHP video tutorial
The above is the detailed content of Steps to install PHP environment on Apple computers. For more information, please follow other related articles on the PHP Chinese website!