PHP學習之Apache修改預設網站的目錄

來源:互聯網
上載者:User
在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教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.