濮阳杆衣贸易有限公司

主頁 > 知識庫 > mac os apache 配置方法詳細介紹

mac os apache 配置方法詳細介紹

熱門標簽:南昌語音外呼系統(tǒng)代理 長春外呼系統(tǒng)價格 美圖手機 成都移動外呼系統(tǒng) 南寧智能外呼系統(tǒng)線路商 電銷機器人的效果 佛山外呼系統(tǒng)平臺 聯(lián)客智能語音外呼系統(tǒng)賬號格式 長沙智能外呼系統(tǒng)中心
我使用的Mac OS X版本是10.8.2,Mac自帶了Apache環(huán)境。
啟動Apache
設置虛擬主機

啟動Apache
打開“終端(terminal)”,輸入 sudo apachectl -v,(可能需要輸入機器秘密)。如下顯示Apache的版本
 
接著輸入 sudo apachectl start,這樣Apache就啟動了。打開Safari瀏覽器地址欄輸入 “http://localhost”,可以看到內容為“It works!”的頁面。其位于“/Library(資源庫)/WebServer/Documents/”下,這就是Apache的默認根目錄。
Apache的安裝目錄在:/etc/apache2/,etc默認是隱藏的。有三種方式查看:
1.dock下右鍵Finder,選擇"前往文件夾",輸入"/etc"
2.在finder下----》前往---》前往文件夾,然后輸入/etc
3.可以在terminal 輸入 "open /etc"

設置虛擬主機
1.在終端運行“sudo vi /etc/apache2/httpd.conf”,打開Apche的配置文件
2.在httpd.conf中找到“#Include /private/etc/apache2/extra/httpd-vhosts.conf”,去掉前面的“#”,保存并退出。
3.運行“sudo apachectl restart”,重啟Apache后就開啟了虛擬主機配置功能。
4.運行“sudo vi /etc/apache2/extra/httpd-vhosts.conf”,就打開了配置虛擬主機文件httpd-vhost.conf,配置虛擬主機了。需要注意的是該文件默認開啟了兩個作為例子的虛擬主機:

復制代碼
代碼如下:

VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
/VirtualHost>
VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
/VirtualHost>

而實際上,這兩個虛擬主機是不存在的,在沒有配置任何其他虛擬主機時,可能會導致訪問localhost時出現(xiàn)如下提示:
Forbidden
You don't have permission to access /index.php on this server最簡單的辦法就是在它們每行前面加上#,注釋掉就好了,這樣既能參考又不導致其他問題。
5.增加如下配置

復制代碼
代碼如下:

VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents"
ServerName localhost
ErrorLog "/private/var/log/apache2/localhost-error_log"
CustomLog "/private/var/log/apache2/localhost-access_log" common
/VirtualHost>
VirtualHost *:80>
DocumentRoot "/Users/snandy/work"
ServerName mysites
ErrorLog "/private/var/log/apache2/sites-error_log"
CustomLog "/private/var/log/apache2/sites-access_log" common
Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
/Directory>
/VirtualHost>

保存退出,并重啟Apache。
6.運行“sudo vi /etc/hosts”,打開hosts配置文件,加入"127.0.0.1 mysites",這樣就可以配置完成sites虛擬主機了,可以訪問“http://mysites”了,在10.8之前Mac OS X版本其內容和“http://localhost/~[用戶名]”完全一致。
7.注意,記錄log的“ErrorLog "/private/var/log/apache2/sites-error_log"”也可以刪掉,但記錄日志其實是一個好習慣,在出現(xiàn)問題時可以幫助我們判斷。如果保留這些log代碼,一定log文件路徑都是存在的,如果隨便修改一個不存在的,會導致Apache無法服務而沒有錯誤提示,這個比較惡心。

標簽:法律服務 慶陽 沈陽 東營 新鄉(xiāng) 阜陽 邵陽 云浮

巨人網絡通訊聲明:本文標題《mac os apache 配置方法詳細介紹》,本文關鍵詞  mac,apache,配置,方法,詳細,;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《mac os apache 配置方法詳細介紹》相關的同類信息!
  • 本頁收集關于mac os apache 配置方法詳細介紹的相關信息資訊供網民參考!
  • 推薦文章
    库尔勒市| 桂阳县| 武冈市| 呼伦贝尔市| 揭西县| 韩城市| 措美县| 怀集县| 南昌县| 贺兰县| 微山县| 阿拉善盟| 商南县| 法库县| 余庆县| 化德县| 双流县| 和田县| 娱乐| 仪征市| 金华市| 婺源县| 涡阳县| 广水市| 汝州市| 中西区| 广宗县| 基隆市| 云南省| 衡阳县| 苏尼特右旗| 盐城市| 孝义市| 咸宁市| 建昌县| 出国| 苏州市| 阜南县| 盱眙县| 乐业县| 涪陵区|