Linux安装rzse,MySQL,Tomcat,JDK

来源:互联网 发布:经济学数据库 编辑:程序博客网 时间:2024/06/05 04:06

1. 安装rzsz
[java] view plain copy 在CODE上查看代码片派生到我的代码片
# 1. 安装rzsz  
yum update -y  
yum list lrzsz*  
yum install lrzsz -y  


2. 安装JDK,path之类的已经自动设置好了
[java] view plain copy 在CODE上查看代码片派生到我的代码片
yum list java*  
yum install java-1.7.0-openjdk* -y  


3.安装MySQL

1. # wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm   
2. # yum install mysql-community-release-el7-5.noarch.rpm 
3. # yum install mysql-server* -y

vi /etc/my.cnf
3.1 大致的mysql配置文件如下:
[java] view plain copy 在CODE上查看代码片派生到我的代码片
[mysqld]  
# datadir=/var/lib/mysql  
datadir=/usr/local/renfufei/mysql_data  
socket=/var/lib/mysql/mysql.sock  
user=mysqlsys  
# Disabling symbolic-links is recommended to prevent assorted security risks  
symbolic-links=0  
default-character-set=utf8  
[mysqld_safe]  
log-error=/var/log/mysqld.log  
pid-file=/var/run/mysqld/mysqld.pid  
[mysql] 
default-character-set=utf8  


其中,vi 默认进入时是命令模式,要进入编辑模式,可以使用按键 “i” 表示insert,插入模式。
而退出编辑模式,使用Esc键,退出编辑模式后,就处于命令模式,在命令模式下输入的指令不会被加入到内容之中,


在命令模式下,直接输入行号,比如 22,回车,则光标就跳到22行了,而使用冒号加命令,可以执行相关操作,比如






[java] view plain copy 在CODE上查看代码片派生到我的代码片
:wq 表示写入文件,并退出  
:wq! 表示强制写入文件,并退出,适合只读文件什么的。  
:q! 表示退出不保存  




记得加回车键。


4. 安装 tomcat


[java] view plain copy 在CODE上查看代码片派生到我的代码片
# 4. 安装 tomcat  
cd /usr/local  
yum -y install wget
wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-6/v6.0.48/bin/apache-tomcat-6.0.48.tar.gz   
tar -zxf apache-tomcat-6.0.48.tar.gz  
mv apache-tomcat-6.0.48 tomcat  


4.1 修改配置文件
[java] view plain copy 在CODE上查看代码片派生到我的代码片
cd /usr/local/tomcat/conf  
# 修改配置文件 server.xml,不能有中文.  
# 配置端口号,绑定域名,别名,以及设置线程池,映射context文件夹  
vi server.xml  


然后修改其中的Server部分,当然,可以采用ftp,或者其他工具下载到windows编辑好,再上传回去啦,记得如果有中文注释什么的,需要修改编码为UTF-8,否则纯英文,使用默认的ANSI也可以。
[html] view plain copy 在CODE上查看代码片派生到我的代码片
<Service name="Catalina">  
lt;Executor name="tomcatThreadPool" namePrefix="catalina-exec-"  
      maxThreads="250" minSpareThreads="20"/>  
  <Connector port="80" protocol="HTTP/1.1"  
             connectionTimeout="20000"  
             redirectPort="8443"   
        compression="on"  
        compressionMinSize="2048"  
        noCompressionUserAgents="gozilla,traviata"  
        compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json,application/javascript,application/x-javascript"  
        />  
  <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" executor="tomcatThreadPool"/>  
  <Engine name="Catalina" defaultHost="www.renfufei.com">  
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  
           resourceName="UserDatabase"/>  
    <Host name="www.renfufei.com"  appBase="webapps"  
          unpackWARs="true" autoDeploy="true"  
          xmlValidation="false" xmlNamespaceAware="false">  
    <Alias>localhost</Alias>  
    <Alias>renfufei.com</Alias>  
    <Alias>renfufei.cn</Alias>  
    <Alias>www.renfufei.cn</Alias>  
    <Context docBase="/renfufei/upload"  path="/upload" />  
    <Context docBase="/renfufei/myapp"  path="" />  
    </Host>  
  </Engine>  
</Service>


5. 启动mysqld 服务,以及tomcat
[java] view plain copy 在CODE上查看代码片派生到我的代码片
-- 5. 启动mysqld 服务,以及tomcat  
cd /usr/local/renfufei  
mkdir mysql_data  
# 必须修改所属用户哦,如果修改了mysql的数据文件保存目录的话  
chown mysql:mysql mysql_data  
  
service mysqld start  
/usr/local/tomcat/bin/startup.sh  




5.1 设置Tomcat自动启动


有很多种方式,比如设置服务,或者使用 rc.local 进行加载。


修改 /etc/rc.d/rc.local 文件:


[plain] view plain copy 在CODE上查看代码片派生到我的代码片
vim /etc/rc.d/rc.local  
在里面增加启动Tomcat的脚本,然后保存. 最A
终结果如下所示:
[plain] view plain copy 在CODE上查看代码片派生到我的代码片
[root@xxx bin]# cat /etc/rc.d/rc.local   
#!/bin/sh  
#  
# This script will be executed *after* all the other init scripts.  
# You can put your own initialization stuff in here if you don't  
# want to do the full Sys V style init stuff.  
  
touch /var/lock/subsys/local  
  
# start tomcat  
/usr/local/tomcat/bin/startup.sh  
可以看到, 我们只增加了最后一行。意思是在Linux启动完成后,加载其他初始脚本完毕之后, 执行启动Tomcat的命令.
当然,启动其他程序也可以使用这种方式,但是就是土了一点,而且不可以使用 chkconfig 进行配置和调用(也就是说没有采用安装服务的方式.)


6. 因为修改了相对应的tomcat的context,所以访问没有什么内容啦,需要在 


[html] view plain copy 在CODE上查看代码片派生到我的代码片
/renfufei/myapp  
下面有对应的javaEE app才可以。


使用遇到问题
1:服务器使用:编辑防火墙:vi /etc/sysconfig/iptables
重启服务:centen6:service iptables restart
centen7: /bin/systemctl restart iptables.service


centen7:
mysql停止服务:service mysqld restart
service mysqld stop


查看端口号:netstat -ntlp


现在服务器重启:bin/startup.sh
查看日志:tail -500f catalina.out


下面是6重启tomcat方法:cd tomcat/
bin/catalina.sh start


下面是7重启tomcat方法:
bin/startup.sh 

暂停:
bin/shutdown.sh 


0 0
原创粉丝点击