当前位置:   article > 正文

从0开始搭建一台服务器开发环境【中篇】

从0开始搭建一台服务器开发环境【中篇】
4,安装maven
5,安装tomcat
6,安装redis
8,安装mysql
9,安装svn
  • 1
  • 2
  • 3
  • 4
  • 5

【4安装maven】

1,创建一个maven的安装路径

  [root@localhost ~]# mkdir /usr/local/maven
  • 1

2,将下载好的maven安装包上传到maven文件夹,解压:

[root@localhost maven]# wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz

[root@localhost maven]# tar -zxvf apache-maven-3.5.2-bin.tar.gz

[root@localhost maven]#  ls
    apache-maven-3.5.2  apache-maven-3.5.2-bin.tar.gz
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

3,配置maven, 编辑 /etc/profile 文件,尾部添加如下

[root@localhost maven]# vi /etc/profile
  添加如下脚本
 M2_HOME=/usr/local/maven/apache-maven-3.5.2 export
 PATH=${M2_HOME}/bin:${PATH}
  • 1
  • 2
  • 3
  • 4

4,重新加载/etc/profile:

[root@localhost maven]# source /etc/profile
  • 1

5,检查maven是否安装成功:

 [root@localhost maven]# mvn -v
  • 1

Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d;
2019-06-09 T15:58:13+08:00) Maven home:
/usr/local/maven/apache-maven-3.5.2 Java version: 1.8.0_162,
vendor: Oracle Corporation

到此maven安装完毕

【 5,安装tomcat】

1,下载apache-tomcat-8.5.27.tar.gz

[root@localhost ~]# mkdir /usr/local/tomcat
  • 1

2,将下载好的安装包上传到tomcat文件夹,解压:

[root@localhost tomcat]# tar -zxvf apache-tomcat-8.5.27.tar.gz
  • 1

3,设置tomcat的端口80(可选)

[root@localhost tomcat]# vi /usr/local/tomcat/apache-tomcat-8.5.27/conf/server.xml
  • 1

4,配置防火墙,开放端口

[root@localhost tomcat]# firewall-cmd --zone=public --add-port=80/tcp --permanent
  • 1

success

5,重启防火墙

[root@localhost tomcat]# firewall-cmd --reload
  • 1

success

6,启动tomcat:

[root@localhost tomcat]# /usr/local/tomcat/apache-tomcat-8.5.27/bin/startup.sh
  • 1

Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-8.5.27 Using
CATALINA_HOME: /usr/local/tomcat/apache-tomcat-8.5.27 Using
CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-8.5.27/temp Using
JRE_HOME: //usr/local/java/jdk1.8.0_162/jre Using CLASSPATH:
/usr/local/tomcat/apache-tomcat-8.5.27/bin/bootstrap.jar:/usr/local/tomcat/apache-
tomcat-8.5.27/bin/tomcat-juli.jar Tomcat started

7,在浏览器输入:localhost 如果不配置端口:localhost :8080

【6,安装redis】

1.进入并创建/usr/local/redis目录,下载并解压redis文件

[root@localhost ~]#  clear      或  Ctrl + L     【清屏】

[root@localhost ~]# yum -y install gcc gcc-c++ tcl
[root@localhost ~]# mkdir /usr/local/redis
[root@localhost ~]# cd /usr/local/redis


[root@localhost redis]# wget  http://download.redis.io/releases/redis-4.0.9.tar.gz

[root@localhost redis]# tar -zxvf redis-4.0.9.tar.gz

[root@localhost redis]# cd redis-4.0.9
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

2.编译并指定安装

[root@localhost redis-4.0.9]# make

[root@localhost redis-4.0.9]#  make PREFIX=/usr/local/redis install
    CC Makefile.dep

Hint: It's a good idea to run 'make test' ;)

INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install

[root@localhost redis-4.0.9]#  cd /usr/local/redis/bin

[root@localhost bin]# ll
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

-rwxr-xr-x. 1 root root 2451904 4月 3 17:20 redis-benchmark
-rwxr-xr-x. 1 root root 5770200 4月 3 17:20 redis-check-aof
-rwxr-xr-x. 1 root root 5770200 4月 3 17:20 redis-check-rdb
-rwxr-xr-x. 1 root root 2617024 4月 3 17:20 redis-cli lrwxrwxrwx. 1 root root 12 4月 3 17:20 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 5770200 4月 3 17:20 redis-server

3.复制redis.com文件并启动

[root@localhost bin]# cp /usr/local/redis/redis-4.0.9/redis.conf /usr/local/redis

[root@localhost bin]# ./redis-server
  • 1
  • 2
  • 3

在这里插入图片描述

ctrl+C 关闭redis

4.设置后台启动服务

[root@localhost bin]# vim /usr/local/redis/redis.conf 
  • 1

daemonize no 修改为: daemonize yes

[root@localhost bin]# ./redis-server /usr/local/redis/redis.conf (启动redis)  
  • 1

5.查看和停止

[root@localhost bin]# ps aux | grep redis-server (查看服务名)  ps -ef | grep -i redis
  • 1

root 5549 0.1 0.1 145264 7504 ? Ssl 11:15 0:00
redis-server 127.0.0.1:6379 root 5565 0.0 0.0 112676 988
pts/0 S+ 11:22 0:00 grep --color=auto redis-server

[root@localhost bin]# netstat -tunple | grep 6379 (查看端口)
  • 1

tcp 0 0 127.0.0.1:6379 0.0.0.0:*
LISTEN 0 33053 5549/redis-server 1

[root@localhost bin]# redis-cli shutdown (停止redis)
  • 1

[root@localhost bin]# ps aux | grep redis-server root 17245 0.0
0.0 112676 988 pts/0 R+ 17:39 0:00 grep --color=auto redis-server

6.测试

[root@localhost bin]# ./redis-cli 
  • 1

127.0.0.1:6379> ping PONG (连接成功)
127.0.0.1:6379> set 11 “hh” OK
127.0.0.1:6379> get 11"hh"

7.指定IP登录

[root@localhost redis]# vi redis.conf  
  • 1

[ 替换 .conf结尾文件中的内容 :%s/old/new/g]

:%s/6379/6378/g

[快速查找对应关键字—>输入 /关键字]

/bind

修改IP:bind 192.168.234.10 (第69行)

修改Port:6378(第92行)

[root@localhost redis]# ./bin/redis-server /usr/local/redis/redis.conf  重启redis
  • 1

5618:C 11 Apr 21:09:37.574 # oO0OoO0OoO0Oo Redis is starting
oO0OoO0OoO0Oo 5618:C 11 Apr 21:09:37.575 # Redis version=4.0.9,
bits=64, commit=00000000, modified=0, pid=5618, just started 5618:C 11
Apr 21:09:37.575 # Configuration loaded

[root@localhost redis]# ps aux | grep redis-server  查看端口号
  • 1

root 4910 0.1 0.1 145264 7504 ? Ssl 13:33 0:29
./redis-server 127.0.0.1:6378 root 5583 0.0 0.1 145264 7504 ?
Ssl 20:54 0:00 ./redis-server 192.168.234.10:6378 root 5622
0.0 0.0 112676 980 pts/0 R+ 21:09 0:00 grep --color=auto redis-server

[root@localhost redis]# ./bin/redis-cli -h 192.168.234.10 -p 6378
  • 1

192.168.234.10:6378> ping PONG (连接成功)
192.168.234.10:6378> set 11 “hh”
192.168.234.10:6378> get 11 “hh”

8.命令设置密码连接

[root@rabbit1 bin]# ls
  • 1

dump.rdb redis-benchmark redis-check-aof redis-check-rdb redis-cli
redis-sentinel redis-server

[root@rabbit1 bin]# ./redis-cli
  • 1

127.0.0.1:6379> config get requirepass 1) “requirepass” 2) “”
127.0.0.1:6379> config set requirepass admin 配置redis.conf 第500行 OK
127.0.0.1:6379> config get requirepass (error) NOAUTH Authentication required.

127.0.0.1:6379>exit

[root@rabbit1 bin]# ./redis-cli -h 127.0.0.1 -p 6379 -a admin
  • 1

127.0.0.1:6379> config get requirepass 1) “requirepass” 2) “admin”
127.0.0.1:6379>

9,手动配置密码

9.1,编辑配置文件

 vi redis.conf
  • 1

9.2,找到配置文件第500行

命令行模式下输入 set nu 回车 //显示行
  • 1

在这里插入图片描述
9.3,配置密码重启即可

requirepass  passwd
  • 1

10在密码的情况下连接reids

auth passwd
  • 1

【 8,安装mysql】

那天有时间接着写mysql篇

从0开始搭建一台服务器开发环境【开始篇】

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/613189
推荐阅读
相关标签
  

闽ICP备14008679号