Configure the php environment on Mac

Source: Internet
Author: User
MacOSX has built-in Apache and PHP, which is very convenient to use. This article takes MacOSX10.9.5 as an example. The main content includes: start Apache, run PHP, install MySQL, use phpMyAdmin to configure the MCrypt extension library of PHP, and set the virtual host to start Apache. There are two ways to enable "SystemPreferences )"

Mac OS X has built-in Apache and PHP, which is very convenient to use. This article takes Mac OS X 10.9.5 as an example. The main content includes: start Apache, run PHP, install MySQL, and use phpMyAdmin to configure the MCrypt extension library of PHP to set up a virtual host to start Apache. There are two ways to enable "System Preferences )"

Mac OS X has built-in Apache and PHP, which is very convenient to use. This article takes Mac OS X 10.9.5 as an example. The main content includes:

Start Apache

Run PHP

Install MySQL

Use phpMyAdmin

Configure the MCrypt extension library of PHP

Set VM

Start Apache

There are two methods:

Choose System Preferences> Sharing> Web Sharing )"

Open "terminal" and (Note: The password required by sudo is the root account password of the system)

Run "sudo apachectl start" and then enter the account password to run Apache.

Run "sudo apachectl-v" and you will see the Apache version number in Mac OS X 10.9.5:

Server version: Apache/2.2.26 (Unix)

Server built: Dec 10 2013 22:09:38

In this way, enter "http: // localhost" in the browser, and you can see that the content is "It works !" Is located under "/Library (resource Library)/WebServer/Documents/", which is the default root directory of Apache.

NOTE: If Apache is enabled, "Web Sharing" is enabled, and connected users access "/Library (resource Library)" through "http: // [local IP address) /WebServer/Documents/"directory, through" http: // [local IP address]/~ [User name] to access the "/Users/[user name]/Sites/" directory. You can set "Firewall" in "Security" of "system preference settings) to prohibit such access.

Run PHP

Run "sudo vi/etc/apache2/httpd. conf" on the terminal to open the Apache configuration file. (If you are not familiar with operating terminal and vi, you can set to display all system hidden files in the Finder. Remember to restart the Finder so that you can find the corresponding file and edit it as you like, note that you need to enable the root account to modify some files, but it is safer to use sudo on the terminal to temporarily obtain the root permission .)

Find "# LoadModule php5_module libexec/apache2/libphp5.so", remove the # sign, save it (enter w in the command line), and exit vi (enter q in the command line ).

Run "sudo cp/etc/php. ini. default/etc/php. ini" to configure various php functions through PHP. ini. For example:

Use the following two items to adjust the maximum value of the submitted PHP file, for example, the maximum value of imported data in phpMyAdmin.

Upload_max_filesize = 2 M

Post_max_size = 8 M

For example, display_errors is used to control whether the PHP Program Reports errors.

Display_errors = Off

Run "sudo apachectl restart" and restart Apache so that PHP can be used.

Run "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.

Run "vi/Library/WebServer/Document/info. php" on the terminal to edit the info. php file in vi. In "It's works !" Add" And save it. In this way, you can see information about php in http: // localhost/info. PHP, for example, the version number is 5.4.30.

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.