Home  >  Article  >  Backend Development  >  Enable the built-in Apache and PHP under MAC OSX 1010

Enable the built-in Apache and PHP under MAC OSX 1010

WBOY
WBOYOriginal
2016-08-08 09:20:26991browse

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
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 # blocks below.
218 #
219
220 AllowOverride none
221 # Require all denied
222

Also uncomment line 499 to make apache’s vhost settings take effect

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 content (sheng is my user name, xxx is the virtual domain name I added)

DocumentRoot "/Users/sheng/site/xxx"
ServerName xxx.com
xxx">
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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn