Mac system comes with Apache and PHP, as long as you turn it on and use it
1. Modifying the Apache configuration file
sudo vim/etc/apache2/httpd.conf.
Uncomment the next two lines
LoadModule rewrite_Module Libexec/apache2/mod_rewrite.so
LoadModule Php5_module libexec/apache2/libphp5.so
Comment out 221 lines of #Require all denied
212 #ServerName www.example.com:80
213
214 #
215 # Deny access to the entirety of your server ' s filesystem. You must
216 # explicitly permit access to Web content directories in other
217 # <Directory> blocks below.
218 #
219 <directory/>
allowoverride None
221 # Require All denied
222 </Directory>
Also uncomment 499 lines to make Apache's vhost settings effective
497
498 # Virtual Hosts
499 include/private/etc/apache2/extra/httpd-vhosts.conf
500
501 # Local access to the Apache HTTP Server Manual
502 #Include/private/etc/apache2/extra/httpd-manual.conf
2. Vim/etc/apache2/extra/httpd-vhosts.conf
Add the following (Sheng is my username, xxx is the virtual domain name you added)
<virtualhost *:80>
DocumentRoot "/users/sheng/site/xxx"
ServerName xxx. com
<directory "/users/sheng/site/xxx" >
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
3. Modify the host settings for this computer
Vim/etc/hosts
Add a row
127.0.0.1 xxx.com
4. Open the terminal command line
sudo apachectl start.
5. put a index.php file in /users/sheng/site/xxx
You can write to the following content. (MAC OSX 10.10 php version above 5.4, do not know why the short label is not available by default)
<?php
echo "Hello php";
?>
Open your browser
Type
XXX.com
and try Out!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Enable your own Apache and PHP under MAC OSX 10.10