ubuntu做交换机和服务器
ssh
- 安装的时候选择openssh server
- 初始账户进去后 sudo passwd 配置root密码
- /etc/ssh/sshd_config 找到#PermitRootLogin prohibit-password下加PermitRootLogin yes
- root可以远程登录
- 可能防火墙放行
- service ssh restart
多网口桥接
- apt-get install bridge-utils安装工具 (brctl工具只能配置临时桥接)
- ubuntu 20以后使用Netplan,配置文件在/etc/netplan/*.yuml,之前使用/etc/network/interface
- 配置文件
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: yes
bridges:
br0:
dhcp4: yes
# dhcp4: no
# addresses: [10.157.81.250/24]
# gateway4: 10.157.81.254
# nameservers:
# addresses: [114.114.114.114]
interfaces:
- enp1s0
- enp2s0
br0是虚拟网卡
3. 配置路由转发 /etc/sysctl.conf net.ipv4.ip_forward=1
4. sudo netplan apply 应用更改
5. brctl show 查看桥接状态
硬盘挂载
mkfs -t ext4 /dev/xvdb3 格式化成ext4 fdisk -l 查看硬盘设备,
blkid查看并记录uuid
mkdir新建文件夹
vi /etc/fstab
/dev/sda /mnt/sda ext4 defaults 0 0
或者
UUID="f7649943-dfdf-4721-92ba-30290bb31d69" /mnt/sda ext4 defaults 0 0
- 第1列是设备名或者卷标
- 第2列是挂载点(也就是挂载目录)
- 第3列是所要挂载设备的文件系统或者文件系统类型
- 第4列是挂载选项,
auto: 系统自动挂载,fstab默认就是这个选项
defaults: rw, suid, dev, exec, auto, nouser, and async.
noauto 开机不自动挂载
nouser 只有超级用户可以挂载
ro 按只读权限挂载
rw 按可读可写权限挂载
user 任何用户都可以挂载
第5列设置是否使用dump备份,置0为不备份,置1,2为备份,但2的备份重要性比1小
第6列设置是否开机的时候使用fsck检验所挂载的磁盘,置0为不检验,置1,2为检验,但置2盘比置1的盘晚检验
mount -a
生效
samba共享
apt-get install samba samba-common 给文件夹权限 chmod 777 /mnt/sda -R 备份sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak smb.conf文件最后
[sda] #共享名
comment = guest share #共享描述
path = /mnt/sda #共享目录
public = yes #允许guest用户访问
writable = yes #允许在目录下写入
directory mask = 0775 #默认创建目录权限 rwxrwxr_x
create mask = 0775 #默认创建文件权限 rwxrwxr_x
valid users = heijunma,root #允许访问该共享的用户
write list = heijunma,root #可写入共享的用户列表
browseable = yes #该指定共享目录可浏览
available = yes #该指定共享资源可使用
workgroup = DAWN #设定 Samba Server 所要加入的工作组或者域
service smbd restart
php-fpm配置
nginx配置文件中对phpfpm的配置为:fastcgi_pass 127.0.0.1:9000或fastcgi_pass unix:fastcgi_pass 127.0.0.1:9000;改为fastcgi_pass unix:/tmp/php-fpm.sock; 此项配置在/etc/php/7.4/fpm/pool.d/www.conf中: listen = /run/php/php7.4-fpm.sock; 1. /etc/php/7.4/fpm/php.ini中可以配置
max_execution_time = 3600
max_input_time = 3600
memory_limit = 512M
post_max_size = 512M
upload_max_filesize = 512M
- /etc/php/7.4/fpm/pool.d/www.conf中可以配置
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 30
pm.max_requests = 500
php-fpm7.4 -t检查配置
frp
wget https://github.com/fatedier/frp/releases/download/v0.38.0/frp_0.38.0_linux_amd64.tar.gz tar -vxzf frp_0.38.0_linux_amd64.tar.gz cd frp_0.38.0_linux_amd64
复制执行文件
sudo cp frpc frps /usr/bin/
复制配置文件
sudo mkdir /etc/frp sudo cp frp*.ini /etc/frp
复制系统服务文件
sudo cp systemd/* /lib/systemd/system/
启动frp客户端
sudo systemctl start frpc
启动frp服务端
sudo systemctl start frps
配置开机启动
sudo systemctl enable frpc sudo systemctl enable frps
[common]
server_addr = xx.xx.xx.xx #公网服务器ip
server_port = xxxx #服务器端口号
token = 123456 #服务器和客户端协商的密码,不一致无法登录
tls_enable = true #使用tls加密
[ssh]
type = tcp
local_ip = 192.168.0.5 #本地映射的应用的IP
local_port = 3389 #本地映射的应用的端口
remote_port = 13389 #远端访问端口
use_compression = true #启用数据压缩
[wrt]
type = http
local_ip = 192.168.0.5 #本地映射的应用的IP
local_port = 80 #本地映射的应用的端口
subdomain = wrt #远端访问端口
use_compression = true #启用数据压缩
systemctl restart frpc
安装ImageMagick 7.1.0-54 with HEIC and WEBP support
已经明确的依赖libde265、libheif、build-essential https://gist.github.com/hurricup/e14ae5bc47705fca6b1680e7a1fb6580
//安装依赖
apt-get install -y build-essential git libde265-dev libdjvulibre-dev libfftw3-dev libghc-bzlib-dev libgoogle-perftools-dev libgraphviz-dev libgs-dev libheif-dev libjbig-dev libjemalloc-dev libjpeg-dev liblcms2-dev liblqr-1-0-dev liblzma-dev libopenexr-dev libopenjp2-7-dev libpango1.0-dev libraqm-dev libraw-dev librsvg2-dev libtiff-dev libwebp-dev libwmf-dev libxml2-dev libzip-dev libzstd-dev
安装
git clone --depth 1 --branch 7.1.0-54 https://github.com/ImageMagick/ImageMagick.git
cd ImageMagick
配置和编译
./configure --with-bzlib=yes --with-djvu=yes --with-dps=yes --with-fftw=yes --with-flif=yes --with-fontconfig=yes --with-fpx=yes --with-freetype=yes --with-gslib=yes --with-gvc=yes --with-heic=yes --with-jbig=yes --with-jemalloc=yes --with-jpeg=yes --with-jxl=yes --with-lcms=yes --with-lqr=yes --with-lzma=yes --with-magick-plus-plus=yes --with-openexr=yes --with-openjp2=yes --with-pango=yes --with-perl=yes --with-png=yes --with-raqm=yes --with-raw=yes --with-rsvg=yes --with-tcmalloc=yes --with-tiff=yes --with-webp=yes --with-wmf=yes --with-x=yes --with-xml=yes --with-zip=yes --with-zlib=yes --with-zstd=yes --with-gcc-arch=native --disable-openmp
make -j 8
make install
ldconfig /usr/local/lib
identify --version
其他方法:5 minutes to Install Imagemagick with HEIC support on Ubuntu 20.04 (and 18.04) DigitalOcean
多线程bug
imagick 的多线程模式有一個 bug,他会导致多核心的 cpu 使用率瞬间飙升到 100%。所以一定要使用它的单线程程模式才行。重新编译 ImageMagick 最新版,增加了参数:--disable-openmp convert -version 指令查看一下输出內容是否已经开启了多线程 · Features 的值为空或DPC,说明是单线程; · Features的值是 openMP,说明是多线程。
安装yum(可选)
- 备份source.list文件,防止弄坏下载源 sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
- 更换国内源 sudo vim /etc/apt/sources.list https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/ 第一行添加镜像源 deb http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiverse 后面添加清华源
- apt-get update apt install python2.7 apt install python-urlgrabber apt install python-sqlitecachec apt-get install yum
- ubuntu没有yum源 添加两个repo,在/etc/yum/repos.d下 fedora-163.repo
[fedora]
name=Fedora 17 - $basearch - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/releases/17/Everything/$basearch/os/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-17&arch=$basearch
enabled=1
metadata_expire=7d
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
[fedora-debuginfo]
name=Fedora 17 - $basearch - Debug - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/releases/17/Everything/$basearch/debug/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-debug-17&arch=$basearch
enabled=0
metadata_expire=7d
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
[fedora-source]
name=Fedora 17 - Source - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/releases/17/Everything/source/SRPMS/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-source-17&arch=$basearch
enabled=0
metadata_expire=7d
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
fedora-updates-163.repo
[updates]
name=Fedora 17 - $basearch - Updates - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/updates/17/$basearch/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f17&arch=$basearch
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
[updates-debuginfo]
name=Fedora 17 - $basearch - Updates - Debug - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/updates/17/$basearch/debug/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-debug-f17&arch=$basearch
enabled=0
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
[updates-source]
name=Fedora 17 - Updates Source - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/updates/17/SRPMS/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-source-f17&arch=$basearch
enabled=0
gpgcheck=0
- yum makecache