How to install php environment under mac

藏色散人
Release: 2023-03-07 11:58:01
Original
9513 people have browsed it

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复制代码
Copy after login
  • Open the terminal and enter the following command to start the Apache service.
sudo apachectl start
Copy after login
  • 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复制代码
Copy after login
Copy after login

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
Copy after login
  • 打开 httpd.conf 这个文件,找到下面这一行,然后将前面的 # 注释符去掉,然后 command + s 保存。
LoadModule php5_module libexec/apache2/libphp5.so复制代码
Copy after login
How to install php environment under mac
  • 输入以下命令重启 Apache 服务。
sudo apachectl restart复制代码
Copy after login
  • 打开 Finder ,然后按下 shift + command + G 打开前往文件夹,前往以下地址,这个地址是 Apache 的默认网站服务器根目录。
/Library/WebServer/Documents复制代码
Copy after login
Copy after login
  • 新建一个名为 How to install php environment under mac.php 的文件,在里面输入以下代码后,command + s 保存。
Copy after login
  • 打开浏览器在地址栏输入 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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!