Configuration of the PHP environment in mac OS environment, macos

Source: Internet
Author: User

Configuration of the PHP environment in mac OS environment, macos

Recently, I am looking at php. Today I have learned about the php environment configuration and Baidu materials, which is simple and convenient.

First, you need to prepare:

  • Apache web Server

  • PHP
  • MacBook
  • MySql

Start the Apache service first: (several commands need to be introduced here)

  • Start Apache service sudo apachectl start
  • Restart Apache service sudo apachectl restart
  • Stop the Apache service sudo apachectl stop
  • View Apache version httpd-v

Because Mac OS comes with Apache, you do not need to download and install it. Simply start the Apache service on the terminal.

  

Here we can see the service version: Apache/2.4.25 (Unix)

Open the browser: (enter localhost and It works will appear! , Indicating that the Apache service has been successfully started)

  

On Mac, the root directory of Apache website server is in the/Library/WebServer/Documents path.

  

The phptest. php file is created by myself.

Next we will configure PHP: (because Mac OS itself also comes with PHP, This is a benefit for our new friends, you only need to add Apache support for PHP in the Apache configuration file)

Open the httpd. conf file on the terminal. Modify LoadModule php5_module libexec/apache2/libphp5.so.

  • Sudo vim/etc/apache2/httpd. conf (open the http. conf file)

  

Enter your Mac password.

  • Open the httpd. conf file and find LoadModule php5_module libexec/apache2/libphp5.so.

Note: The default value is # LoadModule php5_module libexec/apache2/libphp5.so. This item is commented out, and it is OK to remove the previous.

  

Restart the Apache service.

  • Sudo apachectl restart

Next, go to our PHP Directory and create a PHP file of our own.

  • Enter/Library/WebServer/Documents, create a PHP test page under the directory, and enter the command: sudo vim phptest. php

  • Edit our first PHP File

  

  • Run localhost/phptest. php in the browser.

  

Sorry, please ignore this Warning (). For Beginners, I don't know what this warning is and how to set date. timezone.

Date_default_timezone_set ("Asia/Beijing"); (is this incorrect? Please advise)

However, in general, I still learned that at least the java web html I have learned is displayed. It indicates that the PHP environment configuration is correct. As for the PHP syntax, study it slowly!

 

The reference of this article: Baidu experience http://jingyan.baidu.com/article/67508eb434539f9cca1ce4da.html here thanks ^_^

  

  

 

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.