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

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

Mu class network of small friends, this time I will bring you how to configure the PHP development environment under the Mac, gossip, start our work!
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

sudo apachectl start

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

sudo apachectl-v

can view version information for Apache

Server version:Apache/2.2.24(Unix)Server built:Jul7201318: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

sudo apachectl restart

PHP is ready for use.

3, in the terminal input

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 http://dev.mysql.com/downloads/mysql/website, select the Mac OS x platform, and then select the download in the diagram, download the version 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 123456, but also for other, custom can

/usr/local/mysql/bin/mysqladmin -u root password 123456

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

$cfg[‘Servers‘]]$i][‘host‘]=‘localhost‘;

For

$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

$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.
PHP development also need to download a PHP development tool, the MAC has a lot of PHP development tools, but most people use phpstorm and sublime, need to be reminded 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 dedicated to the PHP project, otherwise, it will not work

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