How to set up PHP server on Mac OS X 10.8

In Mac OS X 10.8 version, Apple delete the web sharing function in System Preferences. But this version of operating system has pre-install a version of PHP server. 

So at first, we can start PHP service by using command in Terminal.

sudo apachectl start

The terminal doesn't give us any prompt. 

But after this step, we can use another command to look up the version of PHP server.

apachectl -v
The Terminal will give us a prompt.

Server version: Apache/2.2.22 (Unix)
Server built:   Aug 24 2012 17:16:58

Then we can open the browser and type http://localhost.

we will find a homepage, which default set by PHP server.

If we use "http://localhost" url to access our web server, it means we access to the computer directory, which is /Library/WebServer/Documents.  This is called System Web Level Root. But if we want to use the traditional version such as we used in Mac OS X 10.7 and before, we should change some configuration in this version.

I try to find a mount of resource to do this thing. But nothing worked in my MAC Pro. 

At last, I find a APPLESCRIPT to auto change all the configuration aim to get the User Level Root.

set userHome to (short user name of (system info))
set configFile to "/etc/apache2/users/" & userHome & ".conf"
set configFileContents to "<Directory \"/Users/" & userHome & "/Sites/\">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>"

do shell script "echo '" & configFileContents & "' > " & configFile with administrator privileges
do shell script "/usr/sbin/apachectl restart" with administrator privileges

Actually, I didn't find any difference between this APPLESCRIPT and my manual configuration. 

But only this type of script can work!!!!!!


I don't know why.

At last I will put the resource that I find and follow. But this article didn't give me any help!!

If somebody find the difference between this two methods, please let me know.

Thank you very much.

REFERENCE

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值