Home >Backend Development >PHP Tutorial >PHP configure php mac on mac install mac phpstorm ma

PHP configure php mac on mac install mac phpstorm ma

WBOY
WBOYOriginal
2016-07-29 08:48:55910browse

Apache configuration

Mac OS 10.10.1 comes with Apache software. We only need to start the corresponding service. The following commands are commonly used when operating Apache:

<code><span>// 启动Apache服务</span><span>
sudo apachectl start

</span><span>// 重新启动Apache服务</span><span>
sudo apachectl restart

</span><span>// 关闭Apache服务</span><span>
sudo apachectl stop

</span><span>// 查看Apache的版本</span><span>
httpd </span><span>-</span><span>v</span></code>

About sudocommand , I don’t need to say more. Start the Apache service first, and then enter localhost in the browser. The words It works appear, indicating that Apache has done it.

Under Macbook pro, the root directory of Apache's website server is under the path /Library/WebServer/Documents.

PHP configuration

PHP already comes with Mac OS. We only need to add Apache’s support for PHP in the Apache configuration file. The steps are as follows:

  1. Edit the http.conf configuration file, command as follows:
    <code><span>sudo vim </span><span>/</span><span>etc</span><span>/</span><span>apache2</span><span>/</span><span>httpd</span><span>.</span><span>conf</span></code>
  2. Remove the comments in the following parts:
    <code><span>LoadModule</span><span> php5_module libexec</span><span>/</span><span>apache2</span><span>/</span><span>libphp5</span><span>.</span><span>so</span></code>
  3. Restart the Apache service;
  4. Write a simple test file to test it.
    <code><span><?</span><span>php phpinfo</span><span>();</span><span>?></span></code>

MySQL configuration

It is more troublesome to install MySQL. Since Apache and PHP are directly included in Mac OS, it is relatively simple to install them. However, MySQL is not included and we need to download it from the official website.

After the download is completed, install it directly. After the installation is complete, start the MySQL service from System Preferences, as shown in the figure below:

mac php,mac php开发环境,php,php mac 开发工具,php mac地址,xampp,php mac 安装,mac,phpstorm ma

Okay, now log in to mysql from the command line, and then set the password. If you are not familiar with this, please refer to this article : "MySQL Literacy Chapter".

When logging in to MySQL using the command line, a 2002, mysql.sock file cannot be found error will appear.

Because MySQL places the mysql.sock file in the /tmp directory, but Mac OS goes to the /var/mysql directory to find the corresponding mysql.sock file. Therefore, the corresponding mysql.sock file cannot be found. , the corresponding 2002 error appears.

So in order to solve this problem, we need to store a soft link pointing to the /tmp/mysql.sock file in the /var/mysql directory. The command is as follows:

<code><span>sudo ln </span><span>-</span><span>s </span><span>/</span><span>tmp</span><span>/</span><span>mysql</span><span>.</span><span>sock </span><span>/</span><span>var</span><span>/</span><span>mysql</span><span>/</span><span>mysql</span><span>.</span><span>sock</span></code>

Then restart the MySQL service and it will be OK.

Summary

Okay, the configurations of Apache, PHP and MySQL have been summarized, basically this is it. Next, let us happily start the learning journey of PHP. For this article, it is a simple summary. Hope it helps everyone learn.

The above introduces the configuration of PHP on mac, including php and mac content. I hope it will be helpful to friends who are interested in PHP tutorials.

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