Apache 映射到 Tomcat

8 篇文章 0 订阅

Apache 是centos 默认的http服务器
默认使用80端口 ,apache 使用量巨大。
Apache 管理命令

service httpd restart //重启
service httpd start //启动
service httpd stop //停止

配置文件目录

 cd /etc/httpd/conf
 vi httpd.conf 

配置文件中增加一个虚拟机配置

<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common

RewriteEngine On
ServerName  h.youyisky.com
serverAlias www.h.youyisky.com

ProxyRequests Off
<Proxy *>
   Order deny,allow
  Allow from all
</Proxy>
#ProxyPass /classifier/ http://172.16.129.22:8080/shiny/
#ProxyPassReverse /classifier/ http://172.16.129.22:8080/shiny/
#ProxyPass /pic_random/ http://172.16.129.121:8080/
#ProxyPassReverse /pic_random/ http://172.16.129.121:8080/

ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
#SetEnv force-proxy-request-1.0.1
#SetEnv proxy-nokeepalive 1
</VirtualHost>

配置 主机名

ServerName  www.domain.com:80

如果页面跳转迅速,但是提示临时维护
则查看 SELinux

关闭SELinux的方法:
修改/etc/selinux/config文件中的SELINUX=”” 为 disabled ,然后重启。
如果不想重启系统,使用命令setenforce 0
注:
setenforce 1 设置SELinux 成为enforcing模式
setenforce 0 设置SELinux 成为permissive模式
在lilo或者grub的启动参数中增加:selinux=0,也可以关闭selinux
getenforce/setenforce查看和设置SELinux的当前工作模式

 /usr/sbin/setenforce 0

此配置需要tomcat与apach 在同一主机上方。

场景:公司、校园内网服务需要外网访问

另外配置文件中也支持301跳转

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值