apache搭载多个tomcat
2016-07-19 17:20
411 查看
在ubuntu环境下
1.下载apache2 ,这里使用apt-get下载安装
apt-get insall apache2
2.安装tomcat
从网上找可用的tomcat 包,解压即可
3.配置java 环境
apt-get install openjdk-7-jre
文件大约300多M,下载完成用 java -version查看版本信息。在这里,我没有配置.bash_profile文件但最好也可以正常运行。
4.加载各种模块
#代理核心模块
a2enmod proxy
#代理AJP模块
a2enmod proxy_ajp
#代理负载均衡模块
a2enmod proxy_balancer
#代理HTTP模块
a2enmod proxy_http
前面将软件和环境基本安装配置好,下面配置apahce2 文件。apache2 主要有以下几个文件需要配置:
1.envvars文件
把tomcat 文件名和网站名一一对应写好
export WWW_HOME="/home/root"
export xiexie_ROOT="$WWW_HOME/tomcat8-xiexie/webapps/ROOT"
export nihao_ROOT="$WWW_HOME/tomcat8-nihao/webapps/ROOT"
export 333333_ROOT="$WWW_HOME/tomcat8-33333/webapps/ROOT"
2.sites-available里的conf文件
新建一个001-nihao.conf,这个conf所配置的内容对应的是名字为tomcat8-nihao的那个tomcat
<Directory ${nihao_ROOT}>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
Options -Indexes
</Directory>
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName nihao.abc.com
ServerAlias abc.com
ProxyPass / ajp://127.0.0.1:8009/
ProxyPassReverse / ajp://127.0.0.1:8009/
ServerAdmin webmaster@localhost
DocumentRoot ${nihao_ROOT}
DirectoryIndex index.html index.htm index.jsp
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/nihao-error.log
CustomLog ${APACHE_LOG_DIR}/nihao-access.log combined
#RewriteEngine on
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
3.在 site-enabled文件里创建 site-available 里conf文件的软链接
ln -s ../site-available/001-nihao.conf 001-nihao.conf
关于apache2 的配置就是以上
tomcat的配置
1.在tomcat 目录下修改conf/server.xml
server port 每个tomcat 都要不同防止冲突
<Server port="8025" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
Connector port 要与apache 里.conf 要对应
<Connector port="8029" protocol="AJP/1.3" URIEncoding="UTF-8" redirectPort="8463" />
配置结束,启动apche和tomcat
1.下载apache2 ,这里使用apt-get下载安装
apt-get insall apache2
2.安装tomcat
从网上找可用的tomcat 包,解压即可
3.配置java 环境
apt-get install openjdk-7-jre
文件大约300多M,下载完成用 java -version查看版本信息。在这里,我没有配置.bash_profile文件但最好也可以正常运行。
4.加载各种模块
#代理核心模块
a2enmod proxy
#代理AJP模块
a2enmod proxy_ajp
#代理负载均衡模块
a2enmod proxy_balancer
#代理HTTP模块
a2enmod proxy_http
前面将软件和环境基本安装配置好,下面配置apahce2 文件。apache2 主要有以下几个文件需要配置:
1.envvars文件
把tomcat 文件名和网站名一一对应写好
export WWW_HOME="/home/root"
export xiexie_ROOT="$WWW_HOME/tomcat8-xiexie/webapps/ROOT"
export nihao_ROOT="$WWW_HOME/tomcat8-nihao/webapps/ROOT"
export 333333_ROOT="$WWW_HOME/tomcat8-33333/webapps/ROOT"
2.sites-available里的conf文件
新建一个001-nihao.conf,这个conf所配置的内容对应的是名字为tomcat8-nihao的那个tomcat
<Directory ${nihao_ROOT}>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
Options -Indexes
</Directory>
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName nihao.abc.com
ServerAlias abc.com
ProxyPass / ajp://127.0.0.1:8009/
ProxyPassReverse / ajp://127.0.0.1:8009/
ServerAdmin webmaster@localhost
DocumentRoot ${nihao_ROOT}
DirectoryIndex index.html index.htm index.jsp
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/nihao-error.log
CustomLog ${APACHE_LOG_DIR}/nihao-access.log combined
#RewriteEngine on
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
3.在 site-enabled文件里创建 site-available 里conf文件的软链接
ln -s ../site-available/001-nihao.conf 001-nihao.conf
关于apache2 的配置就是以上
tomcat的配置
1.在tomcat 目录下修改conf/server.xml
server port 每个tomcat 都要不同防止冲突
<Server port="8025" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
Connector port 要与apache 里.conf 要对应
<Connector port="8029" protocol="AJP/1.3" URIEncoding="UTF-8" redirectPort="8463" />
配置结束,启动apche和tomcat
相关文章推荐
- jvisualvm远程监控Tomcat
- tomcat实现文件打开下载功能
- 打包好的javaweb项目(.war格式)在tomcat上运行时提示404notfond
- 修改Tomcat的默认主页为你自己项目的主页
- 今天tomcat 遇到的问题
- Tomcat工作原理
- [置顶] 腾讯云服务器中Ubuntu上的jdk,tomcat,MySQL的安装和环境配置
- war包放入tomcat
- IntelliJ IDEA 14 拉取SVN maven 多模块项目 部署tomcat 详细图解!
- Maven项目热部署到Tomcat容器下
- Tomcat 7.0.3x 启动慢并且遇到StackOverflowError的异常的解决办法
- Solr4.3.1+Tomcat7.0.37配置
- 启动Tomcat服务报错,端口被占用解决方案
- Tomcat 7 WEB-XML 报错 “:”
- tomcat 添加项目映射
- Spring+JMS+ActiveMQ+Tomcat实现消息服务
- tomcat启动
- tomcat启动异常(严重: Dispatcher initialization failed Unable to load configuration. - [unknown location] )
- 下载Tomcat双击运行startup.bat运行一闪而过的问题
- 安装tomcat出现failed to install tomcat6 service错误及解决方法