赞
踩
1、Ubuntu安装版本为20.04
2、文中安装包也可以从网盘下载
链接:https://pan.baidu.com/s/1YAXhSByi0fQULPR6lV3yGg
提取码:ubun
3、相关查看命令
# 查看所有服务列表
ubuntu@ubuntu:~/lyqc/mysql$ systemctl list-unit-files
# 利用grep过滤指定服务(如下:查看mysqld服务开机自启动设置)
ubuntu@ubuntu:~/lyqc/mysql$ systemctl list-unit-files | grep mysql
# 查看系统中某个文件或文件夹
ubuntu@ubuntu:~/lyqc/mysql$ find / -name 'my.cnf'
先去Oracle官网下载jdk,本人使用版本为jdk-8u351
将上面的jdk上传到服务器,使用下面命令解压
sudo tar -zxvf jdk-8u351-linux-x64.tar.gz
命令参数解释
参数 | 含义 |
---|---|
tar | Linux压缩/解压缩命令 |
-z | 代表gzip,使用gzip工具进行压缩或解压 (后缀是*.tar.gz *.tar不需要) |
-x | 代表extract,解压文件(压缩文件是-c) |
-v | 代表verbose,显示解压过程(文件列表) |
-f | 代表file,指定要解压的文件名(or 要压缩成的文件名) |
ubuntu@ubuntu:~/lyqc/jdk1.8.0_351$ pwd
/home/ubuntu/lyqc/jdk1.8.0_351
将上面的路径记录下来,后面需要配置环境
vim ~/.bashrc #按键盘上的i进入insert模式
在文件的末尾添加下面内容
#set oracle jdk environment
export JAVA_HOME=/home/ubuntu/lyqc/jdk1.8.0_351 ## 这里要注意目录要换成自己解压的jdk目录
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
按 Esc键盘,输入 :wq 保存并退出
通过输入一下命令,使配置生效
source ~/.bashrc
最后输入 java -version 测试下是否安装成功
ubuntu@ubuntu:~/lyqc/jdk1.8.0_351$ java -version
java version "1.8.0_351"
Java(TM) SE Runtime Environment (build 1.8.0_351-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.351-b10, mixed mode)
ubuntu@ubuntu:~/lyqc/jdk1.8.0_351$
进入mysql官网下载对应的版本
本人下载的版本是5.7.36
使用命令mkdir mysql创建mysql目录,并解压到mysql目录下
tar -xvf mysql-server_5.7.36-1ubuntu18.04_amd64.deb-bundle.tar -C mysql/
查看
ubuntu@ubuntu:~/lyqc$ cd mysql
ubuntu@ubuntu:~/lyqc/mysql$ ls
libmysqlclient20_5.7.36-1ubuntu18.04_amd64.deb mysql-common_5.7.36-1ubuntu18.04_amd64.deb mysql-community-test_5.7.36-1ubuntu18.04_amd64.deb
libmysqlclient-dev_5.7.36-1ubuntu18.04_amd64.deb mysql-community-client_5.7.36-1ubuntu18.04_amd64.deb mysql-server_5.7.36-1ubuntu18.04_amd64.deb
libmysqld-dev_5.7.36-1ubuntu18.04_amd64.deb mysql-community-server_5.7.36-1ubuntu18.04_amd64.deb mysql-testsuite_5.7.36-1ubuntu18.04_amd64.deb
mysql-client_5.7.36-1ubuntu18.04_amd64.deb mysql-community-source_5.7.36-1ubuntu18.04_amd64.deb
ubuntu@ubuntu:~/lyqc/mysql$
sudo dpkg -i mysql-common_5.7.36-1ubuntu18.04_amd64.deb
sudo dpkg -i libmysqlclient20_5.7.36-1ubuntu18.04_amd64.deb
sudo dpkg -i libmysqlclient-dev_5.7.36-1ubuntu18.04_amd64.deb
sudo dpkg -i libmysqld-dev_5.7.36-1ubuntu18.04_amd64.deb
sudo dpkg -i mysql-community-server_5.7.36-1ubuntu18.04_amd64.deb
在安装mysql server这个包的时候 会报依赖错误 暂时先不管
ubuntu@ubuntu:~/lyqc/mysql$ sudo dpkg -i mysql-community-server_5.7.36-1ubuntu18.04_amd64.deb Selecting previously unselected package mysql-community-server. (Reading database ... 74128 files and directories currently installed.) Preparing to unpack mysql-community-server_5.7.36-1ubuntu18.04_amd64.deb ... Unpacking mysql-community-server (5.7.36-1ubuntu18.04) ... dpkg: dependency problems prevent configuration of mysql-community-server: mysql-community-server depends on mysql-client (= 5.7.36-1ubuntu18.04); however: Package mysql-client is not installed. mysql-community-server depends on libmecab2; however: Package libmecab2 is not installed. dpkg: error processing package mysql-community-server (--install): dependency problems - leaving unconfigured Processing triggers for man-db (2.10.2-1) ... Errors were encountered while processing: mysql-community-server
接着我们安装mysql-client 然后此时你会发现 又提示缺少mysql-community-client这个依赖包 继续装
ubuntu@ubuntu:~/lyqc/mysql$ sudo dpkg -i mysql-client_5.7.36-1ubuntu18.04_amd64.deb
Selecting previously unselected package mysql-client.
(Reading database ... 74290 files and directories currently installed.)
Preparing to unpack mysql-client_5.7.36-1ubuntu18.04_amd64.deb ...
Unpacking mysql-client (5.7.36-1ubuntu18.04) ...
dpkg: dependency problems prevent configuration of mysql-client:
mysql-client depends on mysql-community-client (= 5.7.36-1ubuntu18.04); however:
Package mysql-community-client is not installed.
dpkg: error processing package mysql-client (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mysql-client
再安装mysql-community-client,发现又缺少libmecab这个包了
ubuntu@ubuntu:~/lyqc/mysql$ sudo dpkg -i mysql-community-client_5.7.36-1ubuntu18.04_amd64.deb
Selecting previously unselected package mysql-community-client.
(Reading database ... 74296 files and directories currently installed.)
Preparing to unpack mysql-community-client_5.7.36-1ubuntu18.04_amd64.deb ...
Unpacking mysql-community-client (5.7.36-1ubuntu18.04) ...
dpkg: dependency problems prevent configuration of mysql-community-client:
mysql-community-client depends on libtinfo5 (>= 6); however:
Package libtinfo5 is not installed.
dpkg: error processing package mysql-community-client (--install):
dependency problems - leaving unconfigured
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
mysql-community-client
接下来使用命令 apt --fix-broken install 自动解决依赖问题,选择y同意
ubuntu@ubuntu:~/lyqc/mysql$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
libmecab2 libtinfo5
The following NEW packages will be installed:
libmecab2 libtinfo5
0 upgraded, 2 newly installed, 0 to remove and 50 not upgraded.
3 not fully installed or removed.
Need to get 298 kB of archives.
After this operation, 1,432 kB of additional disk space will be used.
Do you want to continue? [Y/n]
ubuntu@ubuntu:~/lyqc/mysql$ mysql -u root -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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>
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> mysql> select User,Host from user; +---------------+-----------+ | User | Host | +---------------+-----------+ | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +---------------+-----------+ 3 rows in set (0.00 sec) mysql>
发现root的Host是localhost 这里需要修改为 ‘%’
%表示哪里都可以访问
mysql> update user set host = '%' where user = 'root'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select User,Host from user; +---------------+-----------+ | User | Host | +---------------+-----------+ | root | % | | mysql.session | localhost | | mysql.sys | localhost | +---------------+-----------+ 3 rows in set (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql>
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address修改为0.0.0.0(表示不限制ip)
保存退出 重启mysql服务
systemctl restart mysql
vi /lib/systemd/system/mysql.service
[Unit]
Description=mysql
After=network.target
[Service]
Type=forking
ExecStart=service mysql start
ExecReload=service mysql restart
ExecStop=service mysql stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 重新加载服务
systemctl daemon-reload
# 设置开机自启动
systemctl enable mysql.service
安装gcc
sudo apt-get install -y gcc
sudo apt-get install -y g++
sudo apt-get install -y gcc automake autoconf libtool make
sudo apt-get install pkg-config
进入redis官网下载对应的版本
使用命令mkdir redis创建redis目录,并解压到redis目录下
tar -zxvf redis-6.2.6.tar.gz
ubuntu@ubuntu:~/lyqc/redis$ ls
bin redis-6.2.6 redis-6.2.6.tar.gz
ubuntu@ubuntu:~/lyqc/redis$
ubuntu@ubuntu:~/lyqc/redis/redis-6.2.6$ ls
00-RELEASENOTES CONDUCT COPYING INSTALL MANIFESTO redis.conf runtest-cluster runtest-sentinel src TLS.md
BUGS CONTRIBUTING deps Makefile README.md runtest runtest-moduleapi sentinel.conf tests utils
ubuntu@ubuntu:~/lyqc/redis/redis-6.2.6$
ubuntu@ubuntu:~/lyqc/redis/redis-6.2.6$
ubuntu@ubuntu:~/lyqc/redis/redis-6.2.6$ sudo make
安装时间稍长 如果出现以下信息则表示编译成功
Hint: It's a good idea to run 'make test' ;)
make install PREFIX=/home/ubuntu/lyqc/redis
出现以下信息表示安装成功
Hint: It's a good idea to run 'make test' ;)
INSTALL redis-server
INSTALL redis-benchmark
INSTALL redis-cli
进入bin目录执行 ./redis-server 即可启动redis
ubuntu@ubuntu:~/lyqc/redis/bin$ ls
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis.conf redis-sentinel redis-server
ubuntu@ubuntu:~/lyqc/redis/bin$ ./redis-server
为了让redis后台启动 我们需要修改bin下面的redis.conf 将 daemonize no -> daemonize yes (no->yes 启动方式由前台启动改为后台启动)
vim redis.conf
修改bind ip地址为0.0.0.0 以便远程连接
输入 ESC -> :wq -> Enter 保存并退出
vi /lib/systemd/system/redis.service
[Unit]
Description=redis
After=network.target
[Service]
Type=forking
ExecStart=/home/ubuntu/lyqc/redis/bin/redis-server /home/ubuntu/lyqc/redis/bin/redis.conf
ExecStop=/home/ubuntu/lyqc/redis/bin/redis-cli shutdown
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 重新加载服务
systemctl daemon-reload
# 设置开机自启动
systemctl enable redis.service
# 1、建立redis文件夹
mkdir /etc/redis
# 2、把redis源码文件中redis.conf复制到/etc/redis/目录下
cp /home/ubuntu/lyqc/redis/bin/redis.conf /etc/redis/6379.conf
# 3、拷贝redis源码中初始化文件redis_init_script到/etc/init.d/redis
cp /home/ubuntu/lyqc/redis/redis-6.2.6/utils/redis_init_script /etc/init.d/redis
# 4、修改/etc/init.d/redis配置文件中EXEC和CLIEXEC与自己路径一致
EXEC=/home/ubuntu/lyqc/redis/bin/redis-server
CLIEXEC=/home/ubuntu/lyqc/redis/bin/redis-cli
# 5、加入开机自启项
chkconfig redis on
# 6、7、然后 vi /etc/rc.d/rc.local 在文件rc.local中添加启动命令 (保证命令可运行)
vi /etc/rc.d/rc.local
/etc/init.d/redis start
rabbitmq使用的语言是erlang 所以需要先安装erlang
官网地址下载对应版本
下载的时候要注意erlang版本和rabbitmq版本对应 可通过地址查看对应关系
执行安装命令
sudo dpkg -i esl-erlang_25.3-1~ubuntu~focal_amd64.deb
命令执行后会出现缺少软件包的错误,可以去地址:https://packages.ubuntu.com/下载对应的安装包 需要注意 ubunut版本20.04对应的focal
然后把所有下载好的deb包放在一起 执行命令安装
sudo dpkg -i *.deb
本人执行的是:
sudo apt-get install libwxbase3.0-0v5
# 按照上面命令执行后的提示 执行下面命令
sudo apt --fix-broken install
执行erl命令查看erl是否安装成功
ubuntu@ubuntu:~/lyqc/rabbitmq$ erl
Erlang/OTP 25 [erts-13.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit:ns]
Eshell V13.2 (abort with ^G)
1> halt().
# halt(). 是erlang的控制台中断语句 注意最后的点号
ubuntu@ubuntu:~/lyqc/rabbitmq$
进入官网下载对应版本的rabbitmq
本人官网打不开,用的下载地址是: https://packagecloud.io/rabbitmq/rabbitmq-server?filter=debs&page=4
下载的版本是rabbitmq-server_3.11.19-1_all.deb
服务器版本不同,下载的rabbitmq描述名称是不同的
# 安装rabbitmq包
sudo dpkg -i rabbitmq-server_3.11.19-1_all.deb
# 设置管理员用户名密码
sudo rabbitmqctl add_user root root
# 授予管理员的访问权限
sudo rabbitmqctl set_user_tags root administrator
# 启用rabbitmq的管理插件
sudo rabbitmq-plugins enable rabbitmq_management
# 重启rabbitmq 使上面更改生效
sudo systemctl restart rabbitmq-server
vi /lib/systemd/system/rabbitmq.service
[Unit]
Description=rabbitmq
After=network.target
[Service]
Type=forking
User=root
Group=root
ExecStart=/usr/sbin/rabbitmq-server -detached
ExecReload=/usr/sbin/rabbitmqctl stop
ExecStop=/usr/sbin/rabbitmqctl stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 重新加载服务
systemctl daemon-reload
# 设置开机自启动
systemctl enable rabbitmq.service
下载nginx相关依赖包
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install zlib1g zlib1g-dev
sudo sudo apt-get install openssl
sudo sudo apt-get install libssl-dev
进入nginx官网下载对应的版本
使用命令mkdir nginx创建nginx目录,并解压到nginx目录下
ubuntu@ubuntu:~/lyqc/nginx$ ls
client_body_temp conf fastcgi_temp html logs nginx-1.20.2 nginx-1.20.2.tar.gz proxy_temp sbin scgi_temp uwsgi_temp
ubuntu@ubuntu:~/lyqc/nginx$
./configure --prefix=/home/ubuntu/lyqc/nginx --with-http_stub_status_module --with-http_ssl_module
说明
参数 | 含义 |
---|---|
–prefix=/home/ubuntu/lyqc/nginx | 指定安装目录为/home/ubuntu/lyqc/nginx。在编译和安装完成后,软件将被安装到该目录下 |
-with-http_stub_status_module | 启用 HTTP Stub Status 模块。该模块是 Nginx 的一个内置模块,用于获取 Nginx 服务器的状态信息 |
–with-http_ssl_module | 启用 HTTP SSL 模块。该模块使得 Nginx 支持通过 HTTPS 提供安全的加密传输 |
# 编译
sudo make
# 安装
sudo make install
# 切换到nginx的安装目录
cd /home/ubuntu/lyqc/nginx/sbin
# 启动nginx
./nginx
vi /lib/systemd/system/nginx.service
[Unit] Description=nginx After=network.target [Service] Type=forking TimeoutSec=0 #防止启动超时 User=root Group=root cription=nacos After=network.target [Service] Type=forking TimeoutSec=0 #防止启动超时 User=root Group=root ExecStart=/home/ubuntu/lyqc/nginx/sbin/nginx ExecReload=/home/ubuntu/lyqc/nginx/sbin/nginx -s reload ExecStop=/home/ubuntu/lyqc/nginx/sbin/nginx -s quit Restart=on-failure PrivateTmp=true [Install] WantedBy=multi-user.target
# 重新加载服务
systemctl daemon-reload
# 设置开机自启动
systemctl enable nginx.service
# 1.切换至java目录 cd /home/java # 2.创建启动脚本 vi jar_start.sh #!/bin/bash export JAVA_HOME=/usr/local/jdk1.8.0_351 #对应的 jdk 位置 export PATH=$JAVA_HOME/bin:$PATH nohup java -jar /home/java/jeecg.jar > /home/java/jeecg.log 2>&1 & echo $! > /home/java/jar_start.pid #将上一次启动的pid 写入到指定文件 # 3.创建结束脚本 vi jar_stop.sh #!/bin/sh PID=$(cat /home/java/jar_start.pid) kill -9 $PID # 4.创建服务单元 vi /lib/systemd/system/jeecg.service # 5.单元内容 [Unit] Description=jeecg_service After=network.target [Service] Type=forking # /bin/bash 下面这个一定要加,之前没有加的时候,报了好久的203错误 ExecStart= /bin/bash /home/java/jar_start.sh ExecStop=/home/java/jar_stop.sh PrivateTmp=true [Install] WantedBy=multi-user.target # 6.重新加载并加入开机自启动 # 重新加载服务 systemctl daemon-reload # 设置开机自启动 systemctl enable jeecg.service
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。