MAC 10.10 apache 伺服器配置

來源:互聯網
上載者:User

標籤:

mac中內建了apache伺服器, 如果需要在mac上使用apache伺服器, 只需要配置並啟動伺服器即可。

mac 10.10 中內建的apache版本是 2.4

mac 10.9 中內建的apache版本是2.2

 

1. 啟動伺服器

開啟Terminal, 輸入  sudo apachectl start 即可。

啟動後, 在瀏覽器中輸入http://localhost 就能看到 "It works!"

常用命令:

啟動伺服器:sudo apachectl start

關閉伺服器:sudo apachectl stop

重啟伺服器:sudo apachectl restart

 

2. 配置個人網站

mac內建的apache設定檔放在 /etc/apache2/目錄下

  • 開啟/etc/apache2/httpd.conf,找到下面幾行,去掉開頭的#號
LoadModule userdir_module libexec/apache2/mod_userdir.soInclude /private/etc/apache2/extra/httpd-userdir.conf
  • 開啟/etc/apache2/extra/httpd-userdir.conf,找到下面的內容,去掉開頭的#號
Include /private/etc/apache2/users/*.conf
  • 在/etc/apache2/users檔案夾下,建立一個 fengquan.conf 設定檔(你的使用者名稱是什麼, 紅色的部分就寫什麼)。在檔案中寫入以下內容:(下面的fengquan, 改為你的使用者名稱)
<Directory "/Users/fengquan/Sites/">    Options Indexes MultiViews    AllowOverride None    require all granted</Directory>
  • 建立~/Sites檔案夾, 並在檔案夾下建立一個index.html, 在裡面隨便寫點內容。 
  • 重啟apache伺服器。 sudo apachectl restart

 

3. 支援php

開啟/etc/apache2/httpd.conf,找到下面的內容, 去掉前面的#號

LoadModule php5_module libexec/apache2/libphp5.so

重啟伺服器

 

4. 許可權問題

mac 10.9, apache2.2中, 控制許可權是用的

<Directory "/Users/fengquan/Sites/">    Options Indexes MultiViews    AllowOverride None    Order allow,deny    Allow from all</Directory>

mac 10.10, apache2.4中, 控制許可權改為

<Directory "/Users/fengquan/Sites/">    Options Indexes MultiViews    AllowOverride None    require all granted</Directory>

 

 

enjoy yourself!

 

MAC 10.10 apache 伺服器配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.