记一次阿里云服务器的环境配置

---安装git---
yum -y install git

---ssh设置公钥连接---
检查sshd状态
status sshd.service
新建sshd_config文件:
vim /etc/ssh/sshd_config
配置如下:
##修改端口2207
Port 2207
AddressFamily Any
ListenAddress 0.0.0.0
Protocol 2
LoginGraceTime 2m
StrictModes no
MaxAuthTries 6
#MaxSessions 10
##允许ras认证,公钥认证,指定公钥地址
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PermitEmptyPasswords no
##不允许root密码登录
PermitRootLogin no
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes
UsePAM yes
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
X11Forwarding yes
Subsystem sftp /usr/libexec/openssh/sftp-server
UseDNS no
SyslogFacility AUTHPRIV
PasswordAuthentication no

重启sshd服务
systemctl restart sshd.service

切换到用来登录的用户ninja
在/home/ninja/.ssh 下新建authorized_keys文件,放入公钥
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1pirm8sx1vYXDgvpq0uoUXAAuwKGAWPd8y3vYqbvnkUrmiMJeSQBf1Sdzg6qLYx8ZdLUEJ6/d7D3VAyvdBz8yhL9G3m/2SrIlqMLY5gTxHSRkcQnKzsaDaiNcyXA9WKqjJqiGV3RZEz5iXNHz7zUWxa95aQy/HQCy5IvLXwpc/PxCQ+WEePzEjAGu3DlpNtuVKoIzHL1kU/5HNb1/ehbroxxiJIfKKsfeDjQlvrJK55PfnXvdfsnawi0upYuiBN125ZX6255+ic+RKPJdBh6dYMMCVx2vtRbIHksPqVCmdXVSLrRhh/Q18EKlRVr1iEm2/OioTGjxVnIzqlsrIuXX baijiantao@baijiantaodeMacBook-Pro.local

或者从公钥导入:
touch /home/zhangsan/.ssh/authorized_keys

cat /root/.ssh/id_rsa.pub > /home/zhangsan/.ssh/authorized_keys

设置.ssh的操作权限:
chmod 700 .ssh
设置.ssh/authorized_keys的操作权限
chmod 600 .ssh/authorized_keys

注意:如果还是失败,注意你的阿里云防火墙是否拦截登录端口了。root用户的.ssh是在/root位置,其他用户在/home/用户名/位置


--- 安装配置redis ---
yum安装redis
yum install redis
如果找不到,可以先安装一个epel源,它配置了一些yum软件地址
yum install epel-release
启动redis
systemctl start redis
检查redis状态
systemctl status redis
停止服务
systemctl stop redis
重启服务
systemctl restart redis
查看redis进程
ps -ef | grep redis
设置开机启动
systemctl enable redis

修改redis配置:
vim /etc/redis.conf
几个点:
bind 127.0.0.1 要注释掉,否则只能本机使用
protected-mode no 保护模式设置为no
port 6379 如果要修改端口改这里
requirepass root 修改密码为root

重启redis
systemctl restart redis
进入redis
rediscli
验证
info

--- 安装配置ngix ----
安装可能需要的命令
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
安装ngix
yum install -y nginx
启动nginx
systemctl start nginx.service
配置ngix:
修改/etc/nginx/nginx-conf.

-- 安装配置mysql --
阿里云服务器默认安装了mysql,但是root用户登录需要密码
如果是yum安装:
grep 'temporary password' /var/log/mysqld.log 找密码
我找到密码但是无效,因此修改密码。

vi /etc/my.cnf
mysqld 下新增:skip-grant-tables
service mysqld restart
mysql -u root -p 登录
update mysql.user set authentication_string=password('root_password') where user='root';
退出mysql,再次修改my.cnf,注释掉跳过校验语句
mysqld -u root -p

-- 安装node.js --
https://www.cnblogs.com/happyliusiyi/p/11684019.html


posted @ 2020-07-06 11:47  guodaxia  阅读(242)  评论(0编辑  收藏  举报