Configure the PHP development environment under Mac: Apache+php+mysql

Source: Internet
Author: User
Tags mysql in php development environment php mysql phpmyadmin


Abstract system OS X 10.8.5,apache is a Mac comes with, mainly PHP configuration and MySQL configuration, online tutorials are also very much, I also have reference, but feel that some steps are not very smooth implementation, according to their own configuration of the process of finishing

PHP MySQL Apache mac configuration

Catalogue [-]

    • First, start Apache
    • Second, run PHP
    • Third, configure MySQL
    • Iv. Use of phpMyAdmin
First, start Apache

There are two ways

1. Turn on network sharing

Open "System Preferences", "sharing", before "Internet sharing" that item to hit √.

2. Open Terminal, enter

1 sudo apachectl start

You need to enter the password, enter the computer password, and then enter

1 sudo apachectl -v
can view version information for Apache?
12 Server version: Apache/2.2.24 (Unix)Server built:   Jul  7 2013 18:05:17

When you enter http://localhost in the browser, the IT works! appears The page

Second, run PHP

1, find the Apache configuration file, in the directory/etc/apache2/, open Finder, select "Go"-"Go to Folder", enter "/etc/apache2/", find the "httpd.conf" file, choose to open with the document to edit, Tap command+f, search #loadmodule php5_module libexec/apache2/,

The Blue Line of the # is removed, and then saved, if there is a text lock, unable to unlock the situation, there are two ways to solve

A) Select the file, right-click after selecting "Show Info", click on the lower right corner of the small lock icon, enter the computer password to unlock, and then select the left of the + sign key, select their current computer login user, set the permissions to read and write, if still not, will be the same level folder permissions again modified once.

b) Copy the file to the desktop, modify it, and then copy it to the original folder to replace the previous file.

2. Restart Apache in the terminal input

1 sudo apachectl restart
PHP is ready for use.

3, in the terminal input

1 sudo cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php

That is, copy the Index.html.en file and rename it to info.php in the root directory of Apache.

4. Open info.php, add <?php phpinfo () after it works, and then restart Apache again, enter http://localhost/info.php in the browser, and a page will appear with PHP information.

Third, configure MySQL

1, on the, select the Mac OS x platform, and then select the download in the diagram, I started to download the wrong, installation error, and then download the version of the image installed successfully

Double-click the DMG file

Double-click the first installation, double-click the third installation, and then double-click the second, the second is the profile, after installation, you can choose to start or turn off MySQL in System preferences.

2. Change the password

In the terminal input, here to change the password is 12345, but also for other, custom can

1 /usr/local/mysql/bin/mysqladmin -u root password 12345
Iv. Use of phpMyAdmin

phpMyAdmin is a PHP-developed program for managing MySQL, very practical

1, download phpMyAdmin, in the URL select the appropriate version of the download, I chose the phpmyadmin-4.0.8-all-languages.tar.bz2

2, the downloaded files are extracted, put into the/library/webserver/documents/folder, and named phpMyAdmin.

3. Copy the in/library/webserver/documents/phpmyadmin and name it, and put it under the current folder.

4, edit, modify one of the

1 $cfg[‘Servers‘]]$i][‘host‘] = ‘localhost‘;
to be?
1 $cfg[‘Servers‘]]$i][‘host‘] = ‘‘;
Then , if you want to login without a password, change the false in the following statement to True

1 $cfg[‘Servers‘][$i][‘AllowNoPassword‘] = false

5, enter http://localhost/phpmyadmin in the browser, enter the user name "root", and just change the password, if not changed password, then follow the previous step of the no password operation, and then you can directly login.

PS: To this configuration to complete, PHP development also need to download a PHP development tools, Mac PHP development tools are also quite a lot, we Google Baidu, we need to remind that, after installing the development tools, in the proposed PHP project, remember to put the project in and phpmyadmin the same directory file , you can create a new folder specifically for the PHP project, otherwise, it will not work (a big god instruction, I have not personally verified)

Configure the PHP development environment under Mac: Apache+php+mysql

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: 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.