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.
Next, go to our PHP Directory and create a PHP file of our own.
- 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 ^_^