Heim >Backend-Entwicklung >PHP-Tutorial >php和java环境整合_PHP教程
1、安装jdk
#chmod u+x jdk-6u4-linux-x64.bin
#./jdk-6u4-linux-x64.bin
按‘q’键,输入yes在当前目录下会产生一个jdk1.6.0_04的目录
#mv jdk1.6.0_04 /usr/local/
配置环境变量
#vim /etc/profile
加入
JAVA_HOME=/usr/local/jdk1.6.0_04
export JAVA_HOME
CLASSPATH=/usr/local/jdk1.6.0_04/lib:/usr/local/jdk1.6.0_04/jre/lib
export CLASSPATH
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH
JRE=/usr/local/jdk1.6.0_04/jre
export JRE
#source /etc/profile
查看
#java -vejava
version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) 64-Bit Server VM (build 10.0-b19, mixed mode)
表示成功!
2、安装apache-tomcat
#wget http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.16/bin/apache-tomcat-6.0.16.tar.gz
#tar xzvf apache-tomcat-6.0.16.tar.gz
#mv apache-tomcat-6.0.16 /usr/local/
配置环境变量
#vim /etc/profile
TOMCAT_HOME=/usr/local/apache-tomcat-6.0.16
export TOMCAT_HOME
#source /etc/profile
启动
#/usr/local/apache-tomcat-6.0.16/bin/startup.sh
默认启动端口在8080上
3、配置nginx实现同时解析jsp和php文件
#cat /usr/local/nginx/conf/vhosts/www.test.com.conf
upstream tomcat_server {
server 127.0.0.1:8080;
}
server
{
listen 80;
server_name www.test.com;
index index.html index.htm index.php;
root /data/httpd/channel.metromall.com.cn;
if (!-e $request_filename) {
rewrite ^/(.+\.(html|xml|json|htm|php|asp|shtml))$ /index.php?$1 last;
}
location ~ \.(jsp|jspx|do)?$
{
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://tomcat_server;
}
location ~ .*\.php.*
{
include php_fcgi.conf;
include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
access_log /var/log/nginx/access.log;
#access_log off;
}
作者:yuangang_love