字數602 閱讀402 評論0 喜歡1php
Mac系統自帶apache服務器web
sudo apachectl -v
sudo apachectl start
sudo apachectl restart
配置apache
apache的主配置文件在路徑/etc/apache2/下apache
修改httpd.conf 文件瀏覽器
sudo cp /etc/apache2/httpd.conf /etc/apache2/httpd.conf.backup
$vi /etc/apache2/httpd.conf
主要修改內容服務器
//181行 User _www Group _www //改成(rootname爲本機用戶名) User rootname Group wheel //219行 <Directory /> AllowOverride none Require all denied </Directory> //改成(修改apache配置:設置訪問代理資源被默認不受限制) <Directory /> Require all granted AllowOverride all </Directory> //498行 # Virtual hosts #Include /private/etc/apache2/extra/httpd-vhosts.conf //改成(去掉前面的#,這樣就開啓了httpd-vhosts虛擬主機文件) # Virtual hosts Include /private/etc/apache2/extra/httpd-vhosts.conf
sudo cp /etc/apache2/extra/httpd-vhosts.conf /etc/apache2/extra/httpd-vhosts.conf.backup
$sudo vi /etc/apache2/extra/httpd-vhosts.conf
//在文件里加入,前面的例子能夠用# 註釋掉 <VirtualHost *:80> DocumentRoot "項目文檔根目錄" ServerName 服務器名稱 ErrorLog "/private/var/log/apache2/mysites-error_log" CustomLog "/private/var/log/apache2/mysites-access_log" common <Directory "項目文檔根目錄"> Options FollowSymLinks Multiviews Indexes MultiviewsMatch Any AllowOverride None Require all granted </Directory> <Proxy *> Order deny,allow Allow from all </Proxy> // 配置請求轉發服務器 和 環境路徑(反向代理) ProxyPass /web http://example.com/web ProxyPassReverse /web http://example.com/web </VirtualHost>
127.0.0.1 你的網站地址
sudo apachectl restart
補充:iview
// 169行 #LoadModule php5_module libexec/apache2/libphp5.so //修改後(即去掉#註釋) LoadModule php5_module libexec/apache2/libphp5.so