Apache + php + mysql-php Tutorial on mac configuration

Source: Internet
Author: User
Tags php development environment website server macbook
Introduction to mac configuration Apache + php + mysql

I purchased a Macbook Pro over the weekend, so I was ready to migrate all the work environments to the Mac. it was easy to use and the user experience was really good. Currently, when learning PHP-related development, you need to configure the PHP development environment. on the Internet, there are few files for configuring the PHP development environment on the Macbook. I checked some information online, I made a summary through this article, hoping to be helpful to later students.

The installation environment is as follows:

  • Mac OS 10.10.1
  • Apache 2.4.9
  • PHP 5.5.14
  • MySQL 5.6.22

Apache configuration

In Mac OS 10.10.1, Apache software is provided. you only need to start the corresponding service. the following commands are commonly used to operate Apache.

// Start Apache service sudo apachectl start // restart Apache service sudo apachectl restart // disable Apache service sudo apachectl stop // view Apache version httpd-v

Start Apache and enter localhost in the browser. When It works appears, It means Apache is done.

Under Macbook pro, the Apache website server root directory is in the/Library/WebServer/Documents path.

Php

PHP is already included in Mac OS. you only need to add Apache support for PHP in the Apache configuration file. The steps are as follows:

Edit the http. conf configuration file with the following command:

sudo vim /etc/apache2/httpd.conf

Remove the following comments:

LoadModule php5_module libexec/apache2/libphp5.so

Restart the Apache service. write a simple test file to test it.

MySQL

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

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

After the installation, an error will be reported for any command running on the command line. you need to change the password:

Mac mysql error You must reset your password using alter user statement before executing this statement.

Step 1: set password = PASSWORD ('your new password ');

Step 2: alter user 'root' @ 'localhost' password expire never;

Step 3: flush privileges;

After completing the three steps above, log on again and use the new password. in addition to changing the new password in red, enter the new password as is.

Reference 1: https://dev.mysql.com/doc/refman/5.6/en/alter-user.html

Reference 2: http://dev.mysql.com/doc/refman/5.7/en/password-expiration-policy.html

Reference 3: http://stackoverflow.com/questions/33467337/reset-mysql-root-password-using-alter-user-statement-after-install-on-mac

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.