PHP on Mac configuration php mac install Mac Phpstorm MA

Source: Internet
Author: User
Tags configuration php php and mysql

Apache Configuration

In Mac OS 10.10.1 comes with Apache software, we just need to start the corresponding service, the following command is the operation of Apache commonly used in several commands:

// 启动Apache服务sudo apachectl start// 重新启动Apache服务sudo apachectl restart// 关闭Apache服务sudo apachectl stop// 查看Apache的版本httpd -v

sudoI don't have to say more about the order. Start the Apache service first, then enter localhost in the browser. The appearance It works of the word means that Apache is done.

Under MacBook Pro, the Apache Web server root directory is under the /Library/WebServer/Documents path.

PHP Configuration

With PHP already in the Mac OS, we just need to add Apache support for PHP in the Apache configuration file, here are the steps:

    1. Edit the http.conf configuration file with the following command:
      sudo vim /etc/apache2/httpd.conf
    2. Remove the comments from the following sections:
      LoadModule php5_module libexec/apache2/libphp5.so
    3. Restart the Apache service;
    4. Write a simple test file and test it.
      
           
            php phpinfo();?>

MySQL Configuration

Installing MySQL is troublesome, because in Mac OS is directly with Apache and PHP, so install them, relatively simple, and MySQL is not with, we need to download the official website.

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

OK, now log in from the command line MySQL, and then set the password, if you are unfamiliar with this, please refer to this article: "MySQL literacy article."

When you log in to MySQL using the command line, you will see 2002 and cannot find the error Mysql.sock file.

Since MySQL is putting the Mysql.sock file in the/tmp directory, Mac OS has gone to/var/ MySQL directory to find the corresponding Mysql.sock file, so, due to find the corresponding Mysql.sock file, there is a corresponding 2002 error here.

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

sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Then restarting the MySQL service will be OK.

Summarize

Well, Apache, PHP and MySQL configuration are summed up, basically this is something, next, let's happily start the PHP learning journey. For this article, is a simple summary. I hope it helps to learn from you.

The above describes the PHP configuration on the Mac, including the Php,mac aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.