Linux环境配置记录

NAT固定ip设置

  1. vmware设置:
    在这里插入图片描述
  2. 修改 /etc/netplan/**-installer-config.yaml:
    network:
      ethernets:
        ens33:
          addresses: [ 192.168.10.100/24 ]
          dhcp4: false
          gateway4: 192.168.10.1
          nameservers:
            addresses: [ 8.8.8.8 ]
          optional: true
    
    
  3. 重启linux 或者 刷新网络
    > reboot
    > netplan apply
    

root用户启动并自动登录

> sudo -s
> sudo passwd root
> vim /usr/share/lightdm/lightdm.conf.d/50-unity.conf
# 文件中追加:
# ================
greeter-show-manual-login = true
all-guest = false
# ================
> vim /etc/pam.d/gdm-autologin
> vim /etc/pam.d/gdm-password
# 两个文件注释该语句:auth required pam_succeed_if.so user != root quiet_success
> vim /root/.profile
# 最后一行修改:最后一行 mesg n || true 前添加  tty -s && 即 tty -s &&mesg n || true
> vim /etc/gdm3/custom.conf
# 新增内容:
# ===============
[daemon]
AutomaticLoginEnable=True
AutomaticLogin=root
# ===============
> reboot

Ubuntu APT操作

sudo apt update  	检查更新
sudo apt upgrade 软件包名	更新指定软件
sudo apt update && sudo apt -y upgrade  更新环境所有软件到最新版本

docker命令

docker ps |grep 服务名		查看docker详情
docker exec -it dockerId /bin/sh  	进入docker容器

查找命令

find rootpath -name filename
rootpath: 查找根路径
filename: 查找文件名

远程传送文件:

scp xxx.zip root@10.74.165.114:/usr/local/src

远程服务器用户:root ip:10.74.165.114:后面的传递文件保存路径

压缩命令

tar
  解包:tar zxvf filename.tar
  打包:tar czvf filename.tar dirname
gz命令
  解压1:gunzip filename.gz
  解压2:gzip -d filename.gz
  压缩:gzip filename
      .tar.gz 和  .tgz
      解压:tar zxvf filename.tar.gz -C 目标目录
      压缩:tar zcvf filename.tar.gz dirname
      压缩多个文件:tar zcvf filename.tar.gz dirname1 dirname2 dirname3.....
bz2命令
  解压1:bzip2 -d filename.bz2
  解压2:bunzip2 filename.bz2
  压缩:bzip2 -z filename
        .tar.bz2

       解压:tar jxvf filename.tar.bz2
       压缩:tar jcvf filename.tar.bz2 dirname
bz命令
    解压1:bzip2 -d filename.bz
    解压2:bunzip2 filename.bz
         .tar.bz
       解压:tar jxvf filename.tar.bz
z命令
    解压:uncompress filename.z
    压缩:compress filename
        .tar.z
          解压:tar zxvf filename.tar.z
          压缩:tar zcvf filename.tar.z dirname
zip命令
    
    解压:unzip filename.zip / unzip xxx.zip -d aaa (解压xxx.zip文件置于当前路径下的aaa文件夹下;)
    压缩:zip filename.zip dirname
rar命令
	解压:rar x etc.rar
		  unrar -e etc.tar
	压缩:rar a etc.rar dirname

文件操作

	echo “aaa” > xxx   		// 覆盖的方式将 aaa 写入到xxx文件中
	echo “aaa” >> xxx  		// 将aaa追加到xxx文件中
	cat x.txt >> b.txt 		// 将x.txt中的内容追加到b.txt中
	touch x.txt  			// 新建x.txt文件
	vi xxx ---- 打开文件,并可以对文件进行修改
	vi 打开一个不存在的文件a时,在没有输入保存命令时,a文件是不会存储到机器磁盘上的。
	vi打开一个文件时,进入的是阅读模式,只有输入相关命令才会进入编辑模式:
			i :在当前位置插入
			a:在当前位置后追加
			o:在当前位置的后面插入一行
			I :在行头插入
			A:在行尾追加
			O:在当前位置的前面插入一行
			'ESC'键从编辑模式转换到阅读模式
			阅读模式(或叫命令模式)下:
				:w 保存文件
				:w filename 保存成filename文件
				:q 退出
				:q! 强行退出
				:w! 强行写
				:wq 保存退出
				:x     同wq

sh文件的运行:

如果对文件没有执行权限 ,获取执行权限的方式:
	chmod +x a.sh
运行sh文件的方式:
	方式1:进入sh文件所在路径-----:./xxx.sh
	方式2:进入sh文件所在路径-----:shxxx.sh
注:绝对路径也是可以的,不用进入对应的文件路径。
// 后台运行sh:
> xxx.sh &
> nohup xxx.sh
// 前后台进程的切换与控制
// 将后台中的命令调至前台继续运行
> fg $jobNum
// 将一个在后台暂停的命令,变成在后台继续执行
> bg $jobNum

查看并操作线程

以tomcat为例:
bin/startup.sh #启动tomcat
bin/shutdown.sh #停止tomcat
tail -f logs/catalina.out #看tomcat的控制台输出;
#看是否已经有tomcat在运行了
ps -ef |grep tomcat  #获取正在运行的tomcat的进程号
#如果有,用kill;
kill pid
如果删除不掉,加 -9 强制删除
kill -9 pid #pid 为相应的进程号

查看当前占用空间最多的文件

// 查看当前系统磁盘占用情况
> df -lh
> cd /
// 查看当前目录中各个文件或文件夹的占用情况
> sudo du -h --max-depth=1
// 挨个进去找即可找到最大的文件;便于删除

从0搭建自己的虚拟机环境

安装ubuntu

在ubuntu官网下载最新的LTS版本镜像文件,新建虚拟机(推荐配置下一步即可

修改apt源(阿里云的软件源)

  1. 查询系统代号:
> lsb_release -c
Codename:	focal         // ubuntu 20.04 LTS
  1. 备份原始的源文件(备份是个好习惯):sudo cp /etc/apt/source.list /etc/apt/source.list.bak
  2. 打开源文件:sudo gedit /etc/apt/source.list
  3. 输入配置源信息:
    注:下面url中的focal对应当前系统的代号,若不是focal版本,需自行替换
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
  1. 更新软件列表:sudo apt-get update
  2. 更新软件包:sudo apt-get upgrade

虚拟机窗口自适应

安装方法:

> sudo apt-get install open-vm-tools
> sudo apt-get install open-vm-tools-desktop
> sudo apt-get install cloud-init
> reboot

desktop-中文输入法安装-百度输入法

网上下载百度拼音压缩包,并解压 unzip xxx.zip;
安装方法,逐条命令执行吧:

> sudo apt-get update
> sudo apt-get upgrade
> sudo apt-get install aptitude
> echo "下面命令中 fcitx-config-gtk2 可能会安装不上,可以排除他直接安装其他的"
> sudo aptitude install fcitx-bin fcitx-table fcitx-config-gtk fcitx-frontend-all
#  qml-module-controls2
> sudo aptitude install qt5-default qtcreator
> im-config
> echo "im-config的时候选中fcitx"
> sudo dpkg -i fcitx-baidupinyin.deb
> reboot
> echo "重启后,右上角会有键盘标识,点击配置,添加百度拼音输入法,完成~~"
> echo "下面是卸载命令:"
> sudo dpkg --purge remove fcitx-baidupinyin:amd64

配置环境变量

临时添加

echo "open a terminal"
echo "new a env variable:"
export ENV_VARI_NAME=[path]
echo "add a new path to existed env varibale:"
export ENV_VARI_NAME=[NEW_PATH]:$ENV_VARI_NAME
echo "rm a env variable:"
unset ENV_VARI_NAME
echi "print env variable:"
echo $ENV_VARI_NAME
printenv ENV_VARI_NAME

永久添加

file -> /etc/profile

/etc/profile文件就是系统默认的bash shell的 第一启动文件.其中就涉及到了系统环境变量的读取文件
所有用户登录时均会执行该文件,可以在文件末尾直接追加环境变量
该脚本会扫描/etc/profile.d目录下的所有*.sh脚本加载;

> gedit /etc/profile
> echo "enter 'export ENV_VARI_NAME=[PATH]' at the end of the file. and save."
> echo "reload /etc/profile:"
> source /etc/profile
file -> /etc/environment

/etc/environment文件是登录Linux系统时的 第二启动文件.对所有用户生效

> gedit /etc/environment
> echo "enter ' ENV_VARI_NAME=\"[PATH]\" ' at the end of the file. and save."
> echo "reload /etc/environment:"
> source /etc/environment
file -> ~/.profile

对当前用户生效

> gedit ~/.profile
> echo "enter 'export ENV_VARI_NAME=[PATH]' at the end of the file. and save."
> echo "reload ~/.profile:"
> source ~/.profile
file -> ~/.bashrc

对当前用户生效

> gedit ~/.bashrc
> echo "enter 'export ENV_VARI_NAME=[PATH]' at the end of the file. and save."
> echo "reload ~/.bashrc:"
> source ~/.bashrc

docker安装

ubuntu的官方安装文档:[点击打开]
精简命令说明:

> sudo apt-get remove docker docker-engine docker.io containerd runc
> sudo apt-get update
> sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
> echo "Docker’s official GPG key:9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88"
> curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
> sudo apt-key fingerprint 0EBFCD88
> sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
> sudo apt-get update
> sudo apt-get install docker-ce docker-ce-cli containerd.io
> echo "安装指定版本,下面两条命令:查询版本列表,安装指定版本"
> apt-cache madison docker-ce
> sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
> echo "================ end ================="
> echo "open a test docker:"
> sudo docker run hello-world
> curl -fsSL https://get.docker.com -o get-docker.sh
> sudo sh get-docker.sh
> echo "add your user to docker group:"
> sudo usermod -aG docker your-user

# 阿里云安装
#卸载旧版本docker
sudo apt-get remove docker docker-engine docker-ce docker.io	
#清空旧版docker占用的内存
sudo apt-get remove --auto-remove docker
#更新系统源
sudo apt-get update

# 配置安装环境
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
# 添加阿里云docker GPG秘钥
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# 添加阿里云镜像
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
#更新
sudo apt-get update
# 查看版本
apt-cache madison docker-ce
#安装最新版
sudo apt-get install -y docker-ce
#安装5:19.03.6~3-0~ubuntu-bionic版
sudo apt-get install -y docker-ce=5:19.03.6~3-0~ubuntu-bionic
# 重启docker
sudo service docker restart
	#或者
sudo systemctl restart docker

# 阿里云镜像加速
#	阿里云中搜索 **容器镜像服务**

docker hub地址:[点击打开]

docker离线安装

参考官网文档:[官网文档]

# 1. 从官网路径下载对应的docker离线安装包-(https://download.docker.com/linux/static/stable)
> wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.9.tgz
> tar zxvf docker-19.03.9.tgz
> sudo cp docker/* /usr/bin
# 2. 创建docker为服务,docker.service请看下边独立代码块
> vim /etc/systemd/system/docker.service
> sudo chmod +x /etc/systemd/system/docker.service
> sudo systemctl daemon-reload
> sudo systemctl start docker
> sudo systemctl enable docker.service
> sudo systemctl status docker
> sudo docker -v
# 3. 添加docker用户组,添加指定用户可直接操作
> sudo groupadd docker
# 添加当前用户到docker用户组
> sudo gpasswd -a $USER docker
> newgrp docker
> sudo systemctl restart docker
> docker ps

docker.service内容如下:

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target

常用docker镜像安装及配置

mysql
> docker pull mysql:5.7
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql-root -d mysql:tag
		Currently, this is only supported for MYSQL_ROOT_PASSWORD, MYSQL_ROOT_HOST, MYSQL_DATABASE, MYSQL_USER, and MYSQL_PASSWORD.
		
docker run --name some-mysql -v /my/own/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
		指定数据存储路径
		
docker run --name some-mysql -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
		将配置文件放 xxx.cnf放/my/custom下,容器会加载/etc/mysql/my.cnf和/etc/mysql/conf.d/*.cnf
		
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
		无配置文件启动
		
最终结果:
1.指定密码文件
docker run --name fota-mysql -e MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql-root -v /home/devData/mysql/data:/var/lib/mysql -v /home/devData/mysql/conf:/etc/mysql/conf.d -p 3306:3306 -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
2.直接指定密码
docker run --name fota-mysql -e MYSQL_ROOT_PASSWORD=root -v /home/devData/mysql/data:/var/lib/mysql -v /home/devData/mysql/conf:/etc/mysql/conf.d -p 3306:3306 -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

java环境变量的配置

  1. 从oracle官网下载
  2. jdk压缩包:地址:java官方下载地址
  3. 解压压缩包:tar zxvf jdk***.tar.gz
  4. /etc/profile.d 目录下新建sh脚本,用于加载环境变量;
  5. 重启reboot或者source /etc/profile
> echo "操作步骤请参考:"
> echo "weget jdk please operate by yourself, cmd is a demo."
> wget https://download.oracle.com/otn/java/jdk/8u231-b11/5b13a193868b4bf28bcb45c792fce896/jdk-8u231-linux-x64.tar.gz?AuthParam=1594009882_0e8d258f5bf9d758415383bbe5c3cd63
> echo "please cd to the jdk dir"
> tar zxvf jdk**.tar.gz
> mv jdk_root_dir dst_dir
> touch /etc/profile.d/custom.env.sh
> gedit /etc/profile.d/custom.env.sh
> echo "please enter env into sh file, eg: "
> echo "export JAVA_HOME=/usr/local/dev/sdk/jdk8"
> echo "export PATH=$JAVA_HOME/bin:$PATH"
> echo "save file"
> reboot / source /etc/profile

python环境配置

ubuntu默认情况下安装了python2和python3;而python link的是 python2;修改使默认为python3
操作如下:

> sudo mv /usr/bin/python /usr/bin/python_bak
> echo "link python3 to python, my env python3 is python3.8"
> sudo ln -s /usr/bin/python3.8 /usr/bin/python
> echo "开始安装pip及三方库"
> sudo apt install python3-pip
> sudo ln -s /usr/bin/pip3 /usr/bin/pip
> sudo pip install numpy
> sudo pip3 install numpy

配置pip源:pip源配置方法

golang环境配置

国内golang下载比较比较快的地址:[下载地址]

  1. 复制下载链接
    在这里插入图片描述
  2. 在终端中通过wget下载:wget https://studygolang.com/dl/golang/go1.14.4.linux-amd64.tar.gz;
  3. 解压到指定目录:tar -C /usr/local/dev/sdk/ -xzf go1.14.4.linux-amd64.tar.gz;
  4. 配置环境变量,参见:配置环境变量 章节:
vim /etc/profile.d/custom_env.sh
export GOROOT=$go_root_dir
export PATH=$GOROOT/bin:$PATH
source /etc/profile

chm文件打开配置

两个工具任选其一,第二个更友好

> sudo apt-get install xchm
> sudo apt-get install kchmviewer

ngrok服务器搭建

需要一台云主机,一个备案的域名;(这里演示,直接在虚拟机中弄就ok)
域名需要进行泛解析(*),可使用的二级域名需要A记录解析到云主机IP地址;

  1. 安装go 和 git,可以给go配置一个代理:go moudle模块加载被墙解决方法
  2. 下载ngrok源码:git clone https://github.com/inconshreveable/ngrok.git
  3. 证书生成:默认基础域名是:ngrok.com,需要修改成功自己的域名 —(摘抄了生成方式,不要在意细节)
cd ngrok  
mkdir cert 
cd cert
export NGROK_DOMAIN="abc.com"
openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootCA.pem
openssl genrsa -out device.key 2048
openssl req -new -key device.key -subj "/CN=$NGROK_DOMAIN" -out device.csr
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000

替换原始文件

cp rootCA.pem ../assets/client/tls/ngrokroot.crt
cp device.crt ../assets/server/tls/snakeoil.crt
cp device.key ../assets/server/tls/snakeoil.key
  1. 生成服务端,客户端(即编译源码,cd $ngrok_root_dir
    注: 如果使用的go version 大于1.13, 需要设置环境变量 GO111MODULE=off
    原因: ngrok的源码是go语言实现的, 而代码管理使用的 GOPATH 的方式,; 在高版本的go中, 默认开启了GOMODULE;
    注: 不要在虚拟机中进行编译, 可能会导致获取的证书不匹配, 从而使得连接失败; 建议直接在运行机器上编译
export GO111MODULE=off
# linux服务端/客户端
GOOS=linux GOARCH=386 make release-server (32)
GOOS=linux GOARCH=amd64 make release-server(64位)
GOOS=linux GOARCH=386 make release-client (32)
GOOS=linux GOARCH=amd64 make release-client(64位)
# Mac OS服务端/客户端
GOOS=darwin GOARCH=386 make release-server
GOOS=darwin GOARCH=amd64 make release-server
GOOS=darwin GOARCH=386 make release-client
GOOS=darwin GOARCH=amd64 make release-client
# windows服务端/客户端
GOOS=windows GOARCH=386 make release-server
GOOS=windows GOARCH=amd64 make release-server
GOOS=windows GOARCH=386 make release-client
GOOS=windows GOARCH=amd64 make release-client
# 生成的程序在`./bin`目录下
  1. 启动服务端:./bin/ngrokd -domain="xxx.com"
    其它配置:
    -httpAddr=":80" http服务的访问端口 默认80
    -httpsAddr=":443" https服务的访问端口 默认443
    -tunnelAddr=":4443" 客户端连接服务端的端口 默认4443
    以上端口,如若与系统其他服务有冲突,开启服务时请自行配置其他端口,同时记得配置防火墙
  2. nginx配置
    服务器:80端口被占用,ngrok需要在其他端口启动起来,通过nginx来映射端口到80:
	server {
    listen       80;
    server_name  ~^(www\.)?(?<subDomain>.+)\.domain\.com$;
    location / {
    	# 解决no resolver defined to resolve问题
        resolver 8.8.8.8;
        proxy_pass http://$subDomain.domain.cn:10000;
    }
    error_page  404              /404.html;
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}
  1. 客户端启动
  2. 下载对应的客户端程序
  3. 新建ngrok.cfg文件:配置服务端连接地址,也就是基础域名。端口则与服务端-tunnelAddr配置相同
server_addr: "xxx.cn:4443"  
trust_host_root_certs: false
tunnels:
    http:
        subdomain: "begin"
        proto:
            http: "8088"
    https:
        subdomain: "begin"
        proto:
            https: "443"
    mstsc:
        remote_port: 3389
        proto:
            tcp: "127.0.0.1:3389"
  1. 启动客户端: ngrok -config=ngrok.cfg -subdomain 子域名 本地应用端口
  2. 启动客户端:ngrok -config=ngrok.cfg start http/https/mstsc, 分别启动http,https或者远程桌面;proto映射本地的端口或地址 ;

注:windows系统本地远程端口为3389,为了安全,可自行修改本地的映射端口:

1. 输入 win+R,输入 regedit;
2. 打开文件:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp\PortNumber, 按十进制显示,并修改该端口
3. 打开文件:HKEY_LOCAL_MACHINE\SYSTEM\CurrentContro1Set\Control\Tenninal Server\WinStations\RDP-Tcp\PortNumber, 按十进制显示,并修改该端口
4. 重启电脑

crome浏览器安装

> wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
> sudo apt install ./google-chrome-stable_current_amd64.deb

SSH远程访问及sftp服务器

> sudo apt-get update
> sudo apt install openssh-server
> vim /etc/ssh/sshd_config
# 支持root用户FTP访问:注释配置PermitRootLogin放开,设置为yes
> sudo /etc/init.d/ssh restart
> echo "test for starting success"
> ssh localhost
> echo "sftp style mode:"
> echo "for example: sftp://ubuntu:xxx@192.168.1.107:22/usr/local/dev/sdk"
> ssh-keygen
> echo "set login no password" 
> ssh-copy-id -i ~/.ssh/id_rsa.pub root@hostname

nginx安装

> su -
> apt-get install openssl libssl-dev zlib1g-dev
> echo "PCRE 作用是让 Nginx 支持 Rewrite 功能。"
> wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
> tar zxvf pcre-8.35.tar.gz
> cd pcre-8.35
> ./configure
> make && make install
> cd ..
> wget http://nginx.org/download/nginx-1.19.2.tar.gz
> tar zxvf nginx-1.19.2.tar.gz -C nginx-1.19.2-src
> cd nginx-1.19.2-src
> ./configure --prefix=/usr/local/dev/tools/nginx-1.19.2 --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/dev/tools/pcre-8.35
> make && make install
> export NGINX_HOME=/usr/local/dev/tools/nginx-1.19.2
> export PATH=$NGINX_HOME/sbin:$PATH
> nginx -v
> echo "start nginx"
> nginx -c /usr/local/nginx/conf/nginx.conf

通过openresty安装

# 安装openresty:https://github.com/openresty/openresty
# 文档:https://openresty.org/en/linux-packages.html
# install some prerequisites needed by adding GPG public keys (could be removed later)
sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates
# import our GPG key:
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
# add the our official APT repository:
echo "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" \
    | sudo tee /etc/apt/sources.list.d/openresty.list
# to update the APT index:
sudo apt-get update
sudo apt-get -y install openresty
# 不安装推荐模块
sudo apt-get -y install --no-install-recommends openresty

# 配置环境变量
export NGINX_HOME=/usr/local/openresty/nginx
export PATH=$NGINX_HOME/sbin:$PATH
nginx -v
echo "start nginx"
nginx -c /usr/local/nginx/conf/nginx.conf

20.04创建自启动

# 自启动配置文件
vim /lib/systemd/system/rc-local.service
# ==== 追加以下内容 ====
[Install]  
WantedBy=multi-user.target  
Alias=rc-local.service
# =====================
# systemd 默认读取 /etc/systemd/system 下的配置文件, 所以还需要在 /etc/systemd/system 目录下创建软链接
ln -s /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service
# 若已经创建了软链接,可直接修改该文件
vim /etc/systemd/system/rc-local.service
# 修改下面文件
vim /etc/rc.local
# ==== 追加以下内容 ====
#!/bin/bash

# 个人应用及日志输入路径
/usr/local/qcloud/irq/net_smp_affinity.sh >/tmp/net_affinity.log 2>&1
# =====================
systemctl status rc-local.service
systemctl start rc-local.service
systemctl restart rc-local.service

命令行连接wifi

  1. 查看是否已经正确安装无线网卡 iwconfig
  2. 启动无线网卡, 如果网卡是wlan0
    方式1: ifconfig wlan0 up
    方式2: ip link set wlan0 up
  3. 扫描可用的WiFi
    iw dev wlan0 scan |less (不加less可能会产生太多输出)
    或者
    iwlist wlan0 scanning
  4. 创建口令文件, 并连接
    建立配置文件: wpa_passphrase ESSID PWD > xxx.conf
  5. 使用配置文件连接: wpa_supplicant -B -i wlan0 -Dwext -c ./xxx.conf
  6. 查看连接结果
    iwconfig wlan0
  7. 设置为dhcp client, 获取IP
    dhclient wlan0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值