1. 安装 Tomcat
apt-get install tomcat7 apt-get install tomcat7-admin apt-get install tomcat7-docs apt-get install tomcat7-examples
?
2. 开启,中止和重启
/etc/init.d/tomcat7 start /etc/init.d/tomcat7 stop /etc/init.d/tomcat7 restart
?
3. 根目录链接
cd /var/lib/tomcat7/webapps sudo ln -s /usr/share/tomcat7-examples/examples examples sudo ln -s /usr/share/tomcat7-docs/docs docs sudo ln -s /usr/share/tomcat7-admin/manager manager sudo ln -s /usr/share/tomcat7-admin/host-manager host-manager
?
来源: http://stackoverflow.com/questions/17360868/setting-up-tomcat-in-ubuntu
?
4. JSP和PHP共存――Apache2反向代理实现
?
环境:ubuntu 12.04 + apache2 + tomcat
1.首先在tomcat中配置好jsp站点,映射端口8080
2.启用apache2的反向代理
apache2的配置文件都保存在/etc/apache2/中,启用反向代理既可以用a2enmod实现,也可以用ln手动设置
ln创建链接方式:
ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled/proxy.load ln -s /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled/proxy.conf ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled/proxy_http.load
?
a2enmod方式:
a2enmod proxy a2enmod proxy_http
?
3.修改proxy.conf
vi /etc/apache2/mods-enabled/proxy.conf
?
配置为
<Proxy> Order deny,allow Allow from all </Proxy>
?
4.修改apche2中的站点配置
apache2的站点配置默认保存在/etc/apache2/sites-enabled/文件夹中,默认是default
将站点localhost:80/8080映射到tomcat,文件配置如下:
<VirtualHost *:80> ServerAdmin webmaster@localhost ProxyRequests Off <Location /8080> ProxyPass http://localhost:8080/ ProxyPassReverse http://localhost:8080/ </Location> #ProxyPass / http://localhost:8080/ #ProxyPassReverse / http://localhost:8080/ DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
?
5.重启apache2,测试
打开http://localhost/ 显示apache页面
打开http://localhost/8080 显示tomcat页面
如果有多个目录要映射,并且映射到不同站点的目录有父子关系的,要注意配置文件的顺序,如:
<Location /8080> ProxyPass http://localhost:8080/ ProxyPassReverse http://localhost:8080/ </Location> <Location /> ProxyPass http://website/ ProxyPassReverse http://website/ </Location>
?
使用Apache2反向代理不仅能让同一端口jsp和php共存,还能实现负载均衡等功能。
?
来源:http://yanchao90.blog.163.com/blog/static/17946025201272611182190/
?
5. Apache、Tomcat、IIS(PHP、JSP、ASP)共存时的设置
?
1、分别安装三个环境,并设置不同端口
PHP:80
JSP:8080
ASP:8081
?
2、设置/Apache2/conf/httpd.conf
去掉以下三行前的注释:
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_connect_module modules/mod_proxy_connect.so LoadModule proxy_http_module modules/mod_proxy_http.so
?
加入以下几行:
ProxyPass /jsp http://127.0.0.1:8080 #ProxyPassReverse /jsp http://127.0.0.1:8080 ProxyPass /asp http://127.0.0.1:8081 #ProxyPassReverse http://127.0.0.1:8081?
这样,就可以用
http://127.0.0.1/ 来访问PHP
http://127.0.0.1/asp ??或 http://127.0.0.1:8081 来访问ASP,
http://127.0.0.1/jsp ?或 http://127.0.0.1:8080? 来访问JSP.
注:127.0.0.1是你配置的服务器的IP,可根据你的情况替换之。
来源:http://www.xuebuyuan.com/998179.html
?