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