Home >Backend Development >PHP Problem >How to install php environment under mac

How to install php environment under mac

藏色散人
藏色散人Original
2020-11-06 09:18:129712browse

How to install the php environment on mac: First start the Apache service through the command "sudo apachectl start"; then open the "httpd.conf" file and cancel the comment symbol before "php5_module"; finally test it through How to install php environment under mac. Can.

How to install php environment under mac

Recommended: "PHP Video Tutorial"

Recently trying to configure showdoc to my own server , it requires a PHP environment, so I configured it myself and record the method here.


1. Turn on the Apache service

Mac The system comes with the Apache service, you just need to turn it on , the following are several common commands for Apache services.

/* 启动 Apache 服务 */
sudo apachectl start

/* 重启 Apache 服务 */
sudo apachectl restart

/* 停止 Apache 服务 */
sudo apachectl stop

/* 查看 Apache 版本 */
httpd -v复制代码
  • Open the terminal and enter the following command to start the Apache service.
sudo apachectl start
  • Open the browser and enter http://localhost in the address bar. If It Works appears, it means the Apache service is started successfully.
启动 Apache 服务
  • The default root directory of the website server of Apache is in the path below.
/Library/WebServer/Documents复制代码

Note: If Server is installed on your Mac, this software must be uninstalled (the icon is a blue globe) That), otherwise entering http://localhost will display Server information that will conflict. I don’t care about the specific reasons. Those who are interested can learn more.

2. Configure the PHP environment

Mac The system also comes with the PHP environment. Just open it. If you want to do it yourself If you want to install it, just search it yourself.

  • 打开 Finder ,然后按下 shift + command + G 打开前往文件夹,前往以下地址:
/etc/apache2/httpd.conf
  • 打开 httpd.conf 这个文件,找到下面这一行,然后将前面的 # 注释符去掉,然后 command + s 保存。
LoadModule php5_module libexec/apache2/libphp5.so复制代码
How to install php environment under mac
  • 输入以下命令重启 Apache 服务。
sudo apachectl restart复制代码
  • 打开 Finder ,然后按下 shift + command + G 打开前往文件夹,前往以下地址,这个地址是 Apache 的默认网站服务器根目录。
/Library/WebServer/Documents复制代码
  • 新建一个名为 How to install php environment under mac.php 的文件,在里面输入以下代码后,command + s 保存。
<?php How to install php environment under mac();
?>
  • 打开浏览器在地址栏输入 http://localhost/How to install php environment under mac.php ,跳出以下信息就表示 PHP 环境配置成功。
How to install php environment under mac

这里配置的是 Mac 系统自带的 PHP 环境,想另外安装的就自己去搜一下吧。


The above is the detailed content of How to install php environment under mac. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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