Mac system comes with Apache and PHP, you can use it as long as you enable it
1. Modify the Apache configuration file
sudo vim /etc/apache2/httpd.conf.
Uncomment out the following two lines
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so
Comment out line 221 #Require all denied
212 #ServerName www.example.com:80
Also uncomment line 499 to make apache’s vhost settings take effect
497
502 #Include /private/etc/apache2/extra/httpd-manual.conf
2. vim/etc /apache2/extra/httpd-vhosts.conf
Add the following content (sheng is my user name, xxx is the virtual domain name I added)
ServerName xxx.com
Options FollowSymLinks
AllowOverride All
Require all granted
3. Modify the host settings of this machine
vim /etc/hosts
Add a line
127.0.0.1 xxx.com
4.Open the terminal command line
sudo apachectl start.
5. Put an index.php in /Users/sheng/site/xxx The file
can be written with the following content. (The PHP version of MAC OSX 10.10 is above 5.4, feel free to use short tags)
echo "hello php";
?>
Open the browser
type
xxx. com
and try out!
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above introduces how to enable the built-in Apache and PHP under MAC OSX 1010, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.