CentOS 7 部署 JAVA+PHP 共享80端口环境

阅读:361 2019-03-19 15:02:06 来源:新网

现在很多公司都有云主机,但随着项目或者公司业务的扩大,或者对软件设计的要求越来越高。一种与语言环境已经不能满足。但是如果通过端口来访问又显得不够专业。

现在主流的java+php共享80端口的方案有

本文采用的是第三种。

apache中的mod_proxy模块主要作用就是进行url的转发,即具有代理的功能。应用此功能,可以很方便的实现同tomcat等应用服务器的整合,甚者可以很方便的实现web集群的功能。

yuminstallhttpd

apache安装目录/etc/httpdapachewww目录/var/www

1.升级仓库rpm-uvhhttps://mirror.webtatic.com/yum/el7/epel-release.rpmrpm-uvhhttps://mirror.webtatic.com/yum/el7/webtatic-release.rpm2.安装5.6yuminstall-yphp56wphp56w-opcachephp56w-xmlphp56w-mcryptphp56w-gdphp56w-develphp56w-mysqlphp56w-intlphp56w-mbstring安装jdk

yuminstalljava-1.8.0-openjdk安装tomcat

yuminstalltomcattomcat-webappstomcat-admin-webapps

tomcat安装目录/etc/tomcattomcatwebapps目录/var/lib/tomcat/webapps

vi/etc/httpd/conf/httpd.conf添加读取虚拟主机配置

放在配置文件开头includeconf/extra/httpd-vhosts.conf新建extra/httpd-vhosts.conf配置文件

#serveraliaslocalhost#绑定的子域名#documentroot/var/www/html/#网站主目录#errorloglogs/vhost1.test.com-error_log#错误日志配置(默认在/etc/httpd/logs目录下)#customloglogs/vhost1.test.com-access_logcommon#访问日志配置(默认在/etc/httpd/logs目录下)#serversignatureoff##主机目录##optionsfollowsymlinks#allowoverrideall#requireallgranted#documentroot/var/www/htmlservernamephp.test.comerrorloglogs/php.test.com-error_logcustomloglogs/php.test.com-access_logcommonoptionsfollowsymlinksallowoverrideallrequireallgrantedservernamejsp.test.comdocumentroot/var/lib/tomcat/webapps/rooterrorloglogs/jsp.test.com-error_logcustomloglogs/jsp.test.com-access_logcommonproxypass/http://localhost:8080/proxypassreverse/http://localhost:8080/

新建配置文件如果无法保存,可以尝试使用sudo执行,或者先创建目录,创建文件后再编辑。

systemctlstarttomcat.service启动apache

systemctlstarthttpd.service

通过上边的配置,已经完成apache、tomcat共享80端口的基本配置,也很好理解。

相关文章
{{ v.title }}
{{ v.description||(cleanHtml(v.content)).substr(0,100)+'···' }}
你可能感兴趣
推荐阅读 更多>
推荐商标

{{ v.name }}

{{ v.cls }}类

立即购买 联系客服