大旗谷资源网 Design By www.zqyou.com
前提
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 80 Listen 8080
2.2、在文档最后添加端口映射功能
<VirtualHost ExampleIp:8080> DocumentRoot /var/www/html/website3 ServerName ExampleIp:8080 </VirtualHost> <Directory "/var/www/html/website3"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory>
website3为工程目录.配置完使用“service httpd restart”重启Apache
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。
大旗谷资源网 Design By www.zqyou.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
大旗谷资源网 Design By www.zqyou.com
暂无CentOS系统下Apache配置多域名或多端口映射的方法的评论...
更新日志
2024年09月20日
2024年09月20日
- 《真的田震 中国乐坛红极一时的歌者 精品集》[WAV+CUE][300MB]
- 群星.1995-新滚石九大天王之情歌大全【滚石】【WAV+CUE】
- 群星.1993-滚石九大天王十二出好戏·纵夏欢唱【滚石】【WAV+CUE】
- 群星.1993-滚石九大天王十二出好戏·贺岁齐唱【滚石】【WAV+CUE】
- 黑神话悟空上品虫校尉精魄获取方法一览|上品虫校尉精魄收集攻略
- 《指环王:夏尔的传说》推迟至2025年初发行
- 黑神话悟空上品蝎太子精魄获取方法一览|上品蝎太子精魄收集攻略
- 银霞.1977-《台北66电影原声带》台湾复刻版[WAV+CUE]
- 银霞.1980-《你那好冷的小手》台湾珍藏纪念版[WAV+CUE]
- 王菲.2006《菲常好听》引进版[低速原抓WAV+CUE]
- 《三日危情独家的记忆》女角色介绍
- 《天国拯救》拉泰比武大会攻略
- 任天堂推出《马里奥惊奇》NS捆绑包 10月24日发售
- 《孤岛惊魂》能否逆转育碧颓势?曝系列新作正招兵买马
- 天命人呼叫战术轰炸!玩家自制《黑神话:悟空》轰炸机Mod