This article will introduce to you how to perfectly install PHP7 on Mac system. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Use the third-party package homebrew to install, which is very fast and effective!
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
Then we verify whether the apache service we opened can be used, open the browser and enter:
http://localhost
Before running our php, we need to change our php configuration file, open Finder, "Go->Go to Folder...", enter:
/etc/apache2/
Find us httpd.conf configuration file:
Use a text editor to uncomment the following line:
LoadModule php7_module libexec/apache2/libphp7.so
After modifying the configuration file, we only need to restart our Apache service for the modification to take effect. Enter in Terminal:
sudo apachectl restart
Next we want to know the version of php on our Mac.
We enter in Terminal:
// 在Apache的根目录下复制index.html.en文件并重命名为info.php。 sudo cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php
Open our info.php file, use a text editor to add after "It works":
<?php phpinfo(); ?>
Then restart our Apache.
After restarting, we enter in the browser URL bar:
http://localhost/info.php
Recommended learning: php video tutorial
The above is the detailed content of How to perfectly install PHP7 on Mac system. For more information, please follow other related articles on the PHP Chinese website!