apache绑定二级域名

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache绑定二级域名相关的知识,希望对你有一定的参考价值。

网上文章看了不少,方法也试了很多,都不奏效……
windows平台,希望有能力的朋友帮我解决一下!
加下我Q 369781976,解决后150分献上!
好吧,提到200分. 另外广告自重,有多远死多远。

参考技术A 是绑定一个,还是像Q空间那样地
1.绑定一个 用VHOST
2.像Q空间 用泛解析+Rewrite
参考技术B 你是要在apache里建虚拟主机绑二级域名还是咋滴?解析设置好没?我也是新手,希望和你一起学习~

windows2008 apache2.4 tomcat-7多域名绑定环境配置

=====================软件清单
Apache2.4.33
apache-tomcat-7.0.85
=====================


1.安装apache
    1.1下载apache http://httpd.apache.org/download.cgi
    1.2 下载Visual C++ 2015 x86 ,apache的基础环境 https://www.microsoft.com/en-us/download/details.aspx?id=49984
    1.3 cmd执行httpd.exe -k install安装apache服务
 
2.安装jre
    http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

3.安装tomcat 7.0.85
    http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.85/bin/apache-tomcat-7.0.85.exe

--------------------------
4.下载apache tomcat连接器mod_jk
    https://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/

  4.1拷贝mod_jk.so至modules目录中
  4.2修改apache httpd.conf

修改域名
ServerName javaidea.cn:80

修改默认目录
DocumentRoot "D:/tomcat7/webapps/ROOT"
<Directory "D:/tomcat7/webapps/ROOT">
    Options  FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

 

开启虚拟主机配置

找到#Include conf/extra/httpd-vhosts.conf这句,将之前的#号去掉,开启虚拟主机配置。

 

最后增加
#apache+tomcat config start
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel error
JkMount /* worker1
JKUnmount /*.htm worker1
JKUnmount /*.html worker1
JKUnmount /*.css worker1
JkUnMount /*.gif worker1  
JkUnMount /*.swf worker1  
JkUnMount /*.bmp worker1  
JkUnMount /*.png worker1  
JkUnMount /*.jpg worker1
JkUnMount /*.js worker1
设置为除静态资源 全都转发给tomcat处理

 

4.3增加workers.properties

Apache2.4\conf下新建文件workers.properties并添加内容如下

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009



4.4 apache虚拟主机配置
    Apache24\conf\extra的httpd-vhosts.conf


<VirtualHost _default_:80>
DocumentRoot "D:/tomcat7/webapps/ROOT"
#ServerName www.example.com:80
ServerAlias www.javaidea.cn
JkMountCopy On
</VirtualHost>
# Add any other Virtual Hosts below

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "D:/tomcat7/jzy123/ROOT"
    ServerName jzy123.com
    ServerAlias www.jzy123.com
    ErrorLog "logs/jzy123-error.log"
    CustomLog "logs/jzy123.log" common
    JkMountCopy On
    <Directory "D:/tomcat7/jzy123/ROOT">
        Options  FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>

5.tomcat多域名邦定

修改server.xml

      <Host name="javaidea.cn"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Alias>www.javaidea.cn</Alias>
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="javaidea_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
      </Host>



注:  Options Indexes FollowSymLinks改为Options FollowSymLinks 禁用列出目录

注: (可选)Apache配置虚拟目录,httpd.conf中添加 

Alias /qrcodes "d:/Qrcodes"
<Directory "d:/Qrcodes">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Alias /images "d:/WebImages"
<Directory "d:/WebImages">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Alias /apks "d:/Apks"
<Directory "d:/Apks">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

 

以上是关于apache绑定二级域名的主要内容,如果未能解决你的问题,请参考以下文章

怎么用apache绑定2级域名?

apache 一个ip怎么绑定多个域名不同目录

destoon【已解决】apache下怎么绑定外部模块二级域名(已修改)

linux 下的 apache 绑定多个域名

Linux Apache绑定多域名

自己centos服务器怎么绑定域名