设置虚拟主机

  1. 在终端运行“sudo vi /etc/apache2/httpd.conf”,打开Apche的配置文件
  2. 在httpd.conf中找到“#Include /private/etc/apache2/extra/httpd-vhosts.conf”,去掉前面的“#”,并去掉/private,不用去private里那个设置,保存并退出。
  3. 运行“sudo apachectl restart”,重启Apache后就开启了虚拟主机配置功能。
  4. 运行“sudo vi /etc/apache2/extra/httpd-vhosts.conf”,就打开了配置虚拟主机文件httpd-vhost.conf,配置虚拟主机了。需要注意的是该文件默认开启了两个作为例子的虚拟主机:
  1. <VirtualHost *:80>
  2. ServerAdmin webmaster@dummy-host.example.com
  3. DocumentRoot "/usr/docs/dummy-host.example.com"
  4. ServerName dummy-host.example.com
  5. ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
  6. CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
  7. </VirtualHost>

  8. 
<VirtualHost *:80>
  9. ServerAdmin webmaster@dummy-host2.example.com
  10. DocumentRoot "/usr/docs/dummy-host2.example.com"
  11. ServerName dummy-host2.example.com
  12. ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
  13. CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
  14. </VirtualHost>

而实际上,这两个虚拟主机是不存在的,在没有配置任何其他虚拟主机时,可能会导致访问localhost时出现如下提示.

  1. Forbidden
  2. You don't have permission to access /index.php on this server

最简单的办法就是在它们每行前面加上#,注释掉就好了,这样既能参考又不导致其他问题。

增加如下配置

<VirtualHost *:80>
#ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/Users/admin/wang/djangoprojects/ai123"
ServerName www.vai123.ai
ServerAlias vai123.ai
WSGIScriptAlias / /Users/admin/wang/djangoprojects/ai123/ai123/wsgi_local.py
Alias /static/ /Users/admin/wang/djangoprojects/ai123/static/
Alias /uploads/ /Users/admin/wang/djangoprojects/ai123/uploads/
<Directory "/Users/admin/wang/djangoprojects/ai123">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ErrorLog "/var/log/apache2/vai123.ai-error_log"
# CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>

mac apache配置虚拟主机的更多相关文章

  1. 【转】Apache 配置虚拟主机三种方式

    Apache 配置虚拟主机三种方式  原文博客http://www.cnblogs.com/hi-bazinga/archive/2012/04/23/2466605.html 一.基于IP 1. 假 ...

  2. apache配置虚拟主机后,启动速度慢

    apache配置虚拟主机后,启动速度慢且提示“the requested operation has failed” 可以通过在cmd下启动,来查找问题(命令中的“apache2.2”,是服务名,根据 ...

  3. apache配置虚拟主机的三种方式

    Apache 配置虚拟主机三种方式   一.基于IP 1. 假设服务器有个IP地址为192.168.1.10,使用ifconfig在同一个网络接口eth0上绑定3个IP: [root@localhos ...

  4. lamp apache配置虚拟主机

    You don't have permission to access /index.php on this server

  5. Apache配置虚拟主机后让其他电脑访问

    关于Apache配置虚拟主机后在局域网中让其他电脑访问 #test1# NameVirtualHost *:80         ServerName  www.t1.com     Document ...

  6. [Linux]Apache配置虚拟主机

    Apache 配置虚拟主机的方式很多,种类也很多,主要分为两类:   基于名称的虚拟主机 (每个 IP 多个站点) 基于 IP 的虚拟主机 (每个 IP 一个站点) 基于名称的虚拟主机:  www.2 ...

  7. windows环境利用apache 配置虚拟主机

    windows环境利用apache 配置虚拟主机 1.改动http.host #LoadModule vhost_alias_module modules/mod_vhost_alias.so #In ...

  8. apache配置虚拟主机

    步骤如下: 1.在配置文件httpd.conf中启用httpd-vhosts.conf 找到# Virtual hosts将Include conf/extra/httpd-vhosts.conf前的 ...

  9. Apache配置虚拟主机后,不能访问localhost的问题

    今天想试用一下php7,但是发现php7只支持Apache2.4版本,而我电脑上的Apache是2.2版本,为了想尝鲜,就必须去下载新的Apache2.4 php7和apache2.4安装整合以后,l ...

随机推荐

  1. python 提交form-data之坑

    #coding=utf-8 import requests from requests_toolbelt import MultipartEncoder #requests库上传 files = {& ...

  2. selenium - Js处理滚动条操作

    # 11.Js处理滚动条操作 driver.execute_script('arguments[0].scrollIntoView();',target) target 为find_element_b ...

  3. dev c++ 提示没有iostream.h文件

    dev c++ 提示没有iostream.h文件 解决办法路径没有打通最好是这样写:#include <iostream>using namespace std;int main(int ...

  4. TransH中的Hinge Loss Function

    Hinge Loss Function Hinge Loss 函数一种目标函数,有时也叫max-margin objective. 在Trans系列中,有一个 \[ \max(0,f(h,r,t) + ...

  5. Leetcode 433.最小基因变化

    最小基因变化 一条基因序列由一个带有8个字符的字符串表示,其中每个字符都属于 "A", "C", "G", "T"中的任 ...

  6. Django创建并连接数据库(实现增删改查)--第二版

    注意点一: url里面的地址,不只是html页面,准确说是views视图里面对应的函数方法 <!DOCTYPE html> <html lang="en"> ...

  7. TOJ1840: Jack Straws 判断两线段相交+并查集

    1840: Jack Straws  Time Limit(Common/Java):1000MS/10000MS     Memory Limit:65536KByteTotal Submit: 1 ...

  8. 算法golang篇

    1.slice反转,偏移 func reverse(s []int) { , len(s) - ; i < j; i, j = i+, j- { s[i], s[j] = s[j], s[i] ...

  9. NOJ——1559Jump to the Top of Mountain(简单暴力DFS+渣渣代码)

    [1559] Jump to the Top of Mountain 时间限制: 1000 ms 内存限制: 65535 K 问题描述 Have you played a game named Min ...

  10. 两种KMP题+KMP模版整理

    最近稍微看了下KMP,不是很懂他们大神的A题姿势,但是模版总该还是要去学的. 其中next数组的求法有两处区别. 第一种:求主串中模式串的个数.HDU2087 剪花布条和HDU4847 Wow! Su ...