運行PHP
安裝MySQL
使用phpMyAdmin
配置PHP的MCrypt擴展庫
設置虛擬主機
啟動Apache
有兩種方法:
打開“系統設置偏好(System Preferences)” -> “***享(Sharing)” -> “Web***享(Web Sharing)”
打開“終端(terminal)”,然後(註意:sudo需要的密碼就是系統的root帳號密碼)
運行“sudo apachectl start”,再輸入帳號密碼,這樣Apache就運行了。
運行“sudo apachectl -v”,會看到Mac OS X 10.6.3中的Apache版本號:
Server version: Apache/2.2.14 (Unix)
Server built: Feb 11 2010 14:40:31
這樣在瀏覽器中輸入“
DocumentRoot "/usr/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
而實際上,這兩個虛擬主機是不存在的,在沒有配置任何其他虛擬主機時,可能會導致訪問localhost時出現如下提示:
Forbidden
You don't have permission to access /index.php on this server
最簡單的辦法就是在它們每行前面加上#,註釋掉就好了,這樣既能參考又不導致其他問題。
增加如下配置
.代碼如下:
<VirtualHost *:80>
DocumentRoot "/Users/[用戶名]/Sites"
ServerName sites
ErrorLog "/private/var/log/apache2/sites-error_log"
CustomLog "/private/var/log/apache2/sites-access_log" common
</VirtualHost>
保存退出,並重啟Apache。
運行“sudo vi /etc/hosts”,打開hosts配置文件,加入”127.0.0.1 sites“,這樣就可以配置完成sites虛擬主機了,這樣就可以用“http://sites”訪問了,其內容和“http://localhost/~[用戶名]”完全壹致。
這是利用Mac OS X 10.6.3中原生支持的方式來實現的配置,也可以參考“Mac OS X Leopard: 配置Apache, PHP, SQLite, MySQL, and phpMyAdmin(壹) ”和“Mac OS X Leopard: 配置Apache, PHP, SQLite, MySQL, and phpMyAdmin(二) ”。