這篇文章主要介紹“CentOS系統(tǒng)下Apache怎么配置多域名或多端口映射”的相關(guān)知識(shí),小編通過(guò)實(shí)際案例向大家展示操作過(guò)程,操作方法簡(jiǎn)單快捷,實(shí)用性強(qiáng),希望這篇“CentOS系統(tǒng)下Apache怎么配置多域名或多端口映射”文章能幫助大家解決問(wèn)題。
目前成都創(chuàng)新互聯(lián)已為1000多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)站空間、網(wǎng)站托管運(yùn)營(yíng)、企業(yè)網(wǎng)站設(shè)計(jì)、沾化網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。前提
centos下apache默認(rèn)網(wǎng)站根目錄為/var/www/html,假如我默認(rèn)存了一個(gè)ci項(xiàng)目在html文件夾里,同時(shí)服務(wù)器的外網(wǎng)ip為exampleip,因?yàn)槭褂玫氖莔vc框架,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、配置多域名映射。假設(shè)需要映射www.website1.com和www.website1.com這兩個(gè)域名,在文檔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、首先需要監(jiān)聽端口,在文檔httpd.conf的listen 80下添加需要監(jiān)聽的端口,舉例為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
關(guān)于“CentOS系統(tǒng)下Apache怎么配置多域名或多端口映射”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,小編每天都會(huì)為大家更新不同的知識(shí)點(diǎn)。