Heim  >  Artikel  >  Backend-Entwicklung  >  MAC OSX 1010 下启用自带的Apache和PHP

MAC OSX 1010 下启用自带的Apache和PHP

WBOY
WBOYOriginal
2016-08-08 09:20:26952Durchsuche

Mac 系统自带Apache和PHP,只要你开启即可使用 

1. 修改Apache配置文件

sudo vim /etc/apache2/httpd.conf。

取消注释掉下面两行

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

LoadModule php5_module libexec/apache2/libphp5.so

注释掉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

另外取消499行的注释,使apache的vhost设置生效

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

添加如下内容(sheng 是我的用户名,xxx是自己添加的虚拟域名)

 
      DocumentRoot "/Users/sheng/site/xxx"
      ServerName xxx.com
      xxx">
          Options FollowSymLinks
          AllowOverride All
          Require all granted
     

3. 修改本机的host设置

vim /etc/hosts

添加一行

 127.0.0.1   xxx.com

4.打开终端命令行

sudo apachectl start。

5. 在/Users/sheng/site/xxx放一个index.php 文件

可以写入如下内容。(MAC OSX 10.10的PHP 版本在5.4以上,放心用 短标签)

echo "hello php";

?>

打开浏览器 

type 

xxx.com

and try out!

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了MAC OSX 1010 下启用自带的Apache和PHP,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:nginx入门之安装Nächster Artikel:phpini的加载位置