Home > Backend Development > PHP Problem > Steps to install PHP environment on Apple computers

Steps to install PHP environment on Apple computers

王林
Release: 2023-02-27 15:38:02
Original
3135 people have browsed it

Steps to install PHP environment on Apple computers

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
Copy after login

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
Copy after login

4. Restart apache

sudo apachectl restart
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template