字数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