在Mac OS X中可以很方便的通過開啟“Web共用”啟用Apache服務:
設定方法如下:
開啟“系統設定偏好(System Preferences)” -> “共用(Sharing)” -> “Web共用(Web Sharing)”選中即可
啟動Apache
有兩種方法:
開啟“系統設定偏好(System Preferences)” -> “共用(Sharing)” -> “Web共用(Web Sharing)”
開啟“終端(terminal)”,然後(注意:sudo需要的密碼就是系統的root帳號密碼)
運行“sudo apachectl start”,再輸入帳號密碼,這樣Apache就運行了。
這樣在瀏覽器中輸入“http://localhost”,就可以看到出現一個內容為“It works!”的頁面,它位於“/Library(資產庫)/WebServer/Documents/”下,這是Apache的預設根目錄。
系統預設給目前使用者的訪問目錄是http://localhost/~username的形式,指向的是使用者home目錄下的Sites目錄。而很多情況下我們希望直接存取根目錄(http://localhost/)便可直接存取自己的Sites目錄而非系統預設的目錄。
做如下更改即可:
1.開啟/etc/apache2/httpd.conf檔案
sudo vim /etc/apache2/httpd.conf
2.找到
/Library/WebServer/Documents
替換成
/Users/{username}/Sites
其中{username}是你登陸使用者名稱,如:
/Users/liangc/Sites
3.重啟“Web共用(Web Sharing)” (去掉勾再重新選中即可)
或者 運行“sudo apachectl restart”
重啟成功後,無需再加上使用者名稱,便可以使用http://localhost/直接存取自己Sites目錄下的內容
原文:http://blog.csdn.net/chenlia/article/details/7695804
註:
You don’t have permission to access / on this server. 錯誤
開啟apache的設定檔httpd.conf,
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
由於配置了php後,這裡的“Deny from all”已經拒絕了一切串連。把該行改成“allow from all”,修改後的代碼如下,問題解決。
Options FollowSymLinks
AllowOverride None
Order deny,allow
allow from all
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介紹了PHP學習之Apache修改預設網站的目錄,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。