CentOS下Apache默认网站根目录为/var/www/html,假如我默认存了一个CI项目在html文件夹里,同时服务器的外网IP为ExampleIp,因为使用的是MVC框架,Apache需开启重定向功能。

/etc/httpd/conf/httpd.conf文件配置如下:

DocumentRoot "/var/www/html/CI"
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory "/var/www/html/CI">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks #
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All #
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all </Directory>

配置完使用“service httpd restart”重启Apache,那么直接在浏览器里输入http://ExampleIp,就直接映射到/var/www/html/CI文件夹里了

1、配置多域名映射。假设需要映射www.website1.com和www.website1.com这两个域名,在文档httpd.conf最后添加

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/website1
ServerName http://www.website1.com
</Virtualhost>
<Directory "/var/www/html/website1">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<VirtualHost *:80>
DocumentRoot /var/www/html/website1
ServerName http://website1.com 
</Virtualhost>
<Directory "/var/www/html/website1">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<VirtualHost *:80>
DocumentRoot /var/www/html/website2
ServerName http://www.website2.com
</Virtualhost>
<Directory "/var/www/html/website2">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<VirtualHost *:80>
DocumentRoot /var/www/html/website2
ServerName http://website2.com 
</Virtualhost>
<Directory "/var/www/html/website2">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

website1和website2为工程目录.配置完使用“service httpd restart”重启Apache

2、配置多端口映射。

2.2、首先需要监听端口,在文档httpd.conf的Listen 80下添加需要监听的端口,举例为8080

Listen
Listen

2.2、在文档最后添加端口映射功能

<VirtualHost ExampleIp:>
DocumentRoot /var/www/html/website3
ServerName ExampleIp:
</VirtualHost>
<Directory "/var/www/html/website3">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

website3为工程目录.配置完使用“service httpd restart”重启Apache

参考:CentOS下Apache配置多域名或者多端口映射

CentOS下Apache配置多域名或者多端口映射的更多相关文章

  1. Windows下 wamp下Apache配置虚拟域名

    安装好wamp后  找到 找到  Include conf/extra/httpd-vhosts.conf   去掉前面的#   并保存 修改 DocumentRoot  和  ServerName ...

  2. Debian下Apache配置多域名访问

    请见Github博客:http://wuxichen.github.io/Myblog/php/2014/10/10/DebianApacheSetting.html

  3. Windows下Apache配置多域名项目

    <VirtualHost www.a.com:80> DocumentRoot "C:\object\a\web" ServerName http://www.a.co ...

  4. Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)

    Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)   关于LAMP的各种知识,还请大家自行百度谷歌,在这里就不详细的介绍了,今天主要是介绍一下在Centos下安装,搭建一 ...

  5. CentOS下apache绑定域名

    本文主要介绍在CentOS下apache绑定域名以及apache绑定多个域名,首先要找到apache的配置文件httpd.conf的位置.CentOS操作系统一般在 /etc/httpd/conf 下 ...

  6. CentOS下Apache开启Gzip网页压缩功能

    1.进入/etc/httpd/conf下打开httpd.conf文件 开启Gzip压缩功能,即去掉LoadModule deflate_module modules/mod_deflate.so这行前 ...

  7. win7下IIS配置以及域名映射方法

    win7下IIS配置以及域名映射方法 第一步:打开控制面板,选择程序与功能,如下图: 第二步:双击打开程序与功能面板,如下图: 第三步:打开”打开或关闭windows功能”(红线圈起来的地方),如下图 ...

  8. centos下apache安装后无法访问

    2013.11.28遇到的问题: -------------------------------------- 一.centos下apache安装后无法访问 得查一下防火墙的问题 iptables添加 ...

  9. centos下 Apache、php、mysql默认安装路径

    centos下 Apache.php.mysql默认安装路径 http://blog.sina.com.cn/s/blog_4b8481f70100ujtp.html apache: 如果采用RPM包 ...

随机推荐

  1. 图片上传安全性问题,根据ContentType (MIME) 判断其实不准确、不安全

    图片上传常用的类型判断方法有这么几种---截取扩展名.获取文件ContentType (MIME) .读取byte来判断(这个什么叫法来着?).前两种都有安全问题.容易被上传不安全的文件,如木马什么的 ...

  2. ReportViewer改变图表类型

    /// <summary>    /// 切换成柱状图    /// </summary>    /// <param name="sender"&g ...

  3. the django travel(two)

    一:django路由系统: 注意:我们在urls.py中 定义url的时候,可以加$和不加$,区别的是:加$正则匹配的时候,比如:'/index/$'只能匹配'/index/'这样的url 不能匹配' ...

  4. C#基础——系统登录功能的实现

    一般的登陆界面,都是利用用户名和密码在数据库的匹配关系,来实现登陆的跳转功能. 首先介绍用户数据表的设计. 其中ID列需要设置好增量标识,随着用户的增加,ID的值递增,避免重复. 然后是C#中对数据库 ...

  5. Eclipse “cannot be resolved to a type” 错误

    eclipse中遇到了“XX cannot be resolved to a type”的报错信息.网上找了些资料,本文将做以简单总结.     (1)jdk不匹配(或不存在) 项目指定的jdk为“j ...

  6. 浅谈JavaScript eval() 函数

    用js的人都应该知道eval()函数吧,虽然该函数用的极少,但它却功能强大,那么问题来了,为什么不常用呢?原因很简单,因为eval()函数是动态的执行其中的字符串,里面有可能是脚本,那么这样的话就有可 ...

  7. 关于<head></head>标签;<form></form>标签

    <head> <title>此处写标题</title> 这是唯一能被用户看到的标记 <meta/>标签: 1.设置字符集:<meta http-e ...

  8. tomcat 7.0 之文件配置

  9. PS中的图像知识

    图像处理对于前端工作来说是一个不能回避的问题,ps技术也是我们必备的技能.用法可以在使用中不断的熟练,但针对前端技术本身的一些知识点,需要我们平时不断的积累才能够在使用中不出现问题. 如今的办公,已经 ...

  10. 点击每个li节点,都弹出其文本值及修改

    点击每个li节点,都弹出其文本值 1,获取所有的li节点 var liNodes=document.GetElementsByTagName("li"); 2,使用for循环进行遍 ...