[root@VM-0-10-centos ~]# yum list
[root@VM-0-10-centos ~]# yum update -y
输入用户名和密码:root/root
进入选择界面
关闭 CentOS 系统,到设置配置网络连接
重启系统
// 使用 vi 编辑器打开 DNS 解析文件
vi /etc/resolv.conf
// 在文件中配置如下信息(这个是电信的DNS)
nameserver 114.114.114.114
// 使用 vi 编辑器打开网络配置文件
// /etc/sysconfig/network-scripts/ifcfg-xx
// xx 一般是 enp0s3
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
// 将 ONBOOT=no 改为 ONBOOT=yes 并保存
ONBOOT=yes
// 重启网络服务
service network restart
// 查看IP地址
ip addr
yum update
yum install net-tools
替换默认源:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
// 使用 curl 获取
curl http://mirrors.163.com/.help/CentOS7-Base-163.repo -o CentOS7-Base-163.repo
// 清空
yum clean all
// 生成缓存
yum makecache
yum install wget
// 增强
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
cp -r /mnt/cdrom /usr/local/src/VBoxAdditions
yum install -y gcc gcc-devel gcc-c++ gcc-c++-devel make kernel kernel-devel bzip2
/usr/local/src/VBoxAdditions/VBoxLinuxAdditions.run install
// 启用共享文件夹
mkdir /home/www
// mount -t vboxsf 共享的目录对应的名称 共享到虚拟机的目录
mount -t vboxsf pycode /home/www
[root@VM-0-10-centos ~]# yum install -y nodejs
[root@VM-0-10-centos ~]# node -v
v10.24.0
[root@VM-0-10-centos ~]# npm -v
6.14.11
[root@VM-0-10-centos ~]#
[root@VM-0-10-centos ~]# npm install -g cnpm --registry=https://registry.npm.taobao.org
[root@VM-0-10-centos ~]# which cnpm
/usr/local/bin/cnpm
[root@VM-0-10-centos ~]#
[root@VM-0-10-centos ~]# cnpm -v
cnpm@7.1.0 (/usr/local/lib/node_modules/cnpm/lib/parse_argv.js)
npm@6.14.15 (/usr/local/lib/node_modules/cnpm/node_modules/npm/lib/npm.js)
node@10.24.0 (/usr/bin/node)
npminstall@5.3.1 (/usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/index.js)
prefix=/usr/local
linux x64 4.18.0-305.3.1.el8.x86_64
registry=https://registry.npmmirror.com
[root@VM-0-10-centos ~]#
[root@VM-0-10-centos ~]# npm install -g pm2
// 或者
[root@VM-0-10-centos ~]# cnpm install -g pm2
[root@VM-0-10-centos ~]# pm2 -v
5.1.2
[root@VM-0-10-centos ~]#
// 启动 app.js 程序
[root@VM-0-10-centos ~]# pm2 start app.js
// 启动应用程序并命名为 "app"
[root@VM-0-10-centos ~]# pm2 start app.js --name="app"
[root@VM-0-10-centos ~]# pm2 start app.js --name app
// 当文件变化时自动重启应用
[root@VM-0-10-centos ~]# pm2 start app.js --watch
// 启动 bash 脚本文件
[root@VM-0-10-centos ~]# pm2 start upload.sh
// 启动多个进程
// -i 2 表示启动 2 个名为 app 的 node 进程
// i 是 instance 实例
pm2 start app.js --name app -i 2
// max 表示 pm2 将自动检测可用 CPU 的核数并允许尽可能多的进程
pm2 start app.js --name app -i max
// pm2 启动 TS 文件
pm2 start --interpreter ./node_modules/.bin/ts-node app.ts
pm2 start --interpreter ./node_modules/.bin/ts-node app.ts --name app -i 2 --watch
// 停止 id 为 0 的进程
[root@VM-0-10-centos ~]# pm2 stop 0
// 停止所有进程
[root@VM-0-10-centos ~]# pm2 stop [all]
// 重启进程 ID为 0 的进程
[root@VM-0-10-centos ~]# pm2 restart 0
// 重启所有进程
[root@VM-0-10-centos ~]# pm2 restart [all]
// 删除进程 ID为 0 的进程
[root@VM-0-10-centos ~]# pm2 delete 0
// 删除所有进程
// 进程删除后无法重启再用
[root@VM-0-10-centos ~]# pm2 restart [all]
[root@VM-0-10-centos ~]# pm2 list
// 查看资源消耗情况
[root@VM-0-10-centos ~]# pm2 monit
// 查看所有日志
[root@VM-0-10-centos ~]# pm2 log
// 显示指定应用程序的日志
[root@VM-0-10-centos ~]# pm2 log [app-name]
[root@VM-0-10-centos ~]# pm2 flush
// 显示应用程序所有信息
[root@VM-0-10-centos ~]# pm2 show [app-name]
// 查看进程ID为 0 的进程信息
[root@VM-0-10-centos ~]# pm2 info 0
module.exports = {
apps: [{
name: 'app',
script: './src/app.ts',
watch: true,
ignore_watch: ['logs', 'node_modules'],
out_file: 'logs/out/out.log',
error_file: 'logs/error/error.log',
interpreter: './node_modules/.bin/ts-node',
instance: 3,
autorestart: true,
exec_mode: 'cluster',
env: {
NODE_ENV: 'prod',
port: '3001'
}
}]
}
[root@VM-0-10-centos ~]# yum install -y nginx
[root@VM-0-10-centos ~]# nginx -v
nginx version: nginx/1.14.1
[root@VM-0-10-centos ~]#
[root@VM-0-10-centos ~]# nginx
[root@VM-0-10-centos ~]# nginx -s stop
[root@VM-0-10-centos ~]# nginx -s reload
// 或者
[root@VM-0-10-centos ~]# systemctl restart nginx
[root@VM-0-10-centos /]# cd /home/front/
[root@VM-0-10-centos front]# mkdir nginx
[root@VM-0-10-centos front]# ll
总用量 4
drwxr-xr-x 2 root root 4096 12月 4 10:59 nginx
[root@VM-0-10-centos front]# cd nginx/
[root@VM-0-10-centos nginx]# touch nginx.conf
[root@VM-0-10-centos nginx]# ll
总用量 0
-rw-r--r-- 1 root root 0 12月 4 10:59 nginx.conf
[root@VM-0-10-centos nginx]#
[root@VM-0-10-centos nginx]# cd /etc/nginx/
[root@VM-0-10-centos nginx]# ll
总用量 76
-rw-r--r-- 1 root root 2469 10月 8 2019 nginx.conf
-rw-r--r-- 1 root root 2656 10月 8 2019 nginx.conf.default
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
### 1、指定 user 为 root
user root;
worker_processes auto;
### 2、指定nginx错误时日志文件路径
error_log /home/nginx/logs/error.log;
# pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
### 3、指定根路径为:root /home/front; 及 index index.html index.htm;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
# root /usr/share/nginx/html;
root /home/front;
index index.html index.htm;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
# location / {
# }
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers PROFILE=SYSTEM;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
### 4、 主配置文件需要合并/home/nginx/nginx.conf文件
include /home/nginx/*.conf;
}
[root@VM-0-10-centos nginx]# cd /home/nginx/
[root@VM-0-10-centos nginx]# mkdir logs
[root@VM-0-10-centos nginx]# cd logs
[root@VM-0-10-centos logs]# touch error.log
[root@VM-0-10-centos logs]# ll
总用量 4
-rw-r--r-- 1 root root 2390 12月 4 13:44 error.log
[root@VM-0-10-centos logs]#
[root@VM-0-10-centos logs]# cd ../
[root@VM-0-10-centos nginx]# ll
总用量 8
drwxr-xr-x 2 root root 4096 12月 4 11:52 logs
-rw-r--r-- 1 root root 231 12月 4 11:43 nginx.conf
[root@VM-0-10-centos nginx]# vi nginx.conf
### 子配置文件
server {
listen 80;
server_name localhost;
root /home/front;
# autoindex on;
add_header Cache-Control "no-cache, must-revalidate";
location / {
add_header Access-Control-Allow-Origin *;
}
}
[root@VM-0-10-centos front]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@VM-0-10-centos front]#
nginx: [error] invalid PID number "" in "/run/nginx.pid"
需要执行如下代码
// /etc/nginx/nginx.conf 是主配置文件
[root@VM-0-10-centos front]# nginx -c /etc/nginx/nginx.conf
// 然后重启
[root@VM-0-10-centos front]# nginx -s reload
如果还不成功,查看 Nginx 进程,然后关闭 nginx 进程再重启 nginx
[root@VM-0-10-centos front]# ps -ef|grep nginx
root 978504 1 0 14:14 ? 00:00:00 nginx: master process nginx
root 990563 978504 0 14:20 ? 00:00:00 nginx: worker process
root 1014622 852386 0 14:31 pts/0 00:00:00 grep --color=auto nginx
[root@VM-0-10-centos front]# sudo kill -quit 978504
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
// 注意:我们要安装的是 MySQL 服务端
// 如果输入的是 mysql,则只会安装客户端
[root@VM-0-10-centos home]# yum install mysql-server
完毕!
[root@VM-0-10-centos home]# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@VM-0-10-centos home]#
[root@VM-0-10-centos home]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: inactive (dead)
[root@VM-0-10-centos home]#
[root@VM-0-10-centos home]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
[root@VM-0-10-centos home]#
[root@VM-0-10-centos home]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26 Source distribution
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>
[root@VM-0-10-centos home]# cat /var/log/mysqld.log |grep password
[root@VM-0-10-centos home]# mysql -u root -p
[root@VM-0-10-centos home]# show databsaes;
mysql> alter user 'root'@'localhost' identified by '设置密码示例:test123123.';
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
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
// % 是通配符,表示匹配所有IP
// 使用 mysql_native_password 插件进行验证(与 v8.0 之前的不同了)
// 密码可以使用原来的,也可以设置简单的 123456
mysql> create user 'root'@'%' identified with mysql_native_password by 'lgk123123';
Query OK, 0 rows affected (0.01 sec)
// 赋予所有权限给 'root'@'%'
mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.01 sec)
// 使设置生效
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
// 退出 MySQL
mysql> exit;
[root@VM-0-10-centos home]# mysql --version
mysql Ver 8.0.26 for Linux on x86_64 (Source distribution)
[root@VM-0-10-centos home]#
yum remove mariadb-libs.x86_64
wget https://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install mysql-community-server
service mysqld start
cat /var/log/mysqld.log | grep "password"
mysql -uroot -p
show variables like 'validate_password%';
set global validate_password_length=6;
set global validate_password_mixed_case_count=0;
set global validate_special_char_count=0;
......
flush privileges;
alter user 'root'@'localhost' identified by '123456';
[root@VM-0-10-centos home]# cd resources/
[root@VM-0-10-centos resources]# ll
总用量 70384
-rw-r--r-- 1 root root 72072638 12月 4 16:24 mongodb-linux-x86_64-rhel80-4.4.10.tgz
[root@VM-0-10-centos resources]#
[root@VM-0-10-centos resources]# tar -zxvf mongodb-linux-x86_64-rhel80-4.4.10.tgz
[root@VM-0-10-centos resources]# ll
总用量 70388
drwxr-xr-x 3 root root 4096 12月 4 16:26 mongodb-linux-x86_64-rhel80-4.4.10
-rw-r--r-- 1 root root 72072638 12月 4 16:24 mongodb-linux-x86_64-rhel80-4.4.10.tgz
[root@VM-0-10-centos resources]#
[root@VM-0-10-centos resources]# cd /usr/local/
[root@VM-0-10-centos local]# mkdir mongodb
[root@VM-0-10-centos local]# ll
总用量 48
drwxr-xr-x. 2 root root 4096 12月 4 09:40 bin
drwxr-xr-x. 2 root root 4096 6月 22 13:06 etc
drwxr-xr-x. 2 root root 4096 6月 22 13:06 games
drwxr-xr-x. 2 root root 4096 6月 22 13:06 include
drwxr-xr-x. 4 root root 4096 12月 4 09:14 lib
drwxr-xr-x. 4 root root 4096 6月 22 13:06 lib64
drwxr-xr-x. 2 root root 4096 6月 22 13:06 libexec
drwxr-xr-x 2 root root 4096 12月 4 16:29 mongodb
drwxr-xr-x 16 root root 4096 12月 3 20:54 qcloud
drwxr-xr-x. 2 root root 4096 6月 22 13:06 sbin
drwxr-xr-x. 5 root root 4096 6月 22 13:06 share
drwxr-xr-x. 2 root root 4096 6月 22 13:06 src
srwxrwxrwx 1 root root 0 12月 3 20:54 yd.socket.server
[root@VM-0-10-centos local]#
[root@VM-0-10-centos mongodb-linux-x86_64-rhel80-4.4.10]# cp -r bin/ /usr/local/mongodb/
[root@VM-0-10-centos mongodb-linux-x86_64-rhel80-4.4.10]# cp -r LICENSE-Community.txt /usr/local/mongodb/
[root@VM-0-10-centos mongodb-linux-x86_64-rhel80-4.4.10]# cp -r MPL-2 /usr/local/mongodb/
[root@VM-0-10-centos mongodb-linux-x86_64-rhel80-4.4.10]# cp -r README /usr/local/mongodb/
[root@VM-0-10-centos mongodb-linux-x86_64-rhel80-4.4.10]# cp -r THIRD-PARTY-NOTICES /usr/local/mongodb/
[root@VM-0-10-centos mongodb-linux-x86_64-rhel80-4.4.10]# cd /usr/local/mongodb/
[root@VM-0-10-centos mongodb]# ll
总用量 136
drwxr-xr-x 2 root root 4096 12月 4 16:38 bin
-rw-r--r-- 1 root root 30608 12月 4 16:39 LICENSE-Community.txt
-rw-r--r-- 1 root root 16726 12月 4 16:39 MPL-2
-rw-r--r-- 1 root root 1977 12月 4 16:39 README
-rw-r--r-- 1 root root 75685 12月 4 16:40 THIRD-PARTY-NOTICES
[root@VM-0-10-centos mongodb]#
[root@VM-0-10-centos mongodb]# export PATH=/usr/local/mongodb/bin:$PATH
[root@VM-0-10-centos mongodb]#
// 数据存储目录
[root@VM-0-10-centos mongodb]# mkdir data
// 日志文件目录
[root@VM-0-10-centos mongodb]# mkdir logs
[root@VM-0-10-centos mongodb]# cd logs/
// 在 logs 目录下创建 mongod.log 文件用于存储日志
[root@VM-0-10-centos logs]# touch mongod.log
[root@VM-0-10-centos logs]#
[root@VM-0-10-centos logs]# sudo chown `whoami` /usr/local/mongodb/data
[root@VM-0-10-centos logs]# sudo chown `whoami` /usr/local/mongodb/logs/mongod.log
[root@VM-0-10-centos logs]#
[root@VM-0-10-centos logs]# mongod --dbpath /usr/local/mongodb/data --logpath /usr/local/mongodb/logs/mongod.log --fork
[root@VM-0-10-centos logs]# tail -10f /usr/local/mongodb/logs/mongod.log
{"t":{"$date":"2021-12-04T16:57:52.197+08:00"},"s":"I", "c":"FTDC", "id":20625, "ctx":"initandlisten","msg":"Initializing full-time diagnostic data capture","attr":{"dataDirectory":"/usr/local/mongodb/data/diagnostic.data"}}
{"t":{"$date":"2021-12-04T16:58:52.158+08:00"},"s":"I", "c":"STORAGE", "id":22430, "ctx":"WTCheckpointThread","msg":"WiredTiger message","attr":{"message":"[1638608332:158320][1324308:0x7f8b7f2aa700], WT_SESSION.checkpoint: [WT_VERB_CHECKPOINT_PROGRESS] saving checkpoint snapshot min: 34, snapshot max: 34 snapshot count: 0, oldest timestamp: (0, 0) , meta checkpoint timestamp: (0, 0) base write gen: 1"}}
[root@VM-0-10-centos logs]# mongo
MongoDB shell version v4.4.10
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("c469261f-dcd0-4f6c-a27a-3fc97c4d4f4c") }
MongoDB server version: 4.4.10
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
https://community.mongodb.com
---
> show databases;
admin 0.000GB
config 0.000GB
local 0.000GB
>
[root@VM-0-10-centos resources]# yum -y install git
完毕!
[root@VM-0-10-centos resources]# git --version
git version 2.27.0
[root@VM-0-10-centos resources]#
[root@VM-0-10-centos resources]# yum remove git
[root@VM-0-10-centos resources]# yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel
// 通过源码编译的方式再安装 git
[root@VM-0-10-centos resources]# yum install - y gcc perl-ExtUtils-MakeMaker
[root@VM-0-10-centos resources]# yum install -y tcl build-essential tk gettext
[root@VM-0-10-centos resources]# wget https://github.com/git/git/archive/v2.27.0.tar.gz
[root@VM-0-10-centos resources]# tar -zxvf v2.27.0.tar.gz
[root@VM-0-10-centos resources]# cd git-2.27.0
// 编译时指定安装后的可执行文件位于哪
[root@VM-0-10-centos git-2.27.0]# make prefix=/usr/local/git all
[root@VM-0-10-centos git-2.27.0]# make prefix=/usr/local/git install
// 进入 /usr/bin
[root@VM-0-10-centos git-2.27.0]# cd /usr/bin
// 制作软连接
[root@VM-0-10-centos bin]# ln -s /usr/local/git/bin/git git
[root@VM-0-10-centos resources]# git --version
git version 2.27.0
[root@VM-0-10-centos resources]#
// 通过 ssh-keygen 生成免密登录的密钥
// 通过 -C 属性去填写 git 仓库的用户名
ssh-keygen -t rsa -C “1910184628@qq.com”
// 点击三次回车将密钥生成
// 将密钥打印在终端上面
cat ~/.ssh/id_rsa.pub
// 复制密钥后进入 Gitee 仓库 “我的设置”添加密钥
// 将密钥粘贴到密钥内容上
git clone git@gitee.com:lgk2021/项目名.git
// 进入要更新源码的目录下,执行
git pull
[root@VM-0-2-centos /]# yum list java*
[root@VM-0-2-centos local]# yum install -y java-1.8.0-openjdk.x86_64
// 或者
// 第二种会将很多的东西都安装,如果第一种不成功再考虑第二种方式
[root@VM-0-2-centos /]# yum install -y java-1.8.0-openjdk*
[root@VM-0-2-centos /]# java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)
[root@VM-0-2-centos /]#
[root@VM-0-2-centos /]# cd /home/
[root@VM-0-2-centos home]# ll
总用量 199204
-rw-r--r-- 1 root root 188743215 12月 18 13:56 jdk-13.0.1_linux-x64_bin.tar.gz
[root@VM-0-2-centos home]#
[root@VM-0-2-centos home]# tar -zxvf jdk-13.0.1_linux-x64_bin.tar.gz
[root@VM-0-2-centos home]# ll
总用量 199208
drwxr-xr-x 9 root root 4096 12月 18 15:34 jdk-13.0.1
-rw-r--r-- 1 root root 188743215 12月 18 13:56 jdk-13.0.1_linux-x64_bin.tar.gz
[root@VM-0-2-centos home]#
[root@VM-0-2-centos home]# mv jdk-13.0.1/ /usr/local/
[root@VM-0-2-centos home]# ll
总用量 199204
-rw-r--r-- 1 root root 188743215 12月 18 13:56 jdk-13.0.1_linux-x64_bin.tar.gz
[root@VM-0-2-centos home]# cd /usr/local/
[root@VM-0-2-centos home]# cd /usr/local/
[root@VM-0-2-centos local]# ll
总用量 56
drwxr-xr-x. 2 root root 4096 11月 3 2020 bin
drwxr-xr-x. 2 root root 4096 11月 3 2020 etc
drwxr-xr-x. 2 root root 4096 11月 3 2020 games
drwxr-xr-x. 2 root root 4096 11月 3 2020 include
drwxr-xr-x 9 root root 4096 12月 18 15:34 jdk-13.0.1
[root@VM-0-2-centos local]#
[root@VM-0-2-centos local]# vi ~/.bash_profile
JAVA_HOME=/usr/local/jdk-13.0.1
PATH=$JAVA_HOME/bin:$PATH
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
JAVA_HOME=/usr/local/jdk-13.0.1
PATH=$JAVA_HOME/bin:$PATH
export PATH
~
[root@VM-0-2-centos local]# source ~/.bash_profile
[root@VM-0-2-centos local]# java -version
java version "13.0.1" 2019-10-15
Java(TM) SE Runtime Environment (build 13.0.1+9)
Java HotSpot(TM) 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)
[root@VM-0-2-centos local]#
[root@VM-0-2-centos /]# rpm -qa|grep java
[root@VM-0-2-centos /]# rpm -qa|grep jdk
[root@VM-0-2-centos /]# rpm -qa|grep gcj
[root@VM-0-2-centos /]# rpm -qa | grep java | xargs rpm -e --nodeps
[root@VM-0-2-centos /]# yum -y remove java-1.8.0-openjdk*
[root@VM-0-2-centos local]# vi ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
# JAVA_HOME=/usr/local/jdk-13.0.1
# PATH=$JAVA_HOME/bin:$PATH
export PATH
~
[root@VM-0-2-centos local]# source ~/.bash_profile
[root@VM-0-2-centos /]# java -version
-bash: /usr/bin/java: 没有那个文件或目录
[root@VM-0-2-centos /]#
[root@VM-0-2-centos /]# cd /home/
[root@VM-0-2-centos home]# ll
总用量 193664
-rw-r--r-- 1 root root 9552281 12月 18 16:11 apache-tomcat-8.5.31.tar.gz
-rw-r--r-- 1 root root 188743215 12月 18 13:56 jdk-13.0.1_linux-x64_bin.tar.gz
[root@VM-0-2-centos home]#
[root@VM-0-2-centos home]# tar -zxvf apache-tomcat-8.5.31.tar.gz
[root@VM-0-2-centos home]# ll
总用量 193668
drwxr-xr-x 9 root root 4096 12月 18 16:12 apache-tomcat-8.5.31
-rw-r--r-- 1 root root 9552281 12月 18 16:11 apache-tomcat-8.5.31.tar.gz
-rw-r--r-- 1 root root 188743215 12月 18 13:56 jdk-13.0.1_linux-x64_bin.tar.gz
[root@VM-0-2-centos home]#
[root@VM-0-2-centos home]# mv apache-tomcat-8.5.31 /usr/local/
[root@VM-0-2-centos home]# ll
总用量 193664
-rw-r--r-- 1 root root 9552281 12月 18 16:11 apache-tomcat-8.5.31.tar.gz
-rw-r--r-- 1 root root 188743215 12月 18 13:56 jdk-13.0.1_linux-x64_bin.tar.gz
[root@VM-0-2-centos home]#
[root@VM-0-2-centos home]# cd /usr/local/
[root@VM-0-2-centos local]# ll
总用量 60
drwxr-xr-x 9 root root 4096 12月 18 16:12 apache-tomcat-8.5.31
drwxr-xr-x. 2 root root 4096 11月 3 2020 bin
drwxr-xr-x. 2 root root 4096 11月 3 2020 etc
drwxr-xr-x. 2 root root 4096 11月 3 2020 games
drwxr-xr-x. 2 root root 4096 11月 3 2020 include
drwxr-xr-x 9 root root 4096 12月 18 15:34 jdk-13.0.1
[root@VM-0-2-centos local]#
[root@VM-0-2-centos local]# cd apache-tomcat-8.5.31/bin/
[root@VM-0-2-centos bin]# ll
总用量 836
-rw-r----- 1 root root 34985 4月 28 2018 bootstrap.jar
-rw-r----- 1 root root 15900 4月 28 2018 catalina.bat
-rwxr-x--- 1 root root 23463 4月 28 2018 catalina.sh
-rw-r----- 1 root root 1664 4月 28 2018 catalina-tasks.xml
-rw-r----- 1 root root 25145 4月 28 2018 commons-daemon.jar
-rw-r----- 1 root root 207125 4月 28 2018 commons-daemon-native.tar.gz
-rw-r----- 1 root root 2040 4月 28 2018 configtest.bat
-rwxr-x--- 1 root root 1922 4月 28 2018 configtest.sh
-rwxr-x--- 1 root root 8509 4月 28 2018 daemon.sh
-rw-r----- 1 root root 2091 4月 28 2018 digest.bat
-rwxr-x--- 1 root root 1965 4月 28 2018 digest.sh
-rw-r----- 1 root root 3574 4月 28 2018 setclasspath.bat
-rwxr-x--- 1 root root 3680 4月 28 2018 setclasspath.sh
-rw-r----- 1 root root 2020 4月 28 2018 shutdown.bat
-rwxr-x--- 1 root root 1902 4月 28 2018 shutdown.sh
-rw-r----- 1 root root 2022 4月 28 2018 startup.bat
-rwxr-x--- 1 root root 1904 4月 28 2018 startup.sh
-rw-r----- 1 root root 49336 4月 28 2018 tomcat-juli.jar
-rw-r----- 1 root root 405109 4月 28 2018 tomcat-native.tar.gz
-rw-r----- 1 root root 4574 4月 28 2018 tool-wrapper.bat
-rwxr-x--- 1 root root 5483 4月 28 2018 tool-wrapper.sh
-rw-r----- 1 root root 2026 4月 28 2018 version.bat
-rwxr-x--- 1 root root 1908 4月 28 2018 version.sh
[root@VM-0-2-centos bin]#
[root@VM-0-2-centos bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/apache-tomcat-8.5.31
Using CATALINA_HOME: /usr/local/apache-tomcat-8.5.31
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.5.31/temp
Using JRE_HOME: /usr/local/jdk-13.0.1
Using CLASSPATH: /usr/local/apache-tomcat-8.5.31/bin/bootstrap.jar:/usr/local/apache-tomcat-8.5.31/bin/tomcat-juli.jar
Tomcat started.
[root@VM-0-2-centos bin]#
tar -zxvf redis-7.0.5.tar.gz -C ./
make
[root@VM-0-10-centos redis-7.0.5]# ln -s /opt/redis-7.0.5/src/redis-server /usr/local/bin
[root@VM-0-10-centos redis-7.0.5]# ln -s /opt/redis-7.0.5/src/redis-cli /usr/local/bin/
// 通过 vi 命令打开 redis.conf 配置文件
[root@VM-0-10-centos redis-7.0.5]# vi redis.conf
// 通过 :set nu 命令显示文本行数
// 通过 / daemonize 搜索 daemonize 并将其值改为 yes
// daemonize 是用来指定 redis 是否要用守护线程的方式启动
// 当使用 yes 时,redis 会在后台一直运行,直到手动 kill 该进程
// 当使用 no 时,关闭当前 redis 启动界面或者 exit 强制退出或关闭 Shell 都会导致 redis 进程退出
daemonize yes
// 将 bind 127.0.0.1 改成 bind 0.0.0.0
// 因为默认的 127.0.0.1 redis 服务器只能被本机访问
bind 0.0.0.0 -::1
// 关闭保护模式,允许客户端访问
pertected-mode no
// 增加连接 redis 服务器需要的认证密码
requirepass 123456
// 查看 python 版本
[root@localhost ~]# python --version
Python 2.7.5
[root@localhost ~]#
// 安装 Python3
[root@localhost ~]# yum install python3
[root@localhost ~]# python3 --version
Python 3.6.8
[root@localhost ~]#
安装 Virtualenv:
// 或者 pip
[root@localhost ~]# pip3 install virtualenv
[root@localhost ~]# virtualenv --version
virtualenv 20.17.1 from /usr/local/lib/python3.6/site-packages/virtualenv/__init__.py
[root@localhost ~]# find / -name virtualenv
/usr/local/bin/virtualenv
/usr/local/lib/python3.6/site-packages/virtualenv
[root@localhost ~]# ln -s /usr/local/lib/python3.6/site-packages/virtualenv /usr/bin/virtualenv
// venv 是虚拟环境名称,路径和名称自定义
[root@localhost ~]# virtualenv -p /usr/bin/python3 venv
[root@localhost venv]# which python
/usr/bin/python
[root@localhost venv]# which python3
/usr/bin/python3
[root@localhost ~]# source v_env/bin/activate
[root@localhost ~]#
(v_env) [root@localhost ~]# which python
/root/v_env/bin/python
(v_env) [root@localhost ~]# which python3
/root/v_env/bin/python3
(v_env) [root@localhost ~]#