zoukankan      html  css  js  c++  java
  • MAC 10.10 apache 服务器配置

    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.so
    Include /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!

  • 相关阅读:
    Bit Manipulation
    218. The Skyline Problem
    Template : Two Pointers & Hash -> String process
    239. Sliding Window Maximum
    159. Longest Substring with At Most Two Distinct Characters
    3. Longest Substring Without Repeating Characters
    137. Single Number II
    142. Linked List Cycle II
    41. First Missing Positive
    260. Single Number III
  • 原文地址:https://www.cnblogs.com/fengquanwang/p/4210973.html
Copyright © 2011-2022 走看看