Rumah  >  Artikel  >  pembangunan bahagian belakang  >  MAC OSX 1010 下启用自带的Apache和PHP

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

WBOY
WBOYasal
2016-08-08 09:20:26949semak imbas

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教程有兴趣的朋友有所帮助。

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:nginx入门之安装Artikel seterusnya:phpini的加载位置