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. linux进程命令

    1. ps命令 命令 命令名称: 命令名称: ps 功能: 功能: 查询正在执行的进程 语法: 可选参数] 语法: ps [可选参数] 描述: 命令提供 命令提供Linux系统中正在发生的事情的   ...

  2. Spring Application Event Example

    Spring Application Event 项目结构 工程下载 https://github.com/xiaoheike/SpringApplicationEventExample.git Sp ...

  3. 105 董婷婷 第一次Sprint总结

    总结: 经过一个多星期,第一次Sprint在今天结束了,在这次Sprint中我们的工作主要做的是对项目的构建及各种界面的设计和完善,一些比较具体的功能还没有实现.在这次Sprint中因为有上学期合作的 ...

  4. java基础小知识

    1.1常量: 基本数据类型常量 字符常量 整数常量的表现形式:一进制的形式来表示(二进制,八进制,十进制,十六进制) 生活中:十进制(0-9)  ,星期(七进制(0-6)) ,时间(十二进制(0-11 ...

  5. while做法1.兔子生兔子 2.求100以内质数的和3.洗发水15元 牙膏5元 香皂2元 150元的算法

    1.兔子生兔子 2.求100以内质数的和 3.150块钱花完问题

  6. DrawableLayout

    提供一个在窗口顶层显示,可从窗口边缘拖出的container组件. DrawableLayout本身作为整个容器,先进行默认显示内容的布局,再进行拖出菜单的内容布局.也就是一个DL包含两个或三个子控件 ...

  7. mysql 根据某字段特定值排序

    比如: 表 :user 字段:orders (值为 1,2,3) 要求根据字段  orders 按2 -> 1 -> 3 排序 使用以下语句实现SELECT *FROM userORDER ...

  8. Todo List

    Contest 11.13 2016ACM/ICPC亚洲区青岛站(5/13, solved 7/13) Training 11.06 2016年中国大学生程序设计竞赛(合肥)(solved 6/10) ...

  9. 前端基础 JavaScript~~~ 数据处理 奇技淫巧!!!!!!

    常用的JS数据处理手段      2016-09-21          17:40:07 1.   number类型  数组中取出里面的最大/最小值: // 数组中取出 最小值 [数值] var n ...

  10. multithreading - Reader/Writer Locks in C++

    You Only Need To Note This: only 1 single thread can acquire an upgrade_lock at one time. others are ...