您的位置:首页 > 编程语言 > PHP开发

How to set up PHP server on Mac OS X 10.8

2012-10-10 16:16 796 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: