Configure the php development environment on Mac: Apache + php + MySql + phpmyadmin

Source: Internet
Author: User
Tags php development environment
Configure the php development environment on Mac: Apache + php + MySql + phpmyadmin 1. start Apache

There are two methods

1. enable network sharing

Open "system preference settings"-> "share", and tick before "Internet sharing.

2. open the terminal and enter

?
1
Sudo apachectl start
Enter the password, enter the computer password, and then enter

?
1
Sudo apachectl-v
You can view Apache version information.
?
1
2
Server version: Apache/2.2.24 (Unix)
Server built: Jul 7 2013 18:05:17
Enter http: // localhost in the browser, and It works will appear! Page

2. run PHP

1. find the Apache configuration file, go to the/etc/apache2/directory, open the Finder, select "go to"-"Go to Folder", and enter "/etc/apache2 /", find "httpd. conf "file, select open with document for editing, click Command + F, search # LoadModule php5_module libexec/apache2/libphp5.so,



Remove the # of the blue line and save it. if the text is locked and cannot be unlocked, there are two solutions:

A) select the file, right-click the File, select "show Introduction", click the lock icon in the lower right corner, enter the computer password to unlock, and then select the + key on the left, select the user who logs on to the current computer and set the permission to read and write. if it still does not work, change the permission of the folder at the upper level again.

B) copy the file to the desktop, modify it, and copy it to the original folder to replace the previous file.

2. restart Apache and enter


?
1
Sudo apachectl restart
PHP can be used.
3. enter

?
1
Sudo cp/Library/WebServer/Documents/index.html. en/Library/WebServer/Documents/info. php
Copy the index.html. en file in the apacheroot directory and rename it info. php.

4. open info. php and add It after It works. And then restart Apache again. enter http: // localhost/info. php in the browser. a page showing php information appears ,.



3. configure MySql

1. on the http://dev.mysql.com/downloads/mysql/website, select the Mac OS x platform and select download in the figure. I started downloading. the installation was incorrect. later, the version shown in the download figure was successfully installed.



Double-click the dmg file



Double-click the first installation, double-click the third installation, double-click the second installation, and the second is the configuration file. after installation, you can choose to start or close MySql in system preference settings.

2. change the password

Enter the password on the terminal. here, you can change the password to 12345. you can also customize the password for others.


?
1
/Usr/local/mysql/bin/mysqladmin-u root password 12345
4. use phpMyAdmin

PhpMyAdmin is a MySql management program developed with PHP, which is very practical.

1. download phpMyAdmin at the URL

2. decompress the downloaded file, put it in the/Library/WebServer/Documents/folder, and name it phpmyadmin.

3. copy config. sample. inc. php from/Library/WebServer/Documents/phpmyadmin, name it config. inc. php, and put it in the current folder.

4. edit config. inc. php and modify


?
1
$ Cfg ['servers'] $ I] ['host'] = 'localhost ';
Is
?
1
$ Cfg ['servers'] $ I] ['host'] = '2017. 0.0.1 ';
If you want to log on without a password, change false in the following statement to true.

?
1
$ Cfg ['servers'] [$ I] ['allownopassword'] = false
5. enter http: // localhost/phpmyadmin in the browser, enter the username "root", and the password you just changed. if the password is not changed, follow the password-free operation in the previous step, and then you can log on directly.

PS: After the configuration is complete, you still need to download a php development tool for php Development. There are also a lot of php development tools under mac. you can Google Baidu on your own. Please note, after installing the development tool, remember to put the project in the same directory file as phpmyadmin when suggesting the php project. you can create a new folder to store the php project. otherwise, it cannot be run (I have not personally verified it as instructed by a great god)

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.