您的位置:首页 > 运维架构 > Linux

linux 下搭建java web环境

2014-05-05 15:43 567 查看
linux 系统下安装java服务:

1:将tomcat 和 jdk拷贝到linux下,并解压或安装;
安装jdk(.bin)时:先要用chmod u+x jdk文件名.bin; 添加执行权限-->./jdk文件名.bin
安装tomcat(.tar.gz):tar -zxvf tomcat文件名.tar.gz-->修改tomcat配置文件
2:在/etc/profile 加上export

export JAVA_HOME=/usr/local/jdk1.6.0_43
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
#这个设置可以改变linux和jvm的线程冲突
export _JAVA_SR_SIGNUM=12
3:重新加载profile文件:source /etc/profile
4:运行:java -version

centos 安装mysql:
1:yum install mysql-server --> 安装mysql服务
2:修改/etc/my.cnf文件
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
lower_case_table_names=1 #不区分大小写
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
default-character-set = utf8 #设置字符集

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysql]
default-character-set = utf8

3:启动MySQL服务
[root@sample ~]# chkconfig mysqld on  ← 设置MySQL服务随系统启动自启动
[root@sample ~]# chkconfig --list mysqld  ← 确认MySQL自启动
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 如果2--5为on的状态就OK
[root@sample ~]#/etc/rc.d/init.d/mysqld start  ← 启动MySQL服务
Initializing MySQL database:         [ OK ]
Starting MySQL:              [ OK ]

4:修改mysql root密码:
MySQL在刚刚被安装的时候,它的root用户是没有被设置密码的。首先来设置MySQL的root密码。

[root@sample ~]# mysql -u root -- 用root用户登录MySQL服务器

mysql> select user,host,password from mysql.user;  -- 查看用户信息
mysql> set password for root@localhost=password('在这里填入root密码'); -- 设置root密码; 注:password() 将密码加密工具
mysql> exit -- 退出MySQL服务器
5:修改远程登录
方法一:修改mysql下的user表(添加一条host='%'的数据);
方法二: grant all privileges on *.* to ‘yourUser’@'%' identified by ‘yourPassword’;

MySQL登录密码重置:
# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
保存并且退出vi。

3.重新启动mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

4.登录并修改MySQL的root密码
# /usr/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> USE mysql ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
5.将MySQL的登录设置修改回来
# vi /etc/my.cnf
将刚才在[mysqld]的段中加上的skip-grant-tables删除
保存并且退出vi。
6.重新启动mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: