[pro-Test] Configure the PHP development environment under Mac: Apache+php+mysql

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

The company has given us a Big Apple Mac Pro laptop, which is getting used to it for two days. With the virtual machine PD, it does solve some things because the work habits can not be done well on iOS, but I think, since the use of iOS as far as possible to deal with the iOS environment, so as to avoid the like Guan Yu playing broadsword but riding a small Trojan horse. Before the installation of the PHP development environment under Windows, it is easy to download an integration package directly, such as Xmapp, Ampps, and so on, has not been in IIS for many years or the next one in Windows to configure, to engage in this stuff. iOS itself seems to be based on the Linux kernel to get up the operating system, so itself with some of the Apache and other things, so to or in iOS to build a PHP development environment, free to find the time to explore.

Online also search for some tutorials, compared to the previous installation of Windows, it is really simple.

First step: Start Apache

Many tutorials write "There are two ways", I think arabesque, do not want to understand, also did not care about it. I think it should be said that there are two operations.

1. Start "Internet sharing" in the configuration.

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

Here the operation of the time seems to be a little puzzled, is how to choose the question, I did not make too clear, roughly randomly in the following check a connection, save as if it had.

2. Start Apache

Open Launchpad, find "terminal", also like the command line under Windows, DOS way similar. Should it be called a shell under Linux? Oh, not very clear.

Enter the following command to launch Apache

sudo apachectl start

Note that the following Apache is the letter L, not the number 1. I still got dizzy here.

Start to enter the password, you lose, the power-on password can be. In general, no input is wrong, the normal start.

After startup, you can view the Apache version information by entering the following command.

sudo apachectl-v

Speaking of this, I have a little self-understanding, if the understanding is wrong, later to change. Experts, please smile and past it ~

Sudo seems to be running, Apachectl is the name of the Apache service, followed by some parameters, such as Start is the start, restart is a reboot. Each subsequent modification of the config file requires a reboot to take effect. Such.

Well, when we get here, Apache starts to finish. A webserver is ready to run.

Enter http://localhost in the browser and the IT works! will appear The page.

Step two: Start PHP

After Apache starts, the Web service starts, but this is not supported by PHP running and needs to start PHP. Fortunately, iOS also comes with PHP, which is also installed, and only needs to be started.

Here's how:

Locate the Apache configuration file, typically under directory/etc/apache2/. If not very familiar with how to find the directory under iOS, please follow me: Open finder, select "Go to"-"Go to Folder", enter "/etc/apache2/", find the "httpd.conf" this configuration file.

Select Open with document to edit, tap command+f, search #LoadModule php5_module libexec/apache2/libphp5.so

In this configuration file, the preceding # number indicates that the comment is out of effect. So we're going to start the PHP module by just removing the # from the front of the line.

Once removed, save the httpd.conf file.

This time the problem comes, because the default to the folder does not have the right to prompt text lock, can not 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.

I am sure to do the B-step, that is, to copy to the desktop, modified and posted back to get it done. This situation seems to have happened under Windows, and so on.

Modified the httpd.conf file, it is necessary to restart Apache to take effect. The command to restart is as follows:

sudo apachectl restart

At this point, PHP is ready to start!

So, how do we know if it succeeds, practice is the only standard for testing truth, let's test it.

This is another thing, that is where the Web root directory of Apache is the problem. I began to look under the Apache folder, half a day is not in, later read the instructions on the Internet, only to know in

/library/webserver/documents/this. That is, directly through the Finder directly to the directory can find our previous access to the Index.html.en file.

/library/webserver/documents/This directory also involves modifying the permissions of the problem, of course, can also be modified as above, but it is too inconvenient. So I took the way to modify the httpd.conf file, modify the Web root point.

This is done: Of course, open the httpd.conf file first. Depressed, still need to copy to the desktop of that file to change, and then refrigerator to/etc/apache2/directory, and then restart Apache to make it effective.

Open httpd.conf and find

" /library/webserver/documents " " /library/webserver/documents ">

Change the quotation marks to the web directory you want to build. I modified this: Create a mywebroot directory under the users/lintianyu/directory, and then modify the above code to:

" /library/webserver/documents " # " /library/webserver/documents ">"/users/lintianyu/mywebroot""/users/ Lintianyu/mywebroot">

Keep it original, with # comment out, in case you forget. Then add yourself to the newly created directory address.

Then restart Apache to make its changes effective.

To create a new info.php file in the users/lintianyu/directory, enter the following code:

1 Phpinfo ();?>

Save.

Open the browser, enter http://localhost/info.php, if everything is not unexpected, you can see the familiar phpinformation page!

Step three: Installation of MySQL

The first is to download MySQL, this ios can not bring your own, the URL is as follows:

Http://dev.mysql.com/downloads/mysql/really admire the things foreigners do, for decades, such as a day, the Web site will never change.

Unlimited version, note the following several rules:

    • See the OS, IOS
    • See if it is the latest version, generally the latest version
    • See the format, DMG archive should be more suitable for the installation of small white in iOS
    • See quasi-adaptive hardware, 32-bit or 64-bit. Mac naturally selected for 64 bits.

See, lest under the use, annoyed.

At the moment I'm under the following version:

Mac OS X 10.10 (x86, 64-bit), DMG Archive 5.7.9 322.9M

More than 300 m, it takes a bit of time, not fast.

Download finished, click the DMG file, said decompression will have four files, but my version seems to only see a file, and did not deliberately pay attention to the . After installation, you can choose to start or close MySQL in System Preferences.

In the terminal enter the following command, here to change the password is 12345, can also be other, custom can

12345

MySQL installation is complete.

Fourth Step: PhpMyAdmin

1, download phpMyAdmin, in the URL http://www.phpmyadmin.net/home_page/downloads.php select the appropriate version of the download.

A lot of versions, but the choice is not difficult, the main look: Select the latest version of the choice of multi-lingual (if the English is enough for the ox can also choose as long as the English), choose their own familiar compression method.

2, the downloaded files are extracted, put into/users/lintianyu/mywebroot/this web root folder, and the following a large list of suffixes deleted, directly named phpMyAdmin, easy to access.

3. Copy the config.sample.inc.php in/users/lintianyu/mywebroot/phpmyadmin and name it config.inc.php, and put it under the current folder. (It didn't have a config.inc.php before?) Strange

4, edit the config.inc.php, modify the connection information therein

1 ' $cfg [' Servers ']] $i [' host '] = ' localhost '; 2 $cfg [' Servers ']] $i [' host '] = ' 127.0.0.1 '; 3 ' Why change, what's the difference I don't know

Then modify the connection password. If you do not want to enter a password, modify it to false as follows

1 $cfg [' Servers '] [$ifalse

Enter Http://localhost/phpmyadmin in the browser, enter the username "root", and the password you just changed, if the password is not changed, then follow the previous step of the no password operation, then you can directly login.

Done!

[pro-Test] Configure the PHP development environment under Mac: Apache+php+mysql

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.