ubuntu 发布的文章

命令:

cat /etc/os-release

结果:

NAME="ImmortalWrt"
VERSION="21.02-SNAPSHOT"
ID="immortalwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="ImmortalWrt 21.02-SNAPSHOT"
VERSION_ID="21.02-snapshot"
HOME_URL="https://immortalwrt.org/"
BUG_URL="https://github.com/immortalwrt/immortalwrt/issues"
SUPPORT_URL="https://github.com/immortalwrt/immortalwrt/discussions"
BUILD_ID="r0-3fa9687"
OPENWRT_BOARD="mediatek/mt7981"
OPENWRT_ARCH="aarch64_cortex-a53"
OPENWRT_TAINTS="no-all busybox"
OPENWRT_DEVICE_MANUFACTURER="ImmortalWrt"
OPENWRT_DEVICE_MANUFACTURER_URL="https://immortalwrt.org/"
OPENWRT_DEVICE_PRODUCT="Generic"
OPENWRT_DEVICE_REVISION="v0"
OPENWRT_RELEASE="ImmortalWrt 21.02-SNAPSHOT r0-3fa9687"

其中架构为:

OPENWRT_ARCH="aarch64_cortex-a53"

来源

Windows一直以来都有一个系统常量MAX_PATH = 260,用于定义一个文件名(Filename)或者全路径(Directory route)的最大长度,在实际实践中,不管在命令行或者是使用编程语言调用相关系统API处理长路径文件时都会受到此常量的限制,即最大长度不得超过260个字符(characters),这是为了限制某些进程访问过长的路径而对系统产生的潜在风险和影响

在2016年的Windows10 Insider Preview版本(现已支持Windows10Windows Server 2016及以上版本系统)中,微软为Windows用户增加了一项策略Enable NTFS long paths,允许用户在激活该策略时可以突破260个字符的文件路径长度限制。早期版本中只针对NTFS格式的硬盘支持该项策略。

解决方案

在开发过程中,我们难免需要安装各种工具。有些工具的文件路径特别长,超出了Win11的最大文件路径长度限制,这往往会导致文件安装下载无故失败。因此,最简单的解决方法就是关闭文件最大路径长度的限制。

操作步骤

  1. 打开组策略管理器:按下win徽标键+R,输入gpedit.msc并回车,或者直接通过开始菜单打开gpedit
  2. 定位到本地计算机策略计算机配置管理模板系统文件系统启用Win32长路径
  3. 双击后选择已启用确定,搞定。

英语系统

  1. 打开策略管理器:按下win徽标键+R,输入gpedit.msc并回车,或者直接通过开始菜单打开gpedit
  2. 定位到Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem
  3. 在当前位置寻找策略Enable NTFS long paths,在较老的系统版本中,该项策略会在Filesystem下的NTFS策略组中;
  4. 双击Enable NTFS long paths策略,将状态改为Enabled并保存即可。

ubuntu更新

ssh ubuntu@124.220.81.137
sudo apt update
sudo apt upgrade
sudo reboot

安装nginx

ssh ubuntu@124.220.81.137
sudo apt install nginx 
检查安装是否成功
sudo nginx -t
网站输入:http://124.220.81.137,提示nginx安装成功
sudo apt install tree # tree命令方便以树形查看文件结构

安装php8.1

sudo apt install php8.1 php8.1-fpm # 安装php主包

居然同步安装了apache2和很多包

ubuntu@VM-12-2-ubuntu:~$ sudo apt list --installed | grep php

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libapache2-mod-php8.1/jammy-updates,jammy-security,now 8.1.2-1ubuntu2.19 amd64 [installed,automatic]
php-common/jammy,now 2:92ubuntu1 all [installed,automatic]
php8.1-cli/jammy-updates,jammy-security,now 8.1.2-1ubuntu2.19 amd64 [installed,automatic]
php8.1-common/jammy-updates,jammy-security,now 8.1.2-1ubuntu2.19 amd64 [installed,automatic]
php8.1-opcache/jammy-updates,jammy-security,now 8.1.2-1ubuntu2.19 amd64 [installed,automatic]
php8.1-readline/jammy-updates,jammy-security,now 8.1.2-1ubuntu2.19 amd64 [installed,automatic]
php8.1/jammy-updates,jammy-security,now 8.1.2-1ubuntu2.19 all [installed,automatic]
php/jammy,now 2:8.1+92ubuntu1 all [installed]

ubuntu@VM-12-2-ubuntu:~$ sudo apt list --installed | grep apache

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

apache2-bin/jammy-updates,jammy-security,now 2.4.52-1ubuntu4.12 amd64 [installed,automatic]
apache2-data/jammy-updates,jammy-security,now 2.4.52-1ubuntu4.12 all [installed,automatic]
apache2-utils/jammy-updates,jammy-security,now 2.4.52-1ubuntu4.12 amd64 [installed,automatic]
apache2/jammy-updates,jammy-security,now 2.4.52-1ubuntu4.12 amd64 [installed,automatic]
libapache2-mod-php8.1/jammy-updates,jammy-security,now 8.1.2-1ubuntu2.19 amd64 [installed,automatic]
ubuntu@VM-12-2-ubuntu:~$ 

检查php安装情况sudo php -v
发现已经安装php8.1,测试是否可用。

sudo nano /var/www/html/index.php

填入

<?php 
phpinfo(); 
?>

打开链接测试是否运行

http://124.220.81.137/index.php

输入后直接下载,没有打开网页,说明忘记给nginx设置以支持解析php了,调整nginx设置。

首先看nginx配置文件夹结构。

sudo tree /etc/nginx
/etc/nginx
├── conf.d
├── fastcgi.conf
├── fastcgi_params
├── koi-utf
├── koi-win
├── mime.types
├── modules-available
├── modules-enabled
│   ├── 50-mod-http-geoip2.conf -> /usr/share/nginx/modules-available/mod-http-geoip2.conf
│   ├── 50-mod-http-image-filter.conf -> /usr/share/nginx/modules-available/mod-http-image-filter.conf
│   ├── 50-mod-http-xslt-filter.conf -> /usr/share/nginx/modules-available/mod-http-xslt-filter.conf
│   ├── 50-mod-mail.conf -> /usr/share/nginx/modules-available/mod-mail.conf
│   ├── 50-mod-stream.conf -> /usr/share/nginx/modules-available/mod-stream.conf
│   └── 70-mod-stream-geoip2.conf -> /usr/share/nginx/modules-available/mod-stream-geoip2.conf
├── nginx.conf
├── proxy_params
├── scgi_params
├── sites-available
│   └── default
├── sites-enabled
│   └── default -> /etc/nginx/sites-available/default
├── snippets
│   ├── fastcgi-php.conf
│   └── snakeoil.conf
├── uwsgi_params
└── win-utf
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.default # 先做个备份
sudo nano /etc/nginx/sites-available/default

修改前

#location ~ \.php$ {
    #    include snippets/fastcgi-php.conf;
    #
    #    # With php-fpm (or other unix sockets):
    #    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    #    # With php-cgi (or other tcp sockets):
    #    fastcgi_pass 127.0.0.1:9000;
    #}

修改后

        location ~ \.php$ {
                include snippets/fastcgi-php.conf; # 取消注释
         
                # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/run/php/php.8.1-fpm.sock; # 修改为php.8.1-fpm
                # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

重启nginx

sudo systemctl restart nginx

再次测试网址

http://124.220.81.137/index.php

发现出现502 bad gateway错误

检查cat /var/log/nginx/error.log发现如下错误提示,显示无法与php-fpm通讯,原来是设置的时候错将 fastcgi_pass unix:/run/php/php8.1-fpm.sock多加了一个英文点,写成了fastcgi_pass unix:/run/php/php.8.1-fpm.sock

2024/10/21 20:15:45 [crit] 996#996: *1 connect() to unix:/run/php/php.8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 101.82.186.225, server: _, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php.8.1-fpm.sock:", host: "124.220.81.137"

php8.1和php8.1-fpm安装成功。

PHP Version 8.1.2-1ubuntu2.19
SystemLinux VM-12-2-ubuntu 5.15.0-124-generic #134-Ubuntu SMP Fri Sep 27 20:20:17 UTC 2024 x86_64
Build DateSep 30 2024 16:25:25
Build SystemLinux
Server APIFPM/FastCGI
Virtual Directory Supportdisabled
Configuration File (php.ini) Path/etc/php/8.1/fpm
Loaded Configuration File/etc/php/8.1/fpm/php.ini
Scan this dir for additional .ini files/etc/php/8.1/fpm/conf.d
Additional .ini files parsed/etc/php/8.1/fpm/conf.d/10-opcache.ini, /etc/php/8.1/fpm/conf.d/10-pdo.ini, /etc/php/8.1/fpm/conf.d/20-calendar.ini, /etc/php/8.1/fpm/conf.d/20-ctype.ini, /etc/php/8.1/fpm/conf.d/20-exif.ini, /etc/php/8.1/fpm/conf.d/20-ffi.ini, /etc/php/8.1/fpm/conf.d/20-fileinfo.ini, /etc/php/8.1/fpm/conf.d/20-ftp.ini, /etc/php/8.1/fpm/conf.d/20-gettext.ini, /etc/php/8.1/fpm/conf.d/20-iconv.ini, /etc/php/8.1/fpm/conf.d/20-phar.ini, /etc/php/8.1/fpm/conf.d/20-posix.ini, /etc/php/8.1/fpm/conf.d/20-readline.ini, /etc/php/8.1/fpm/conf.d/20-shmop.ini, /etc/php/8.1/fpm/conf.d/20-sockets.ini, /etc/php/8.1/fpm/conf.d/20-sysvmsg.ini, /etc/php/8.1/fpm/conf.d/20-sysvsem.ini, /etc/php/8.1/fpm/conf.d/20-sysvshm.ini, /etc/php/8.1/fpm/conf.d/20-tokenizer.ini
PHP API20210902
PHP Extension20210902
Zend Extension420210902
Zend Extension BuildAPI420210902,NTS
PHP Extension BuildAPI20210902,NTS
Debug Buildno
Thread Safetydisabled
Zend Signal Handlingenabled
Zend Memory Managerenabled
Zend Multibyte Supportdisabled
IPv6 Supportenabled
DTrace Supportavailable, disabled
Registered PHP Streamshttps, ftps, compress.zlib, php, file, glob, data, http, ftp, phar
Registered Stream Socket Transportstcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3
Registered Stream Filterszlib., string.rot13, string.toupper, string.tolower, convert., consumed, dechunk, convert.iconv.*

安装sqlite3和php-sqlite3

sudo apt install sqlite3
sudo apt install php8.1-sqlite3
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


#mail {
#    # See sample authentication script at:
#    # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#    # auth_http localhost/auth.php;
#    # pop3_capabilities "TOP" "USER";
#    # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#    server {
#        listen     localhost:110;
#        protocol   pop3;
#        proxy      on;
#    }
#
#    server {
#        listen     localhost:143;
#        protocol   imap;
#        proxy      on;
#    }
#}

将typcho传到服务器

  1. 开放服务器文件夹写入权限

    sudo chmod 777 /var/www/html #开放html文件夹写入权限,测试755无法上传。
  1. 单开一个ssh界面,需要从本地打开ssh,不要在服务器界面。然后命令格式如下:

    scp C:/Users/28358/Downloads/typecho.zip ubuntu@124.220.81.137:/var/www/html/
    这会将本地的 typecho.zip 文件复制到远程主机 124.220.81.137/var/www/html/ 目录下。

  2. 从远程主机复制到本地
    (1)命令解释

    命令格式如下:
    
    scp user@remote_host:/path/on/remote/file.txt /path/to/local/
    
    这会将远程主机 `remote_host` 的 `/path/on/remote/file.txt` 文件复制到本地的 `/path/to/local/` 目录下。
    

查找www文件夹位置

find -name www
find -name typecho确认typecho文件夹是否存在

解压缩文件

unzip typecho.zip

初始化typecho

浏览器输入http://124.220.81.137/install.php

提示:缺少PHP扩展: mbstring
上传目录无法写入, 请手动将安装目录下的 /usr/uploads 目录的权限设置为可写然后继续升级

安装该扩展

sudo apt install php8.1-mbstring

继续安装,提示:上传目录无法写入, 请手动将安装目录下的 /usr/uploads 目录的权限设置为可写然后继续升级

sudo chmod 777 /var/www/html/usr/uploads
初始化配置
数据库适配器:Pdo 驱动 SQLite 适配器
数据库前缀:typecho_
数据库文件路径:/var/www/html/usr/typecho.db

继续安装,提示:对不起, 无法连接数据库, 请先检查数据库配置再继续进行安装: "SQLSTATE[HY000] [14] unable to open database file"

原因应该是次文件夹无写入权限

sudo chmod 777 /var/www/html/usr

继续安装
创建您的管理员帐号
网站地址
http://124.220.81.137
这是程序自动匹配的网站路径, 如果不正确请修改它

用户名:***
登录密码:***
邮件地址:**@**.com

进入主页http://124.220.81.137可以正常访问

首次登陆后管理界面,输入账号密码后提示404错误

进入登录页面,提示404 Not Found错误,经查询主要是因为typecho需要path_info,而nginx服务器默认并未开启支持path_info。解决办法为修改nginx默认配置,具体代码如下:

sudo nano /etc/nginx/sites-enabled/default

调整如下

原代码

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;

                # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/run/php/php8.1-fpm.sock;
                # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

location ~ \.php(.*)$ {
        # 正则匹配.php后的pathinfo部分
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
                fastcgi_param PATH_INFO $1;
        #       把pathinfo部分赋给PATH_INFO变量        

        }

重启nginx服务器生效。

sudo systemctl restart nginx

将dokuwiki传到服务器

  1. 从本地复制到远程主机

    单开一个ssh界面,需要从本地打开ssh,不要在服务器界面。然后命令格式如下:

    scp C:/Users/28358/Downloads/dokuwiki.zip ubuntu@124.220.81.137:/var/www/html/
    这会将本地的 `dokuwiki.zip` 文件复制到远程主机 `124.220.81.137` 的 `/var/www/html/` 目录下。
    
  2. 解压缩文件夹并开发写入权限

    unzip dokuwiki.zip
    sudo chmod -R 777 dokuwiki
  3. 安装php8.1的xml扩展

    sudo apt install php8.1-xml
    sudo systemctl restart nginx
  4. 初始化安装dokuwiki
    浏览器输入http://124.220.81.137/dokuwiki/install.php一步步安装。

在日本购买iPhone 16并申请退税,目前收集到可以考虑以下几个地方:

  1. 第三方授权店:根据搜索结果,第三方授权店如Bic camera、Yodobashi、爱电王等可以退税。这些店铺通常提供电子产品,包括iPhone,并且符合退税条件。
  2. 百货公司和电器行:在日本,百货公司(如伊势丹、高岛屋)和电器行(如山田电机、藤本电气)也是购买iPhone 16并申请退税的好地方。这些地方通常会有“Japan. Tax-free shop”的标示,表明可以退税。
  3. 退税金额为商品价格的8%,即日本的消费税率。