MAC为Apache2服务器配置多个虚拟主机
Mac 下自带的 Apache 配置
参考:
http://www.cnblogs.com/snandy/archive/2012/11/13/2765381.html
设置虚拟主机
- 在终端运行“
sudo vi /etc/apache2/httpd.conf”,打开Apche的配置文件 #LoadModule rewrite_module modules/mod_rewrite.so改为 LoadModule rewrite_module modules/mod_rewrite.so<Directory />AllowOverride None 改为 AllowOverride All
Require all denied
</Directory>- 在httpd.conf中找到“
#Include /private/etc/apache2/extra/httpd-vhosts.conf”,去掉前面的“#”,保存并退出。 - 运行“
sudo apachectl restart”,重启Apache后就开启了虚拟主机配置功能。 - 运行“
sudo vi /etc/apache2/extra/httpd-vhosts.conf”,就打开了配置虚拟主机文件httpd-vhost.conf,配置虚拟主机了。需要注意的是该文件默认开启了两个作为例子的虚拟主机:123456789101112131415<VirtualHost*:80>ServerAdmin webmaster@dummy-host.example.comDocumentRoot "/usr/docs/dummy-host.example.com"ServerName dummy-host.example.comErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common</VirtualHost><VirtualHost*:80>ServerAdmin webmaster@dummy-host2.example.comDocumentRoot "/usr/docs/dummy-host2.example.com"ServerName dummy-host2.example.comErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common</VirtualHost>而实际上,这两个虚拟主机是不存在的,在没有配置任何其他虚拟主机时,可能会导致访问localhost时出现如下提示:
- Forbidden
- You don't have permission to access /index.php on this server
最简单的办法就是在它们每行前面加上#,注释掉就好了,这样既能参考又不导致其他问题。
- 增加如下配置
12345678910111213141516171819
<VirtualHost*:80>DocumentRoot "/Library/WebServer/Documents"ServerName localhostErrorLog "/private/var/log/apache2/localhost-error_log"CustomLog "/private/var/log/apache2/localhost-access_log" common</VirtualHost><VirtualHost*:80>DocumentRoot "/Users/snandy/work"ServerName mysitesErrorLog "/private/var/log/apache2/sites-error_log"CustomLog "/private/var/log/apache2/sites-access_log" common<Directory/>Options Indexes FollowSymLinks MultiViewsAllowOverride NoneOrder deny,allowAllow from all</Directory></VirtualHost>保存退出,并重启Apache。
- 运行“
sudo vi /etc/hosts”,打开hosts配置文件,加入"127.0.0.1 mysites",这样就可以配置完成sites虚拟主机了,可以访问“http://mysites”了
ServerName www.域名.com
DocumentRoot "/var/www/项目/public"
<Directory "/var/www/项目/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
httpd.conf最后一行加入
IncludeOptional conf.d/*.conf,
重启apache:systemctl restart httpd.service
MAC为Apache2服务器配置多个虚拟主机的更多相关文章
- Linux服务器配置多台虚拟主机
2016年11月4日15:59:12 LAMP环境 参考:http://blog.itblood.com/nginx-same-ip-multi-domain-configuration.html 在 ...
- Apache2.4.6 添加虚拟主机
apache2.4 与 apache2.2 的虚拟主机配置写法有所不同 apache2.2的写法: <VirtualHost *:80> ServerName domain.com Doc ...
- apache-2.4.12之虚拟主机配置问题与觖决办法
apache-2.4.12基于域名访问的多虚拟主机配置 原始配置: <VirtualHost *:80> ServerAdmin kk@etiantian.org DocumentRoot ...
- Apache2.4.6添加虚拟主机提示:NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/extra/httpd-vhosts.conf
[root@localhost conf]# service httpd restart 停止 httpd: [确定] 启动 httpd:AH00548: NameVirtualHost has no ...
- 【 APACHE 】 Apache2.4.x版本虚拟主机配置
今天准备使用apache搭建一个目录浏览的服务,折腾了一下. apache2.4.x以后的版本: Require all granted 代替了apache2.4.x以前版本: Order Allow ...
- apache2.2 虚拟主机配置详解
一.修改httpd.conf 打开appserv的安装目录,找到httpd.conf文件,分别去掉下面两行文字前面的#号. #LoadModule vhost_alias_module modules ...
- Ubuntu Server 14.04 & Apache2.4 虚拟主机、模块重写、隐藏入口文件配置
环境: Ubuntu Server 14.04 , Apache2.4 一.Apache2.4 虚拟主机配置 01. 新建一份配置文件 在apache2.4中,虚拟主机的目录是通过/etc/apach ...
- ubuntu下安装配置apache2(含虚拟主机配置)
在Ubuntu14.14中安装apache 安装指令: sudo apt-get install apache2 安装结束后: 产生的启动和停止文件是: /etc/init.d/apache2 启动: ...
- 烂泥:apache虚拟主机的学习与应用
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 要配置apache的虚拟主机,我们需要分以下几步进行: 1. 检查apache虚拟主机模块 2. 开启apache虚拟主机功能 3. httpd-vho ...
随机推荐
- mydql 函数和存储过程
存储过程 CREATE PROCEDURE getUid (IN phone CHAR(11), OUT uid INT ) READS SQL DATA BEGIN select u.id from ...
- rpc框架画 和spring cloud流程图
- linux程序对比
- JAVA中AES对称加密和解密以及与Python兼容
引言:本文主要解决Java中用AES加密及解密,同时可通过Python脚本对Java加密后的字符进行解密的操作. 由于近期工作中用到需要使用Java对一串密钥进行加密,并且后台通过Python语言读取 ...
- CentOs Linux 对于 修改 yum源 为 阿里
修改yum源为阿里 备份本地yum源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak 2.获取阿里 ...
- Linux下安装LoaderRunner LoaderGenerator
Linux负载机上安装LR的理由: 1.windows系统,基本上每个vuser会消耗2-5M的内存,单机300-500或者更多的虚拟用户时,CPU占用率已经较高,此时整个测试环境的测试系统的瓶颈实际 ...
- cmake学习笔记之add_library、target_link_libraries和link_directories
cmake是Linux(这里默认是Ubuntu系统)下常使用的编译C++的工具,而使用cmake就需要先在CmakeLists.txt文件中对编译规则进行.这里介绍常用的三种指令add_library ...
- python瞎练
需求:有不规则列表 singlelist3 = [ '总计', '每吨人工:', '总人工', 1748.07, '金额'],如果当前元素为字符串且该元素的下一个相邻位置仍为字符串,那么请在该元素后面 ...
- python一些方便excel行操作的函数(一)
import collections class headhandler(): def __init__(self,mylist): self.mystorage={} self.mylist = m ...
- [RxJS] RxJS Advanced Patterns Operate Heavily Dynamic UIs
Check the playground. import {Counter, CountDownState, ConterStateKeys, PartialCountDownState} from ...