跳转到帖子

剑弗

网站管理
  • 注册日期

博客帖子 发布由 剑弗

  1. E: Malformed entry 60 in list file /etc/apt/sources.list (Component)
    E: The list of sources could not be read.
    在阿里云上添加了Docker官方的下载源后,升级包(apt-get update)报出如上的错误.
    没办法只好注释掉了其中的一个源路径:
    deb [arch=amd64] https://download.docker.com/linux/ubuntu stable
    只留下了:
    deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
    再次更新源不再报错.
  2. Linux中修改Docker路径

    首先,我们需要停止Docker服务并备份所有必要的文件。
    停止
    sudo service docker stop 备份
    sudo tar -czvf /tmp/docker.tar.gz /var/lib/docker
    接下来,我们需要修改Docker配置文件。打开“/etc/docker/daemon.json”(如果文件不存在,请创建它)。在文件中添加以下配置:
    vim /etc/docker/daemon.json { "data-root": "/www/docker" } 注意:如果有多条配置信息的话需要在两条配置信息中加逗号“,”


    这里,“data-root”指定了Docker的新安装路径。请将“/home/docker”替换为您想要使用的路径。
    保存文件并重启Docker服务:
    sudo service docker start
    现在,Docker已经使用新的安装路径。您可以验证操作是否成功,方法如下:
    docker info | grep "Docker Root Dir" 结果将显示如下:
    Docker Root Dir: /home/docker  
  3. Docker镜像源站

    网易:http://hub-mirror.c.163.com 中科大镜像地址:http://mirrors.ustc.edu.cn/ 中科大github地址:https://github.com/ustclug/mirrorrequest Azure中国镜像地址:http://mirror.azure.cn/ Azure中国github地址:https://github.com/Azure/container-service-for-azure-china DockerHub镜像仓库: https://hub.docker.com/  阿里云镜像仓库: https://cr.console.aliyun.com  google镜像仓库: https://console.cloud.google.com/gcr/images/google-containers/GLOBAL (如果你本地可以翻墙的话是可以连上去的 ) coreos镜像仓库: https://quay.io/repository/  RedHat镜像仓库: https://access.redhat.com/containers  
  4. Debian安装 Docker

    一、安装Docker
    1.更新系统软件包
    sudo apt update sudo apt upgrade 2.安装所需的依赖库和工具:
    sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release 3.添加Docker官方GPT秘钥:
    curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 4.设置Docker稳定版存储库
    echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 5.更新软件包索引:(这一步可要可不要,因为前面已经执行了)
    sudo apt update 6.安装Docker引擎:
    sudo apt install docker-ce docker-ce-cli containerd.io 7.添加当前用户到Docker组:
    sudo usermod -aG docker $USER 安装成功以后提示:
    docker version #查看版本
    Client: Docker Engine - Community  Version:           24.0.2  API version:       1.43  Go version:        go1.20.4  Git commit:        cb74dfc  Built:             Thu May 25 21:52:17 2023  OS/Arch:           linux/amd64  Context:           default Server: Docker Engine - Community  Engine:   Version:          24.0.2   API version:      1.43 (minimum version 1.12)   Go version:       go1.20.4   Git commit:       659604f   Built:            Thu May 25 21:52:17 2023   OS/Arch:          linux/amd64   Experimental:     false  containerd:   Version:          1.6.21   GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8  runc:   Version:          1.1.7   GitCommit:        v1.1.7-0-g860f061  docker-init:   Version:          0.19.0   GitCommit:        de40ad0 二、安装Docker Compose
    下载 Docker Compose 二进制文件:
    bash复制代码sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    添加执行权限:
    bash复制代码sudo chmod +x /usr/local/bin/docker-compose
    验证Docker Compose是否安装成功:
    复制代码
    docker-compose version  
  5. Linux解压/压缩命令集合

    linux常用的解压和压缩命令如下:

    1、.tar
    解包:
    tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!)
    2、.gz
    解压1:
    gunzip FileName.gz 解压2:gzip -d FileName.gz 压缩: gzip FileName 3、.tar.gz 和 .tgz
    解压:
    tar zxvf FileName.tar.gz 压缩:tar zcvf FileName.tar.gz DirName 4、.bz2
    解压1:
    bzip2 -d FileName.bz2 解压2:
    bunzip2 FileName.bz2 压缩:
    bzip2 -z FileName 5、.tar.bz2
    解压:
    tar jxvf FileName.tar.bz2 压缩:
    tar jcvf FileName.tar.bz2 DirName 6、.bz
    解压1:
    bzip2 -d FileName.bz 解压2:
    bunzip2 FileName.bz 7、.tar.bz
    解压:
    tar jxvf FileName.tar.bz 8、.Z
    解压:
    uncompress FileName.Z 压缩:
    compress FileName 9、.tar.Z
    解压:
    tar Zxvf FileName.tar.Z 压缩:
    tar Zcvf FileName.tar.Z DirName 10、.zip
    解压:
    unzip FileName.zip 压缩:
    zip FileName.zip DirName 11、.rar
    解压:
    rar x FileName.rar 压缩:
    rar a FileName.rar DirName 12、.lha
    解压:
    lha -e FileName.lha 压缩:
    lha -a FileName.lha FileName 13、.rpm
    解包:
    rpm2cpio FileName.rpm | cpio -div 14、.deb
    解包:
    ar p FileName.deb data.tar.gz | tar zxf 15、.tar .tgz .tar.gz .tar.Z .tar.bz .tar.bz2 .zip .cpio .rpm .deb .slp .arj .rar .ace .lha .lzh .lzx .lzs .arc .sda .sfx .lnx .zoo .cab .kar .cpt .pit .sit .sea
    解压:
    sEx x FileName.* 压缩:
    sEx a FileName.* FileName  
  6. Nginx配置文件
    server { listen 80; listen [::]:80; server_name www.cxcblog.com ; index index.html index.htm index.php default.html default.htm default.php; root /home/wwwroot/www.cxcblog.com; location ^~ / { proxy_pass http://0.0.0.0:1080; proxy_set_header Host $host; } include rewrite/none.conf; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php-pathinfo.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/www.cxcblog.com.log; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name www.cxcblog.com ; index index.html index.htm index.php default.html default.htm default.php; root /home/wwwroot/www.cxcblog.com; location ^~ / { proxy_pass https://0.0.0.0:10443; proxy_set_header Host $host; } ssl_certificate /usr/local/nginx/conf/ssl/www.cxcblog.com/fullchain.cer; ssl_certificate_key /usr/local/nginx/conf/ssl/www.cxcblog.com/www.cxcblog.com.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5"; ssl_session_cache builtin:1000 shared:SSL:10m; # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048 ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem; include rewrite/none.conf; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php-pathinfo.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/www.cxcblog.com.log; }  
    APP.YML配置文件
    ## this is the all-in-one, standalone Discourse Docker container template ## ## After making changes to this file, you MUST rebuild ## /var/discourse/launcher rebuild app ## ## BE *VERY* CAREFUL WHEN EDITING! ## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT! ## visit http://www.yamllint.com/ to validate this file as needed templates: - "templates/postgres.template.yml" - "templates/redis.template.yml" - "templates/web.template.yml" ## Uncomment the next line to enable the IPv6 listener #- "templates/web.ipv6.template.yml" - "templates/web.ratelimited.template.yml" ## Uncomment these two lines if you wish to add Lets Encrypt (https) - "templates/web.ssl.template.yml" # - "templates/web.letsencrypt.ssl.template.yml" ## which TCP/IP ports should this container expose? ## If you want Discourse to share a port with another webserver like Apache or nginx, ## see https://meta.discourse.org/t/17247 for details expose: - "1080:80" # http - "10443:443" # https params: db_default_text_search_config: "pg_catalog.english" ## Set db_shared_buffers to a max of 25% of the total memory. ## will be set automatically by bootstrap based on detected RAM, or you can override db_shared_buffers: "128MB" ## can improve sorting performance, but adds memory usage per-connection #db_work_mem: "40MB" ## Which Git revision should this container use? (default: tests-passed) #version: tests-passed env: LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LANGUAGE: en_US.UTF-8 # DISCOURSE_DEFAULT_LOCALE: en ## How many concurrent web requests are supported? Depends on memory and CPU cores. ## will be set automatically by bootstrap based on detected CPUs, or you can override UNICORN_WORKERS: 2 ## TODO: The domain name this Discourse instance will respond to ## Required. Discourse will not work with a bare IP number. DISCOURSE_HOSTNAME: www.cxcblog.com ## Uncomment if you want the container to be started with the same ## hostname (-h option) as specified above (default "$hostname-$config") #DOCKER_USE_HOSTNAME: true ## TODO: List of comma delimited emails that will be made admin and developer ## on initial signup example 'user1@example.com,user2@example.com' DISCOURSE_DEVELOPER_EMAILS: '5779512@qq.com' ## TODO: The SMTP mail server used to validate new accounts and send notifications # SMTP ADDRESS, username, and password are required # WARNING the char '#' in SMTP password can cause problems! DISCOURSE_SMTP_ADDRESS: smtp.qq.com DISCOURSE_SMTP_PORT: 587 DISCOURSE_SMTP_USER_NAME: 5779512@qq.com DISCOURSE_SMTP_PASSWORD: "cnltjjkvvaewbjgg" #DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true) DISCOURSE_SMTP_DOMAIN: qq.com DISCOURSE_NOTIFICATION_EMAIL: 5779512@qq.com ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate LETSENCRYPT_ACCOUNT_EMAIL: 5779512@qq.com ## The http or https CDN address for this Discourse instance (configured to pull) ## see https://meta.discourse.org/t/14857 for details #DISCOURSE_CDN_URL: https://discourse-cdn.example.com ## The maxmind geolocation IP address key for IP address lookup ## see https://meta.discourse.org/t/-/137387/23 for details #DISCOURSE_MAXMIND_LICENSE_KEY: 1234567890123456 ## The Docker container is stateless; all data is stored in /shared volumes: - volume: host: /var/discourse/shared/standalone guest: /shared - volume: host: /var/discourse/shared/standalone/log/var-log guest: /var/log ## Plugins go here ## see https://meta.discourse.org/t/19157 for details hooks: after_code: - exec: cd: $home/plugins cmd: - git clone https://github.com/discourse/docker_manager.git ## Any custom commands to run after building run: - exec: echo "Beginning of custom commands" ## If you want to set the 'From' email address for your first registration, uncomment and change: ## After getting the first signup email, re-comment the line. It only needs to run once. #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'" - exec: echo "End of custom commands"  
  7. 甲骨文抢(ARM)高配机

    我这里面是用的ubuntu的机器搭建的
    安装Git: 先确保VPS上安装了Git,以便从GitHub克隆代码。运行以下命令:
    sudo apt update sudo apt install git 克隆GitHub仓库: 打开GitHub页面,找到仓库的URL(通常在仓库首页上方有“Code”按钮,可以复制HTTPS链接)。然后,在VPS上运行以下命令,将仓库代码下载到本地:
    git clone https://github.com/lemoex/oci-help 进入项目文件夹: 克隆完成后,进入下载的项目文件夹,通常这个文件夹的名称是仓库名。例如:
    cd oci-help 如果没有更改过位置,脚本文件夹默认位置就是:root/oci-help
    4. 编译和运行程序: 该项目包含的文件如go.mod和main.go表明它是用Go语言编写的。确保Go已经在VPS上安装,您可以运行以下命令安装Go:
    sudo apt install golang 编译Go代码: 进入项目目录后,运行以下命令来编译和构建程序:
    go build -o oci-help main.go 这会在当前目录下生成一个可执行文件oci-help。但如果你的VPS配置很低,比如是内存只有512M/1G,有可能会提示进程killed,也就是编译失败。这时,你需要给VPS增加Swap空间,也就是占用一部分硬盘空间(我默认设置为1G)
    # 创建一个1GB的交换文件 sudo fallocate -l 1G /swapfile # 设置交换文件的权限 sudo chmod 600 /swapfile # 设置交换文件为swap sudo mkswap /swapfile # 启用交换文件 sudo swapon /swapfile # 确保交换文件在重启后依然有效 echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab 设置配置文件 这里额外提示下,对于不了解linux的朋友,建议使用finalshell这类可以看到服务器文件的工具来连接。Mac用户可以使用terminus。看下项目文件夹,应该有一个文件:oci-help.ini因为GitHub作者写得已经很详细了,照着做就行。不过,我在实操中,发现甲骨文的界面有所变化。所以,找不到API设置路径的朋友,可以直接搜索“API”,然后进入。其次,关于实例的配置,如果只设置一个引导卷,最好不要设为200G,而是199G。
    运行程序: 确保oci-help.ini在项目文件夹中。然后,使用以下命令来运行程序:
    ./oci-help
    oci-help.ini配置文件
    # 配置 socks5 或 http 代理. socks5://127.0.0.1:7890 / http://127.0.0.1:7890 #proxy=socks5://127.0.0.1:7890 # Telegram Bot 消息提醒 token=7864472473:AAE3TczVYP1Z1jkOEF3AuaYulO7mSD-F29s chat_id=7056619357 ############################## 甲骨文账号配置 ############################## # 可以配置多个账号 [美西] user=ocid1.user.oc1..aaaaaaaa2kphvfjsdsuoocobmyo74mxqqllw45pjyhlyfyunun65e5bqfs2q fingerprint=4c:1d:7f:47:bf:a3:c8:e0:cc:25:52:b8:16:fa:ed:7e tenancy=ocid1.tenancy.oc1..aaaaaaaab2shlk4m3n2cdgkqf4med2tjl75ha6dmlpvvnm7n3kkkfi6h2ysq region=us-phoenix-1 key_file=cxc202501@163.com_2025-04-23T00_17_10.070Z.pem ############################## 实例相关参数配置 ############################## [INSTANCE] # 虚拟云网络名称 (可选) #vcnDisplayName= # 子网名称 (可选) #subnetDisplayName= # 实例名称 (可选) #instanceDisplayName= # 系统 Canonical Ubuntu / CentOS / Oracle Linux OperatingSystem=Canonical Ubuntu # 系统版本 Canonical Ubuntu: 20.04|18.04 / CentOS :8|7 / Oracle Linux: 8|7.9 OperatingSystemVersion=22.04 # 失败后重试次数 retry=3 # 延迟时间(秒) minTime=5 maxTime=30 # ssh_authorized_key= # 请在下方 [INSTANCE.ARM] 和 [INSTANCE.AMD] 中配置 SSH 公钥。 # 初始化脚本(将脚本内容base64编码后添加)。该脚本将在您的实例引导或重新启动时运行。 cloud-init= [INSTANCE.ARM] shape=VM.Standard.A1.Flex cpus=4 # cpu个数 memoryInGBs=24 # 内存大小(GB) bootVolumeSizeInGBs=100 # 引导卷大小(GB) sum=1 # 创建实例个数 retry=-1 # 失败后重试次数设置为-1,失败后一直尝试直到成功。 # 可用性域(选填) availabilityDomain=TDte:PHX-AD-3 # SSH 公钥 ssh_authorized_key=ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6Dr9fGrducRtaeY0V2Y3+v+Ff4pirEU49T9fvyQYkvD6vZ3jY0uzwsmg/QpWPnt9fCoJ7GKcqAkpK+qSW7Hif384hdRIbymuLuGCDJoCVCl4J6kkX0DwNxpY6s3a37+q4cDNtKEzwt3nSNSdKWTdDpGzEGbZj87pLz7HSMLyYox9ip9bTbMAYtxRtFEfQbipx02jfu6FBji0ibsLl2P2TbQtahH1qW7HnVnB7l3/mOeLm84T3r4jjeGK1SSukDYyJMSn/4c6UwkR63YhmjYOcTPV8TEWIjhWp6DGDDiFesm++lvsAEyMc5lqmTSZZAPndcdBb3y/xnJoaYdX+1hgJ ssh-key-2025-04-23

  8. IPS5/IC5/简化发帖代码修改

    修改根目录/static/templates/forums_front_index.php 的2624行和6236行
    修改根目录/applications/forums/modules/front/forums/forums.php 的626-632行
    //new $fixed_id = 41; if ( !isset( Request::i()->id ) ) { Request::i()->id = $fixed_id; }



  9. Linux调整swappiness为10

    在 Linux 中,swappiness 是一个内核参数,用于控制系统在使用交换空间(Swap)时的倾向。其值范围为 0 到 100,值越低,系统越倾向于使用物理内存而不是交换空间。将 swappiness 设置为 10 可以减少对交换空间的依赖,适合内存充足的服务器或桌面环境。
    调整步骤
    1. 临时调整(重启后失效)
    执行以下命令临时设置 swappiness 为 10:
    sudo sysctl vm.swappiness=10
    验证设置是否生效:
    cat /proc/sys/vm/swappiness
    2. 永久调整(重启后生效)
    编辑系统配置文件:
    sudo nano /etc/sysctl.conf添加或修改以下行:
    vm.swappiness=10
    保存并退出编辑器,然后使更改生效:
    sudo sysctl -p
    3. 验证修改
    再次检查当前的 swappiness 值:
    cat /proc/sys/vm/swappiness
    现在,swappiness 应该被成功设置为 10。
  10. 在 Discourse 中,如果你想进入容器内并手动修改某个用户的用户名,你可以通过以下步骤实现。这个操作可以通过使用 rails 控制台在容器内直接修改用户信息。
    步骤 1: 进入 Discourse 容器
    使用 SSH 登录到你的服务器。
    进入 Discourse 的安装目录:
    cd /var/discourse进入 Discourse 容器:
    ./launcher enter app这将会把你带入到运行中的 Discourse 容器环境。
    步骤 2: 启动 Rails 控制台
    在容器内,你需要启动 Rails 控制台来修改用户的用户名:
    rails c这将启动 Discourse 的 Rails 控制台,你可以在这个环境中直接操作数据库。
    步骤 3: 查找并修改用户名
    使用以下命令查找要修改的用户:
    u = User.find_by(username: '旧用户名')将 '旧用户名' 替换为你想修改的用户的当前用户名。如果你想根据用户的电子邮件地址查找用户,可以使用以下命令:
    u = User.find_by(email: '用户的邮箱')接下来,修改用户的用户名:
    u.username = '新用户名' u.save将 '新用户名' 替换为你想设置的新用户名。

    步骤 4: 确认修改
    通过 u.save 后,用户名应该已经更新成功。你可以再次查询用户来验证用户名是否正确修改:
    User.find_by(username: '新用户名')
    步骤 5: 退出容器
    完成修改后,退出 Rails 控制台并退出容器:
    exit exit第一个 exit 是退出 Rails 控制台,第二个 exit 是退出容器环境。

    步骤 6: 验证修改
    回到浏览器中,登录 Discourse 管理后台,检查用户列表或通过登录测试,确认用户名已经成功更改。
  11. IPS 如何去掉域名后缀的index.php

    在 Invision Community (以前称为 IP.Board) 中,你可以通过修改 伪静态文件或者是进入后台修改SEO设置。以下是具体步骤:
    确保 mod_rewrite 已启用: 确保你的服务器启用了 Apache 的 mod_rewrite 模块。这通常可以通过服务器的配置文件或通过联系你的托管提供商来完成。
    找到并编辑 .htaccess 文件: 在你的 Invision Community 安装目录中,应该有一个 .htaccess 文件。如果没有,可以创建一个。
    添加或修改规则: 在 .htaccess 文件中,添加以下规则:
    <IfModule mod_rewrite.c>     RewriteEngine On     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule ^index\.php/(.*)$ /$1 [L,R=301]     RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> 保存并上传文件: 保存 .htaccess 文件,并将其上传到你的服务器的 Invision Community 安装目录中。
    配置 Invision Community 设置: 进入你的 Invision Community 管理面板,依次点击 “系统” > “网站设置” > “SEO 设置”。
    在 “SEO URL 设置” 部分,确保选择 “Friendly URLs”,并检查“Redirect Non-Friendly URLs”是否已启用。
    完成上述步骤后,你的 Invision Community 站点应当可以在没有 index.php 后缀的情况下正常运行和访问。
    如果你在过程中遇到任何问题,可以在下方进行留言。