CentOS系统下Apache怎么配置多域名或多端口映射-创新互联
这篇文章主要介绍“CentOS系统下Apache怎么配置多域名或多端口映射”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“CentOS系统下Apache怎么配置多域名或多端口映射”文章能帮助大家解决问题。
目前成都创新互联已为1000多家的企业提供了网站建设、域名、网站空间、网站托管运营、企业网站设计、沾化网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。前提
centos下apache默认网站根目录为/var/www/html,假如我默认存了一个ci项目在html文件夹里,同时服务器的外网ip为exampleip,因为使用的是mvc框架,apache需开启重定向功能。
方法如下
/etc/httpd/conf/httpd.conf文件配置如下:
documentroot "/var/www/html/ci"
options followsymlinks allowoverride all
# # 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 # /tupian/20230522/core.html # 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
配置完使用“service httpd restart”重启apache,那么直接在浏览器里输入http://exampleip,就直接映射到/var/www/html/ci文件夹里了
1、配置多域名映射。假设需要映射www.website1.com和www.website1.com这两个域名,在文档httpd.conf最后添加
namevirtualhost *:80documentroot /var/www/html/website1 servername http://www.website1.com options indexes followsymlinks allowoverride all order allow,deny allow from all documentroot /var/www/html/website1 servername http://website1.com options indexes followsymlinks allowoverride all order allow,deny allow from all documentroot /var/www/html/website2 servername http://www.website2.com options indexes followsymlinks allowoverride all order allow,deny allow from all documentroot /var/www/html/website2 servername http://website2.com options indexes followsymlinks allowoverride all order allow,deny allow from all
website1和website2为工程目录.配置完使用“service httpd restart”重启apache
2、配置多端口映射。
2.2、首先需要监听端口,在文档httpd.conf的listen 80下添加需要监听的端口,举例为8080
listen 80 listen 8080
2.2、在文档最后添加端口映射功能
documentroot /var/www/html/website3 servername exampleip:8080 options indexes followsymlinks allowoverride all order allow,deny allow from all
website3为工程目录.配置完使用“service httpd restart”重启apache
关于“CentOS系统下Apache怎么配置多域名或多端口映射”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注创新互联行业资讯频道,小编每天都会为大家更新不同的知识点。
本文名称:CentOS系统下Apache怎么配置多域名或多端口映射-创新互联
网页URL:http://azwzsj.com/article/cscspe.html