Home  >  Article  >  Backend Development  >  Learn the detailed tutorial to perfectly install PHP7 on Mac system

Learn the detailed tutorial to perfectly install PHP7 on Mac system

coldplay.xixi
coldplay.xixiforward
2020-06-29 17:54:203729browse

Learn the detailed tutorial to perfectly install PHP7 on Mac system

##Installation tutorial:

1. Start Apache

First we start the Apache service that comes with the system.

Open Terminal and enter the following command:

// 开启Apache服务
sudo apachectl start
// 查看Apache版本号
sudo apachectl -v

图 Terminal输入命令打开apache服务及查看版本号

Then we verify whether the apache service we opened can be used, open the browser and enter:

http://localhost
Related learning recommendations:

PHP programming from entry to proficiency

Running PHP

Before running our php, we need to change our php Configuration file, open Finder, "Go -> Go to Folder...", enter:

/etc/apache2/
Find our httpd.conf configuration file:


Learn the detailed tutorial to perfectly install PHP7 on Mac system

Use text editing After the configuration file is modified, we only need to restart our Apache service to make the modification take effect. Enter in Terminal:

LoadModule php7_module libexec/apache2/libphp7.so
Next we want to know the version of php on our Mac.

We enter in Terminal: Learn the detailed tutorial to perfectly install PHP7 on Mac system

sudo apachectl restart
to open our info.php file, use a text editor to add after "It works":

// 在Apache的根目录下复制index.html.en文件并重命名为info.php。
sudo cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php
and then restart our Apache again.

After restarting, we enter in the browser URL bar:

<?php  phpinfo(); ?>


Learn the detailed tutorial to perfectly install PHP7 on Mac system

## Use the The third-party package homebrew is used to install it, which is very fast and effective! Installation tutorial: 1. Start ApacheFirst we start the Apache service that comes with the system.

Open Terminal and enter the following command:

http://localhost/info.php

Then we verify whether the apache service we opened can be used, open the browser and enter:

// 开启Apache服务
sudo apachectl start
// 查看Apache版本号
sudo apachectl -v

Run PHP

Before running our php, we need to change our php configuration file, open Finder, "Go->Go to Folder...", enter: 图 Terminal输入命令打开apache服务及查看版本号

http://localhost
Find us httpd.conf configuration file:

Use a text editor to uncomment the following line:

/etc/apache2/


Learn the detailed tutorial to perfectly install PHP7 on Mac systemConfiguration After the file is modified, we only need to restart our Apache service for the modification to take effect. Enter in Terminal:

LoadModule php7_module libexec/apache2/libphp7.so

Next we want to know the version of php on our Mac.

We enter in Terminal:

sudo apachectl restart
Learn the detailed tutorial to perfectly install PHP7 on Mac system to open our info.php file, use a text editor to add after "It works":
// 在Apache的根目录下复制index.html.en文件并重命名为info.php。
sudo cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php

and then restart our Apache again.

After restarting, we enter in the browser URL bar:

<?php  phpinfo(); ?>

The above is the detailed content of Learn the detailed tutorial to perfectly install PHP7 on Mac system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete