In order to build an operation and maintenance of the project backstage, the newly-learned PHP, the first time to build a PHP development environment on the MacBook, so on record, but also for other learning partners to provide a reference.
Tools/Materials
- Apache 2.4.16
- Php
- Macbook Pro
- MySQL 5.7
Launch Apache
- 1
Introduce a few commands first
Launch Apache Service
sudo apachectl start
Restart Apache Service
sudo apachectl restart
Stop Apache Service
sudo apachectl stop
View Apache version
Httpd-v
Mac OS comes with Apache and only needs to start Apache on the line.
Open terminal, enter command: sudo apachectl start
- 2
Open the browser, enter localhost in the address bar, and the It works string will show that Apache has successfully started
- 3
Under MacBook Pro, the Apache Web server root directory is under the/library/webserver/documents path
END
Configure PHP
Mac OS also comes with PHP, just need to add Apache to PHP in the Apache configuration file support is good
Enter the command in the terminal:
sudo vim/etc/apache2/httpd.conf
Open httpd.conf File
Remove the comment symbol for the contents of the red box callout
LoadModule Php5_module libexec/apache2/libphp5.so
and then save
How to use Vim to edit content is not available here at this stage
Restart Apache Service
Enter the/library/webserver/documents,
Create a new test PHP page in this directory, enter the command: sudo vim test.php
Enter the following code in the test.php
<?php phpinfo ();?>
Open page localhost/test.php in the browser to test if PHP is available
END
How to build a PHP development environment in MacBook Pro