【Linux】阿里云服务器初始化操作

【Linux】阿里云服务器初始化操作

终究还是购买了一台2c8g5m的阿里云服务器,三年近1399元,真的太香了!

下面是从老的腾讯云学生机器挪移过来顺带升级以下软件操作等命令。想想我的那台腾讯云机器还是2016年买的了,没记错的话。还是五月份哈哈。

选择系统ubuntu

开启ssh登陆

1
2
3
sudo vim /etc/ssh/sshd_config
Port 22
sudo service sshd restart

关于port,我一般会选择换一个,安全点哈哈哈。

切换阿里源

1
vim /etc/apt/sources.list
1
2
3
4
5
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

更新软件神马的快一点

更新系统

1
2
sudo apt-get update
sudo apt-get upgrade

新建用户

1
2
3
4
5
sudo useradd -r -m vadxq
sudo passwd vadxq
sudo vim /etc/sudoers
root ALL=(ALL:ALL) ALL
vadxq ALL=(ALL:ALL) ALL

防火墙ufw

1
2
3
4
5
6
7
8
9
sudo ufw enable
sudo ufw allow 80/tcp

# ssh
sudo ufw allow 22
#mongodb
sudo ufw allow 27017
#mysql
sudo ufw allow 3306

按照zsh

1
2
3
sudo apt-get install zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions

历史语法

1
2
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
source $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

法高亮插件

1
2
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
source $ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

nvm

1
2
3
4
5
6
7
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install 13.10.1
npm i -g pm2
npm i nrm -g

docker

1
2
3
4
5
6
7
curl -k -sSl https://get.docker.com | sudo sh
# docker image prune --force --all或者docker image prune -f -a` : 删除所有不使用的镜像
# docker container prune -f: 删除所有停止的容器

# docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

配置ssh

1
ssh-keygen -t rsa -C "dongxianlin@vadxq.com"

nginx

1
2
3
4
5
6
7
8
https://nginx.org/en/linux_packages.html#Ubuntu
sudo apt install curl gnupg2 ca-certificates lsb-release
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
sudo apt-key fingerprint ABF5BD827BD9BF62
sudo apt update
sudo apt install nginx

nginx编译

安装依赖环境
1
2
sudo apt install  perl make build-essential procps libreadline-dev libncurses5-dev libpcre3-dev libssl-dev zlib1g-dev
2>&1 nginx -V | tr ' ' '\n'|grep module
查看完整的编译参数:nginx -V
1
2
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.18.0/debian/debuild-base/nginx-1.18.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' --add-module=../ngx-fancyindex
--add-module=../lua-nginx-module
1
2
3
git clone https://github.com/aperezdc/ngx-fancyindex.git
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -xvf nginx-1.18.0.tar.gz
1
2
3
4
5
cd nginx-1.18.0
./configure 参数
make
cp obj/nginx /usr/sbin
sudo service nginx start

配置泛域名(可以见我另一个文章)

1
2
3
4
5
6
7
8
9
10
export Ali_Key=xxx

export Ali_Secret=xxx

acme.sh --issue --dns dns_ali -d vadxq.com -d *.vadxq.com

sudo ~/.acme.sh/acme.sh --installcert -d vadxq.com --force \
--key-file /etc/nginx/ssl/vadxq.com/vadxq.key \
--fullchain-file /etc/nginx/ssl/vadxq.com/fullchain.cer \
--reloadcmd "service nginx force-reload”

mysql

1
2
3
4
5
6
7
8
9
10
11
12
wget –c https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb

sudo dpkg –i mysql-apt-config_0.8.15-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server
sudo cat /etc/myspl/debian.cnf

grant all privileges on *.* to root@'localhost' identified by "123456" with grant option;
grant all privileges on *.* to vadxq@‘%' identified by “密码" with grant option;
flush privileges;
修改端口
https://www.cnblogs.com/richardzhu/p/3318595.html

【Linux】阿里云服务器初始化操作

https://blog.vadxq.com/article/aliyun-server-init/

作者

vadxq

发布于

2019-12-20

更新于

2020-10-04

许可协议

评论