Home  >  Article  >  php教程  >  wdcp adds tomcat and supports both php and java tutorials

wdcp adds tomcat and supports both php and java tutorials

高洛峰
高洛峰Original
2017-01-05 17:07:031584browse

Use the script officially provided by wdcp to install the lnamp environment. For installation, please refer to: http://www.wdlinux.cn/bbs/thread-6292-1-1.html. This article mainly talks about how to install JDK+ in the LNAMP environment. Tomcat6 enables the same server to support both PHP and JAVA languages. The server system and each software version are as follows

[root@E ~]# uname -a

Linux E.CentOS6.4 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

[root@E ~]# /www/wdlinux/nginx/sbin/nginx -v

nginx version: nginx/ 1.2.9

[root@E ~]# /www/wdlinux/httpd-2.2.24/bin/httpd -v

Server version: Apache/2.2.24 (Unix)

Server built: Oct 30 2014 00:17:07

[root@E ~]# rpm -qa |grep mysql

mysql-libs-5.1.66-2 .el6_3.x86_64

[root@E ~]# /www/wdlinux/php/bin/php -v

Cannot load Zend Extension Manager - it was built with configuration 1.2.0, whereas running engine is API220090626,NTS

PHP 5.3.27 (cli) (built: Oct 30 2014 00:30:02)

Copyright (c) 1997-2013 The PHP Group

Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies


Start installing jdk: List the jdk installation packages available in the yum library

[root@E ~]# yum -y list java*

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: mirror.bit .edu.cn

* extras: mirror.bit.edu.cn

* rpmforge: mirrors.neusoft.edu.cn

* updates: mirrors.neusoft.edu .cn

base | 3.7 kB 00:00

extras | 3.3 kB 00:00

rpmforge | 1.9 kB 00:00

updates | 3.4 kB 00:00

updates/primary_db | 171 kB 00:00

Available Packages

java-1.5.0-gcj.x86_64 1.5.0.0-29.1.el6 base

java-1.5.0-gcj-devel.x86_64 1.5.0.0-29.1.el6 base

java-1.5.0-gcj-javadoc.x86_64 1.5.0.0-29.1.el6 base

java-1.5.0-gcj-src.x86_64 1.5.0.0-29.1.el6 base

java-1.6.0-openjdk.x86_64 1:1.6.0.33-1.13.5.0. el6_6 updates

java-1.6.0-openjdk-demo.x86_64 1:1.6.0.33-1.13.5.0.el6_6 updates

java-1.6.0-openjdk-devel.x86_64 1: 1.6.0.33-1.13.5.0.el6_6 updates

java-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.33-1.13.5.0.el6_6 updates

java-1.6.0 -openjdk-src.x86_64 1:1.6.0.33-1.13.5.0.el6_6 updates

java-1.7.0-openjdk.x86_64 1:1.7.0.71-2.5.3.1.el6 updates

java-1.7.0-openjdk-demo.x86_64 1:1.7.0.71-2.5.3.1.el6 updates

java-1.7.0-openjdk-devel.x86_64 1:1.7.0.71-2.5.3.1 .el6 updates

java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.71-2.5.3.1.el6 updates

java-1.7.0-openjdk-src.x86_64 1 :1.7.0.71-2.5.3.1.el6 updates

java-1.8.0-openjdk.x86_64 1.8.0.25-1.b17.el6 updates

java-1.8.0-openjdk- demo.x86_64 1.8.0.25-1.b17.el6 updates

java-1.8.0-openjdk-devel.x86_64 1.8.0.25-1.b17.el6 updates

java-1.8. 0-openjdk-headless.x86_64 1.8.0.25-1.b17.el6 updates

java-1.8.0-openjdk-javadoc.noarch 1.8.0.25-1.b17.el6 updates

java-1.8.0-openjdk-src.x86_64 1.8.0.25-1.b17.el6 updates

java_cup.x86_64 1:0.10k-5.el6 base

java_cup-javadoc.x86_64 1:0.10k-5.el6 base

java_cup-manual.x86_64 1:0.10k-5.el6 base

javacc.x86_64 4.1-0.5.el6 base

javacc-demo.x86_64 4.1-0.5.el6 base

javacc-manual.x86_64 4.1-0.5.el6 base

javassist.noarch 3.9.0-6.el6 base

javassist-javadoc.noarch 3.9.0-6.el6 base

Select jdk1.6 installation

[root@E ~]# yum -y install java-1.6.0-openjdk*

For other versions, please modify the corresponding version number yourself to check whether the installation is successful

[root@E ~]# java -version

java version "1.6.0_33"

OpenJDK Runtime Environment (IcedTea6 1.13.5) (rhel-1.13.5.0.el6_6-x86_64)

OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

Install tomcat6 Because the default port installed by wdcp background is 8080, and the default port of tomcat is also 8080. In order to avoid conflicts, please change the wdcp background port to other ports (such as: 8089...) in advance. You can manually modify it in the wdcp background system settings:

[root@E ~]# yum install tomcat6 tomcat6-webapps tomcat6-admin-webapps

The installation started successfully

[root@E ~]# service tomcat6 start

Other commands: service tomcat6 {start|stop|restart|condrestart|try-restart|reload|force-reload|status|version}

Start successfully, access test: http://ip :8080 If you can access it, the installation is successful: Configure nginx and tomcat so that they do not add a port number and can be accessed directly through the domain name. First, add the resolution so that the domain name points to the host IP. You can directly change the host locally to achieve normal resolution without adding the 8080 port. Access Add 8080 port access Next modify the configuration of nginx and tomcat so that you can access tomcat's webservice without adding a port number

[root@E ~]# cd /www/wdlinux/nginx/conf/vhost /

[root@E ~]# vi myweb.com.conf

Add the following content

server {

listen 80;

server_name www.myweb.com myweb.com;

root /www/web/master_myweb_com/public_html;

index index.html index.jsp index.htm;

error_page 400 /errpage/400.html;

error_page 403 /errpage/403.html;

error_page 404 /errpage/404.html;

error_page 405 / errpage/405.html;

location ~ \.jsp$ {

proxy_pass http://127.0.0.1:8080;

include naproxy.conf;

}

location / {

try_files $uri @tomcat;

}

location @tomcat {

proxy_pass http://127.0.0.1:8080;

include naproxy.conf;

}

access_log /www/web_logs/ myweb_com_access.log wwwlogs;

error_log /www/web_logs/myweb_com_error.log;

}

Reload the nginx configuration file or restart nginx

[root @E vhost]# service nginxd reload

nginx: the configuration file /www/wdlinux/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /www/wdlinux/nginx /conf/nginx.conf test is successful

Access test without port number: So far nginx has successfully proxy the request from myweb.com domain name to port 8080. If you need to configure multiple domain names, you also need to modify the tomcat virtual machine Host configuration file default configuration file path: /etc/tomcat6/ Default project path: /var/lib/tomcat6/webapps/ tomcat points to the /var/lib/tomcat6/webapps/ROOT directory by default to create a new project directory, copy the ROOT project directly here , make modifications

[root@E webapps]# pwd

/var/lib/tomcat6/webapps

[root@E webapps]# chown -R root myweb. com

Modify permissions so that the new project permissions are consistent with the default project permissions

[root@E webapps]# chgrp -R tomcat myweb.com

[root@E webapps ]# ll

Total usage 24

drwxrwxr-x 5 root tomcat 4096 October 30 22:06 examples

drwxrwxr-x 5 root tomcat 4096 October 30 22: 06 host-manager

drwxrwxr-x 5 root tomcat 4096 October 30 22:06 manager

drwxr-xr-x 3 root tomcat 4096 October 30 22:48 myweb.com

drwxrwxr-x 3 root tomcat 4096 October 30 22:06 ROOT

drwxrwxr-x 5 root tomcat 4096 October 30 22:06 sample

[root@E myweb. com]# cd myweb.com/

[root@E myweb.com]# rm -f index.html

[root@E myweb.com]# vi index.jsp

Write: WebService is Tomcat

Don’t forget to delete the ROOT project or rename it, otherwise the new project will not take effect

[root@E webapps]# mv ROOT/ ROOT. BAK

Modify tomcat virtual host configuration

[root@E myweb.com]# vi /etc/tomcat6/server.xml

At the bottom< Add the following content after the ;/Host> tag

unpackWARs="true" autoDeploy="true"

xmlValidation="false" xmlNamespaceAware="false">

myweb.com

Restart tomcat, test [root@E myweb.com]# service tomcat6 restart success!


For more wdcp adding tomcat, supporting both php and java tutorials, please pay attention to the PHP Chinese website for related articles!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn