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. ReportViewer中修改rdlc图表中显示的数据

    将rdlc以xml的格式打开,修改里面的数据,实现方式如下: public MemoryStream GenerateRdlc()    { XmlDocument xmlDoc = new XmlD ...

  2. entity framework 数据加载三种方式的异同(延迟加载,预加载,显示加载)

    三种加载方式的区别 显示加载: 显示加载

  3. JavaScript 立即执行函数

    js中(function(){…})()立即执行函数写法理解 javascript和其他编程语言相比比较随意,所以javascript代码中充满各种奇葩的写法,有时雾里看花,当然,能理解各型各色的写法 ...

  4. google 版本号49之后chrome的跨域设置

  5. angularjs compile和link

    原文:http://www.cnblogs.com/GoodPingGe/p/4361354.html ************************************************ ...

  6. less和sass

    sass 总体来说应用是和less差不多的,但是也有所不同     sass是用“$”符号来命名 然后加值来先引入后使用的方式.     同时也应该注意到的是sass有两种后缀名文件:一种后缀名为sa ...

  7. SSH基于Hibernate eventListener 事件侦听器的操作日志自动保存到数据库

    在spring xml配置文件中添加配置,包含:model.listener 在model中增加需要写入数据库对应表的model 在auditLog.xml配置文件中配置自己项目中,需要进行日志记录的 ...

  8. .net 创建计划任务开机后自动以管理员身份启动运行 win7 ~ win10

    假如要启动 this.exe.以下逻辑中会启动先后关联启动三个实例分别是ABC.先启动第一个实例A,A启动实例B,B启动实例C. 要求: 1.如果没有以管理员权限运行,则请求管理员权限运行,即使没有请 ...

  9. Web前端MVC框架

    MVC: 模型层(model).视图层(view).控制层(controller) Model:即数据模型,用来包装和应用程序的业务逻辑相关的数据或者对数据进行处理,模型可以直接访问数据. View: ...

  10. oracle rac安装

    http://blog.chinaunix.net/xmlrpc.php?r=blog/article&id=4681351&uid=29655480 参考 1.百度文库中的收藏 2. ...