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

Source: Internet
Author: User
Tags php development environment
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
?
1
2
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/libphp5.so,



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 the info.php, after it works add , 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 http://dev.mysql.com/downloads/mysql/website, 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 http://www.phpmyadmin.net/home_page/downloads.php 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 config.sample.inc.php in/library/webserver/documents/phpmyadmin and name it config.inc.php, and put it under the current folder.

4, edit config.inc.php, modify one of the


?
1
$cfg [' Servers ']] $i [' host '] = ' localhost ';
For
?
1
$cfg [' Servers ']] $i [' host '] = ' 127.0.0.1 ';
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)
  • 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.