mac os x配置apache和php

本文采用的方式是使用Mac OS X 10.5.8自带的Apache和PHP,安装MySQL的dmg版本,以下操作非特殊说明均以root用户在命令行下进行。 启用root用户 1.打开“目录实用工具”,它位于“应用程序”文件夹的“实用工具”文件夹中。 2.点按锁图标以进行更改。您将需要输入管理员名称和密码。 3.选取“编辑”>“启用 Root 用户”。 4.为 root 用户输入安全密码,然后在“验证”栏再次输入它,最后点按“好”。 启用Apache Mac OS X 10.5.8自带了Apache 2.2.9,直接在命令行运行apachectl start,Apache就搞定了。 现在Apache的主目录就是/Libary/WebServer/Documents/,你可以在这目录里放置文件测试了。 启用PHP Mac OS X 10.5.8自带了PHP 5.2.6,我们需要做的就是将PHP加入Apache中。 修改/etc/apache2/httpd.conf中的 #loadModule php5_module libexec/apache2/libphp5.so 为 loadModule php5_module libexec/apache2/libphp5.so 然后将/etc/php.ini.default复制为/etc/php.ini。 cp /etc/php.ini.default /etc/php.ini 之后就可以按照自己的习惯修改php.ini的配置 比如将error_reporting = E_ALL & ~E_NOTICE 修改为 error_reporting = E_ALL 最后,重启Apache,可以在/Libary/WebServer/Documents/目录中建立个phpinfo.php来测试了。 apachectl restart

2010-04-04 · 1 min · 52 words · kevin

php读取mac地址

1. 2. 3. class GetMacAddress { 4. var $return_array = array(); 5. var $mac_addr; 6. 7. function _construct($os_type) { 8. switch (strtolower($os_type)) { 9. case "linux": 10. $this->forLinux(); 11. break; 12. default: 13. $this->forWindows(); 14. break; 15. } 16. 17. $temp_array = array(); 18. foreach ($this->return_array as $value) { 19. if (preg_match(”/[0-9a-f][0-9a-f][:-]“.”[0-9a-f][0-9a-f][:-]“.”[0-9a-f][0-9a-f][:-]” 20. .”[0-9a-f][0-9a-f][:-]“.”[0-9a-f][0-9a-f][:-]“.”[0-9a-f][0-9a-f]/i”, $value, $temp_array)) { 21. $this->mac_addr = $temp_array[0]; 22. break; 23. } 24. } 25. 26. unset($temp_array); 27. return $this->mac_addr; 28. } 29. 30. function forWindows() { 31. @exec(”ipconfig /all”, $this->return_array); 32. 33. if ($this->return_array) { 34. return $this->return_array; 35. } else { 36. $ipconfig = $_SERVER["SystemRoot"].”\system32\ipconfig.exe”; 37. if (is_file($ipconfig)) { 38. @exec($ipconfig.” /all”, $this->return_array); 39. } else { 40. @exec($_SERVER["WINDIR"].”\system\ipconfig.exe /all”, $this->return_array); 41. } 42. return $this->return_array; 43. } 44. } 45. 46. function forLinux() { 47. @exec(”ifconfig -a”, $this->return_array); 48. return $this->return_array; 49. } 50. } 51. 52. $mac = new GetMacAddress(null); 53. echo $mac->mac_addr; 54. 55. ?>

2010-01-25 · 1 min · 153 words · kevin