Mac中设置apache

Mac中Apache的目录在 /etc/apache2

设置虚拟主机

1 修改 /etc/apache2 下的文件 httpd.conf

#Include /private/etc/apache2/extra/httpd-vhosts.conf

去掉前面的注释

2 修改 /etc/apache2/httpd-vhost.conf


    ServerAdmin mysite
    DocumentRoot "/Users/nine/ff.mc/dev-static" #目录
    ServerName mysite
    #ServerAlias www.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
     
        Options Indexes FollowSymLinks
            AllowOverride All
            Order allow,deny
        Allow from all
      

3 硬解析里加 127.0.0.1 mysite

访问时候出现了403 Forbidden (:зゝ∠),改下权限
httpd.conf文件


    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all

因为访问的文件是带有php的html文件

LoadModule php5_module libexec/apache2/libphp5.so
AddType application/x-httpd-php .html .htm .php .phtml 

中间还有一直没有办法访问页面,sudo /usr/sbin/httpd -k start显示

httpd: Syntax error on line 131 of /private/etc/apache2/httpd.conf: LoadModule takes two arguments, a module name and the name of a shared object file to load it from

然后把那行注释了就又可以了 (:зゝ∠)

命令行

sudo apachectl stop
sudo apachectl restart

你可能感兴趣的:(Mac中设置apache)