安装java1.8
#yum update 服务器更新源码包
#rpm -qa |grep -E ‘^open[jre|jdk]|j[re|dk]‘ 搜索任何版本的已安装JDK组件
java-1.8.0-openjdk-headless-1.8.0.60-2.b27.el7_1.x86_64
pygobject2-2.28.6-11.el7.x86_64
pygobject3-base-3.8.2-6.el7.x86_64
java-1.8.0-openjdk-1.8.0.60-2.b27.el7_1.x86_64
openjpeg-libs-1.5.1-10.el7.x86_64
gobject-introspection-1.36.0-4.el7.x86_64
#java -version 查看已安装的java版本
#yum remove java-1.7.0-openjdk 卸载之前的版本的java
yum安装java1.8
# yum search jdk
......
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-headless.x86_64 : The OpenJDK runtime environment without audio and video support
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
#yum -y install java-1.8.0-openjdk
rpm源码包安装:
#rpm -ivh xxx
编译安装:
#tar zxvf xxx -C /root/
#cd /root/xx
#cp -rp jre1.7.-_05 /usr/local
#vi /etc/profile 配置全局环境
JAVA_HOME=/usr/local/xxx
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib
PATH=$JAVA_HOME/bin:$PATH
测试java是否安装成功
#chown -R root.root /usr/local/xxx/
#java -version
如果运行java报错:
error :/usr/lib/libjvm.so: cannot restore segment prot after reloc: Permission denied .
use the command:
chcon -t textrel_shlib_t /usr/lib/libjvm.so
是selinux导致的
#setenforce 0
二、安装tomcat7
#wget http://apache.mirror.digitalpacific.com.au/tomcat/tomcat-7/v7.0.64/bin/apache-tomcat-7.0.64.tar.gz
#tar zxvf xxx 解压之后就是二进制文件,无需安装。直接将目录移动到/usr/local目录即可
#mv xxx /usr/local/tomcat
#vim /usr/local/tomcat/bin/catalisna.sh 在tomcat启动脚本中设置环境变量
JAVA_HOME=/usr/java/jdk1.8.0xx 使其支持java,添加此行
#vim /etc/profile
CATALINA_HOME=/usr/local/tomcat/
PATH=$JAVA_HOME/bin:/usr/local/tomcat/bin/:$PATH 设置环境变量
退出当前shell,重进后该配置生效
or
#. /etc/profile 使新的环境变量生效
手动启动/关闭/重启tomcat
#/usr/local/tomcat/bin/catalina.sh
#netstat -lnp |grep 80 发现80开头的端口,即表示tomcat启动成功
#/usr/local/tomcat/bin/catalina.sh stop/restart
#/usr/local/tomcat/bin/shutdown.sh 也可以关闭tomcat
设置systemctl开机自启动服务
#vim /lib/systemd/system/tomcat.service
[Unit]
Description=tomcat
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/tomcat/bin/catalina.sh start
ExecReload=/usr/local/tomcat/bin/catalina.sh restart
ExecStop=/usr/local/tomcat/bin/catalina.sh stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#systemctl enable tomcat.service 链接到systemctl开机自启动服务
#systemctl start/stop/restart tomcat.service
三、tomcat+apache整合
整合方式三种:
01 JK方式
02 http_proxy方式
03 ajp_proxy方式
http_proxy方式需要的模块:
mod_proxy.so和mod_prxy_http.so
默认mod_proxy.so已经安装,只需安装mod_proxy_http.so模块
#ls /usr/lib64/httpd/modules/mod_proxy.http.so
#ls /usr/lib64/httpd/modules/mod_proxy.so
将该模块添加到httpd.conf配置文件中
#vim /etc/httpd/conf/httpd.conf
LoadModule proxy_http_module modules/mod_proxy_http.so
#service httpd restart 重启apache服务
测试:
浏览器输入:服务器ip