標籤:restart user 目錄 load chown hub cal brew 服務
最簡單直接的方式還是使用 Mac 上內建的 Apache 和 PHP。 1.啟動 Apache1>啟動apache $sudo apachectl start;2>啟動後,在瀏覽器中輸入 localhost ,可以看到頁面上顯示 It works。(/Library/WebServer/Documents/ 下的 index.html.en 檔案)3>Apache 的預設根目錄是 /Library/WebServer/Documents/ 2.添加apache對php的支援1>開啟 http.conf 設定檔: sudo vim /etc/apache2/httpd.conf2>找到以下代碼並去掉注釋(去掉前面的‘#’號), wq 儲存退出。 LoadModule php5_module libexec/apache2/ libphp5.so 3.重啟 Apache,進行php類型檔案的調試重啟: sudo apachectl restart在 Apache 的根目錄 /Library/WebServer/Documents/ 下建立project檔案夾並寫一個php檔案輸出‘hello world‘。此時,在瀏覽器開啟 http://localhost/project/test.php 就可以正常看到hello world 了~(如果有許可權問題, sudo chown yourname:staff project 其中yourname是你自己的名字) 4.使用homebrew安裝mysql安裝homebrewruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"安裝mysqlbrew install mysql啟動mysqlmysql.server start Apache 常用命令 //啟動 Apache 服務 sudo apachectl start// 重新啟動 Apache 服務 sudo apachectl restart // 關閉 Apache 服務 sudo apachectl stop// 查看 Apache 版本 httpd -v
mac系統之php開發環境配置