Linux系列讲义---Linux常用软件安装(四)

1.安装JDK

1.检查已经安装的jdk

[root@hadoop ~]# java -version
java version "1.7.0_45"
OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

2.卸载OpenJDK

[root@hadoop ~]# rpm -qa|grep jdk
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
卸载:
[root@hadoop ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
[root@hadoop ~]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
再次查看:
[root@hadoop ~]# rpm -qa|grep jdk

3.使用ftp工具上传jdk-7u45-linux-x64.tar.gz到/upload目录下

[root@hadoop ~]# cd /
[root@hadoop /]# mkdir upload

4.解压jdk到/usr/local目录

[root@hadoop /]# cd upload/
[root@hadoop upload]# tar -zxvf jdk-7u80-linux-x64.tar.gz -C /usr/local/

5.设置环境变量

[root@hadoop /]# vim /etc/profile
在/etc/profile文件最后追加相关内容:
export JAVA_HOME=/usr/local/jdk1.7.0_80
export PATH=$JAVA_HOME/bin:$PATH

6.刷新环境变量

[root@hadoop /]# source /etc/profile

7.检查是否安装成

[root@hadoop /]# java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

2.安装Tomcat

1.上传apache-tomcat-7.0.68.tar.gz到Linux上
2.解压tomcat

[root@hadoop /]# cd /upload/
[root@hadoop upload]# tar -zxvf apache-tomcat-7.0.70.tar.gz -C /usr/local/ 

3.启动tomcat

[root@hadoop bin]# ./startup.sh 
Using CATALINA_BASE:   /usr/local/apache-tomcat-7.0.70
Using CATALINA_HOME:   /usr/local/apache-tomcat-7.0.70
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.70/temp
Using JRE_HOME:        /usr/local/jdk1.7.0_80
Using CLASSPATH:       /usr/local/apache-tomcat-7.0.70/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.70/bin/tomcat-juli.jar
Tomcat started.

4.查看tomcat进程是否启动

[root@hadoop bin]# jps
24491 Jps
24472 Bootstrap

5.通过浏览器访问tomcathttp://192.168.100.10:8080/
在这里插入图片描述
专注于IT技术知识梳理,书写前沿技术文章!更多技术在这里慢慢探索吧,请关注杰哥!

关注公众号 回复口令【linux】,即可获取全部linux教程资料
在这里插入图片描述

3.安装MySQL

1.上传MySQL-client-5.5.52-1.linux2.6.x86_64.rpm、MySQL-server-5.5.52-1.linux2.6.x86_64.rpm到Linux上

2.卸载CentOS上预装的mysql

查看已安装:
[root@hadoop /]#rpm -qa|grep -i mysql
                 
mysql-libs-5.1.71-1.el6.x86_64
卸载:
[root@hadoop /]#rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
再次查看:
[root@hadoop /]# rpm -qa|grep -i mysql

3.安装MySQL-server

[root@hadoop /]# cd /upload/
[root@hadoop upload]# rpm -ivh MySQL-server-5.5.52-1.linux2.6.x86_64.rpm
warning: MySQL-server-5.5.52-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
170104  6:48:26 [Note] /usr/sbin/mysqld (mysqld 5.5.52) starting as process 24568 ...
170104  6:48:26 [Note] /usr/sbin/mysqld (mysqld 5.5.52) starting as process 24575 ...
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h hadoop password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/

4.安装MySQL-client

[root@hadoop upload]#rpm -ivh MySQL-client-5.5.52-1.linux2.6.x86_64.rpm
warning: MySQL-client-5.5.52-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]

5.启动MySQL服务

[root@hadoop upload]#service mysql start
Starting MySQL..                                           [确定]

6.初始化MySQL

[root@hadoop upload]# /usr/bin/mysql_secure_installation
运行mysql_secure_installation会执行几个设置:
a)为root用户设置密码 Y
b)删除匿名账号 Y
c)取消root用户远程登录 N
d)删除test库和对test库的访问权限 Y
e)刷新授权表使修改生效 Y

7.测试MySQL

[root@hadoop upload]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.5.52 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

8.设置开机启动

[root@hadoop upload]# chkconfig mysql on

补充:
1、设置MySQL的root用户设置密码
[root@stonex ~]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> select user,host,password from mysql.user;
查询用户的密码,都为空,用下面的命令设置root的密码为root
mysql> set password for root@localhost=password(‘root’);
mysql> exit;
2、用新密码登陆
[root@stonex ~]# mysql -u root -p
3、基本命令
show databases; //查看系统已存在的数据库
use databasesname; //选择需要使用的数据库
drop database databasename; //删除选定的数据库
exit //退出数据库的连接
create database test01; //建立名为test的数据库
show tables; // 列出当前数据库下的表
其他基本的增删改查使用标准SQL即可
4、开放远程登录权限
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;
FLUSH PRIVILEGES;

4.安装Nginx

1.上传nginx-1.8.1.tar.gz到Linux上

2.解压nginx

[root@hadoop upload]# tar -zxvf nginx-1.8.1.tar.gz -C /usr/local/src

3.编译nginx

[root@hadoop upload]# cd /usr/local/src/nginx-1.8.1/
[root@hadoop nginx-1.8.1]# ./configure --prefix=/usr/local/nginx-1.8.1
checking for OS
 + Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
#缺包报错 ./configure: error: C compiler cc is not found
#使用YUM安装缺少的包
[root@hadoop nginx-1.8.1]# yum -y install gcc pcre-devel openssl openssl-devel
再次执行:
[root@hadoop nginx-1.8.1]# ./configure --prefix=/usr/local/nginx-1.8.1

4.编译安装nginx

[root@hadoop nginx-1.8.1]# make && make install

5.启动nginx

[root@hadoop sbin]# cd /usr/local/nginx-1.8.1/sbin
[root@hadoop sbin]# ./nginx

6.访问http://192.168.100.10

在这里插入图片描述
补充:
nginx -s reload :修改配置后重新加载生效
nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

关闭nginx:
nginx -s stop 快速停止nginx
nginx -squit 完整有序的停止nginx

其他的停止nginx 方式:
ps -ef | grep nginx查看nginx进程

kill -QUIT 主进程号 从容停止Nginx
kill -TERM 主进程号 快速停止Nginx
kill -9 nginx 强制停止Nginx

启动nginx:
nginx -c /path/to/nginx.conf
平滑重启nginx:
kill -HUP 主进程号
专注于IT技术知识梳理,书写前沿技术文章!更多技术在这里慢慢探索吧,请关注杰哥!

关注公众号 回复口令【linux】,即可获取全部linux教程资料
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

贝西奇谈

你的鼓励将是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值