linux装软件
====权限==============
drwxr-xr-x
d:目录
read write execute
-rw-r--r-- 文件
rwx r-x r-x
111 101 101
7 5 5
用户 用户组 其他组
g u o
777 最高权限
更改权限的命令:===========
chmod g(u/o)+(-)w 文件
chmod 777 文件名
chmod 777 -R 文件名 递归授权(子目录也获得权限)
添加用户和用户组:=============
创建用户组:groupadd 组名
删除用户组:groupdel 组名 (只能删除空的组)
创建用户组(指定组id):
groupadd -g 701 tomcat 指定tomcat的groupId为701
创建用户(在指定的组下):
useradd -g 701 tomcat 在指定的groupId下创建tomcat用户
修改用户密码: passwd tomcat
切换用户 su - tomcat
* 切换用户:su - tomcat,
注意加 - ;环境变量使用的tomcat用户定义的环境变量
===linux下安装软件3种方式:=====
1 rpm包 相当于windows的exe,属于二进制安装
2 tar包 直接解压安装
3 yum安装 (centos的在线安装),在线安装的prm
安装rpm的常用命令:
rpm -i 安装(install)
rpm -ivh 安装并显示进度
=安装JDK======================
安装之前,先检查一下是否安装过JDK
OpenJDK 社区版jdk
一;tomcat用户下设置jdk的环境变量即可,不影响其他的用户环境
使用命令: chown 改变文件的所有者
chown tomcat /opt/software/jdk-7u67-linux-x64.rpm
注意:安装软件都要使用root
安装rpm:
rpm -ivh /opt/software/jdk-7u67-linux-x64.rpm
二;在tomcat用户下,配置jdk的环境变量(用户级):=====
1 cd
2 ls -la (要查看隐藏文件)
3 vi .bash_profile
JAVA_HOME=/usr/java/jdk1.7.0_67
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH:$HOME/bin
4 echo $PATH 回显 (分隔符是:)
5 切换用户(才生效),最终在tomcat用户下 java -version
root用户下配置jdk环境变量(系统级别):=====
1 vi etc/profile
JAVA_HOME=/usr/java/jdk1.7.0_67
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
2 source /etc/profile 让配置文件立即生效
=mysql安装:=============
1 查找是否安装过mysql 的rpm包
rpm -qa | grep mysql
rpm -e mysql-libs-5.1.71-1.el6.x86_64 卸载
若有依赖关系,需要强删:
rpm -e mysql-libs-5.1.71-1.el6.x86_64 --nodeps
2 解tar
tar -xvf tar包 (解压到当前目录)
tar -xvf tar包 -C 大写C指定目录( man tar)
3 rpm安装顺序(先server 后client)
4 查mysql的进程启动状态
ps -ef|grep mysql
chkconfig --list 查看所有服务
service msyql start 启动mysql服务
5 进入mysql
mysql -u root -p (初始没有密码)
改初始密码
先
退出mysql:exit
再
mysqladmin -u root -p password
Enter password: //直接Enter,因为初始没有密码
New password: //设置新密码
Confirm new password:
6 修改mysql的字符集--
show variables like 'chara%'; --查看字符集是否设置为u8
mysql> show variables like 'chara%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)
通过修改配置文件,改字符编码
配置文件在:/usr/share/mysql/my-small.cnf
需要把my-small.cnf拷贝到etc目录下作为一个全局配置文件
[tomcat@mylinux mysql]$ cat my-small.cnf # Example MySQL config file for small systems. # # This is for a system with little memory (<= 64M) where MySQL is only used # from time to time and it's important that the mysqld daemon # doesn't use much resources. # # MySQL programs look for option files in a set of # locations which depend on the deployment platform. # You can copy this option file to one of those # locations. For information about these locations, see: # http://dev.mysql.com/doc/mysql/en/option-files.html # # In this file, you can use all long options that a program supports. # If you want to know which options a program supports, run the program # with the "--help" option. # The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = /var/lib/mysql/mysql.sock # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /var/lib/mysql/mysql.sock skip-external-locking key_buffer_size = 16K max_allowed_packet = 1M table_open_cache = 4 sort_buffer_size = 64K read_buffer_size = 256K read_rnd_buffer_size = 256K net_buffer_length = 2K thread_stack = 128K # Don't listen on a TCP/IP port at all. This can be a security enhancement, # if all processes that need to connect to mysqld run on the same host. # All interaction with mysqld must be made via Unix sockets or named pipes. # Note that using this option without enabling named pipes on Windows # (using the "enable-named-pipe" option) will render mysqld useless! # #skip-networking server-id = 1 # Uncomment the following if you want to log updates #log-bin=mysql-bin # binary logging format - mixed recommended #binlog_format=mixed # Causes updates to non-transactional engines using statement format to be # written directly to binary log. Before using this option make sure that # there are no dependencies between transactional and non-transactional # tables such as in the statement INSERT INTO t_myisam SELECT * FROM # t_innodb; otherwise, slaves may diverge from the master. #binlog_direct_non_transactional_updates=TRUE # Uncomment the following if you are using InnoDB tables #innodb_data_home_dir = /var/lib/mysql #innodb_data_file_path = ibdata1:10M:autoextend #innodb_log_group_home_dir = /var/lib/mysql # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #innodb_buffer_pool_size = 16M #innodb_additional_mem_pool_size = 2M # Set .._log_file_size to 25 % of buffer pool size #innodb_log_file_size = 5M #innodb_log_buffer_size = 8M #innodb_flush_log_at_trx_commit = 1 #innodb_lock_wait_timeout = 50 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates [myisamchk] key_buffer_size = 8M sort_buffer_size = 8M [mysqlhotcopy] interactive-timeout [tomcat@mylinux mysql]$
查找/etc目录下是否有my.cnf文件;
ls -l | grep my.cnf (在/etc下查找是否有my.cnf文件存在)
拷贝my-small.cnf到etc目录下,名my.cnf:
cp /usr/share/mysql/my-small.cnf /etc/my.cnf
在[mysqld]下面加上设置:
character_set_server = utf8
修改完成之后,重启mysql服务
service mysql restart
7 关闭防火墙 (service iptables stop) 不可取
开启端口:
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT 开放3306端口
service iptables save 保存配置
8 查看mysql的日志 (看mysql的报错等)
cd /var/lib/mysql
9 SQLYoung访问,需要授权
登录mysql后(%是全部ip可登陆,也可换成指定ip/也可以把root用户换成别的用户)
MYSQL--> grant all privileges on *.* to root@'%'
identified by 'root用户密码' with grant option;
flush privileges; 刷新mysql的系统权限相关表
=tomcat安装==================
1 解压tar包
tar -xvf tar包 -C 指定目录
( 解压zip包
unzip )
2 放开端口
iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
service iptables save 保存配置
3 ./ 执行
启动tomcat ./startup.sh
停止tomcat ./shutdown.sh
4 查看日志: tail -f log日志文件