install script

本文档详细介绍了如何在Ubuntu系统中更新源并安装常用工具、VMware Tools、QT、MySQL、SQLite、NFS服务器以及Petalinux。首先,通过阿里云镜像更新Ubuntu源,然后安装基础软件和开发环境。接着,配置NFS服务,建立共享文件夹,并安装Petalinux工具链,以进行Zynq UltraScale+ MPSoC平台的开发。

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

vi /etc/apt/sources.list

----------------------------------------

deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

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

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

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

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

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

deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

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

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

----------------------------------------

//安装基础工具、编译器

sudo apt-get install vim net-tools gcc g++

//安装vmwmware tools(在线安装,不会出现兼容性问题)

sudo apt-get install open-vm-tools open-vm-tools-desktop

//安装QT(断网安装,免账号注册)

sudo /opt/tools/qt-opensource-linux-x64-5.14.2.run

//创建QT快捷方式

sudo vim /usr/share/applications/qtcreator.desktop

----------------------------------------

[Desktop Entry]

Type=Application

Name=qtcreator

Comment=QtCreator

Icon=/opt/Qt5.14.2/qt-logo.jpg

Exec=/opt/Qt5.14.2/Tools/QtCreator/bin/qtcreator

Terminal=false

Categories=Development;IDE;C++;

----------------------------------------

开始菜单,查找Qt, 右键图标,Add to Favorites

//解决Qt make报错问题。14:48:09: Could not start process "make" -j2

sudo apt-get install build-essential

//安装OpenGL库

sudo apt-get install libgl1-mesa-dev

//开机自动设置 vmware 共享文件夹

sudo vim rc.local

----------------------------------------

#!/bin/sh -e

sudo /usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other -o uid=1000 -o gid=1000 -o umask=022

----------------------------------------

sudo chmod +x rc.local

//安装数据库

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

libmysqlcppconn-dev qtbase5-private-dev

sudo apt-get install sqlite3

//change ubuntu default system shell /bin/sh from dash to bash. 输入命令,Configuring dash 选择“No”,回车确认

sudo dpkg-reconfigure dash

sudo apt-get install gnome-control-center

sudo mv /etc/localtime /etc/localtime.bak

sudo ln -s /usr/share/zoneinfo/GMT0 /etc/localtime

==petalinux 安装==============================================================

//依赖库

sudo apt-get install -y iproute2 gawk python3 python build-essential gcc git make net-tools libncurses5-dev tftpd zlib1g-dev libssl-dev flex bison libselinux1 gnupg wget git-core diffstat chrpath socat xterm autoconf libtool tar unzip texinfo zlib1g-dev gcc-multilib automake zlib1g:i386 screen pax gzip cpio python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 libtinfo5

//安装nfs

sudo apt-get install nfs-kernel-server

//配置NFS 的工作目录

sudo mkdir -p /home/user/work

sudo gedit /etc/exports

----------------------------------------

在尾部添加/home/user/work *(rw,sync,no_root_squash,no_subtree_check)

----------------------------------------

//令重启 rpcbind 服务

sudo /etc/init.d/rpcbind restart

//重启 nfs 服务

sudo /etc/init.d/nfs-kernel-server restart

//测试NFS

//通过下面命令挂载 NFS,在本机将 NFS 工作路径挂载在/mnt 目录,127.0.0.1 就是本机 IP

sudo mount -t nfs 127.0.0.1:/home/user/work/nfs /mnt/nfs

//进入/mnt,新建一个 test 目录测试一下,可以在/home/user/work 目录同步看到 test 文件夹

cd /mnt

mkdir test

//创建安装目录,配置权限

sudo -s

mkdir -p /opt/petalinux/2022.2

chgrp user /opt/petalinux/2022.2

chown user /opt/petalinux/2022.2

su user

//安装Petalinux(Zynq UltraScale+ MPSoC 版本)

//sudo vim /var/log/petalinux2022.2_install.log 创建日志文件并保存。

sudo chmod 777 /var/log/petalinux2022.2_install.log

sudo ./petalinux-v2022.2-10141622-installer.run --dir /opt/petalinux/2022.2 --platform "arm aarch64" --log /var/log/petalinux2022.2_install.log

=================Whole Compile Step====================

cd ~/work/petaprj/ps

source /opt/petalinux/2022.2/settings.sh

echo $PETALINUX

petalinux-create -t project -n petalinux --template zynqMP

cd ~/work/petaprj/ps/petalinux

//拷贝vivado生成的xsa文件,然后生成工程。

petalinux-config --get-hw-description ../hardware/petalinux/

// localcache config

copy downloads dir to ~/work/local/

copy sstate_aarch64/aarch64 dir to ~/work/local/

sudo chmod 777 -R local/

//config

Image Packaging Configuration->Root filesystem type (EXT4 (SD/eMMC/SATA/USB))

Image Packaging Configuration->(/dev/mmcblk1p2) Device node of SD device

Yocto Settings ---> Add pre-mirror url ---> file:///home/user/work/local/downloads

Yocto Settings ---> Local sstate feeds settings ---> /home/user/work/local/aarch64

Yocto Settings ---> [ ] Enable Network sstate feeds

Yocto Settings ---> [*] Enable BB NO NETWORK //This is mandatory when you do not have network access on build machines.

sudo gedit project-spec/meta-user/conf/petalinuxbsp.conf

----------------------------------------

DL_DIR = "/home/user/work/local/downloads"

SSTATE_DIR = "/home/user/work/local/aarch64"

sudo gedit project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

----------------------------------------

/include/ "system-conf.dtsi"

/ {

};

/* SD */

&sdhci1 {

disable-wp;

no-1-8-v;

};

/* USB */

&dwc3_0 {

status = "okay";

dr_mode = "host";

};

sudo chmod 666 components/yocto/layers/core/meta/files/common-licenses/*

petalinux-build

=====================Compile Finish====================

//generic boot image

cd images/linux

petalinux-package --boot --u-boot --fpga --force

//根据指导文档格式化SD卡,然后拷贝uboot文件到BOOT分区。

sudo cp images/linux/BOOT.BIN /media/user/BOOT/

sudo cp images/linux/image.ub /media/user/BOOT/

sudo cp images/linux/system.dtb /media/user/BOOT/

sudo cp images/linux/boot.scr /media/user/BOOT/

sudo tar -xzvf ~/work/petaprj/ps/petalinux/images/linux/rootfs.tar.gz -C /media/user/ROOTFS

sudo sync

=====================Burn SD Card Finish====================

petalinux-build -x mrproper

============================================

问题: computer hangs while petalinux-build do_compile

Check the CPUs and Memory. CPU thread too much or insufficient memory.

If used virtul machine, try to change the vm setting. You also can change the petalinux-config.

$ petalinux-config ---> Yocto Settings ---> Parallel thread execution ---> (10) sets number of bb threads (BB_NUMBER_THREADS)

$ petalinux-config ---> Yocto Settings ---> Parallel thread execution ---> (10) sets number of parallel make -j threads (PARALLEL_MAKE)

Yocto Override Syntax Changes

The [:]colon character replaces the use of [ _ ] underscore referring to an override.

Please check the link for more information:https://docs.yoctoproject.org/migration-guides/migration-3.4.html#override-syntax-changes.

git://sourceware.org/git/binutils-gdb.git;branch=binutils-2_37-branch;protocol=git

dtb dts

sudo /opt/petalinux/2022.2/components/yocto/buildtools/sysroots/x86_64-petalinux-linux/usr/bin/dtc -I dtb -O dts ~/work/test/system.dtb -o ~/work/test/system.dts

问题: ERROR: binutils-2.37-r0 do_package_write_rpm_setscene: Error executing a python function in exec_func_python() autogenerated:

...Not enough memory, increase memory or decrease cpu cores&threads.

$ petalinux-config ---> Yocto Settings ---> Parallel thread execution ---> (1) sets number of bb threads (BB_NUMBER_THREADS)

$ petalinux-config ---> Yocto Settings ---> Parallel thread execution ---> (1) sets number of parallel make -j threads (PARALLEL_MAKE)

问题: WARNING: u-boot-tools-1_2021.07-r0 do_populate_sysroot_setscene: No sstate archive obtainable, will run full task instead.

Yocto Settings ---> [*] Enable Network sstate feeds http://petalinux.xilinx.com/sswreleases/rel-v${PETALINUX_VER}/aarch64/sstate-cache

Yocto Settings ---> [ ] Enable BB NO NETWORK

问题: ERROR: pmu-rom-native-2022.2-r0 do_fetch: Network access disabled through BB_NO_NETWORK (or set indirectly due to use of BB_FETCH_PREMIRRORONLY) but access requested with command /usr/bin/env wget -t 2 -T 30 --passive-ftp -P /home/user/work/local/downloads 'http://petalinux.xilinx.com/sswreleases/rel-v2022/downloads/openDownload%3Ffilename%3DPMU_ROM.tar.gz' (for url http://petalinux.xilinx.com/sswreleases/rel-v2022/downloads/openDownload%3Ffilename%3DPMU_ROM.tar.gz)

问题: {standard input}: Error: open CFI at the end of file; missing .cfi_endproc directive aarch64-xilinx-linux-g++: fatal error: Killed signal terminated program cc1plus

Insufficient memory.

问题: libfdt fdt_check_header(): FDT_ERR_BADMAGIC BootOrder not defined EFI boot manager: Cannot load any image

sudo cp images/linux/boot.scr /media/user/BOOT/

<think>我们正在处理用户关于Nginx配置中`unknowndirective`错误的问题,特别是`location~\.php$`块中的语法问题。根据用户提供的配置片段和引用内容,我们可以分析可能的原因和解决方案。用户配置片段:```location~\.php${fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;```根据引用[2]和引用[3],常见的错误包括拼写错误、缺少空格和不可见字符。另外,引用[1]和引用[4]提到,如果指令不在正确的上下文中(例如,`stub_status`只能在特定位置使用),也会导致错误。引用[5]则提醒我们参考官方文档。具体分析:1.指令拼写:检查`fastcgi_pass`、`fastcgi_index`、`fastcgi_param`、`include`等指令的拼写是否正确(注意大小写,Nginx指令不区分大小写,但通常使用小写)。2.指令参数格式:每个指令必须以分号结束,参数之间用空格分隔。3.指令上下文:确保这些指令位于`server`块内的`location`块中。4.不可见字符:用户配置中`fastcgi_param`指令的参数换行,且前面有空格,这可能是复制粘贴时引入的不可见字符(如全角空格)导致。在用户配置片段中,我们发现以下问题:-`fastcgi_param`指令的参数被分成了两行,且第二行前面有空格(可能是制表符或空格)。虽然Nginx允许指令参数跨行,但这里需要注意缩进是否使用了特殊字符(如全角空格)。-在`include`指令后面有两个空格,然后才是`fastcgi_params;`,这通常不会有问题,但为了整洁可以调整为单个空格。另外,根据引用[3],在条件判断中,如`if`和括号之间需要空格,但这里没有使用`if`,所以不适用。解决方案步骤:1.**检查并清理不可见字符**:使用`cat-A`命令查看配置文件,检查是否有不可见字符(如`^M`(回车符)、全角空格(显示为`^`或`M-BM-`)等)。```bashcat-A/etc/nginx/conf.d/your_conf_file.conf```如果发现不可见字符,可以使用`sed`命令清理:```bashsed-i's/\r//g;s/ //g'/etc/nginx/conf.d/your_conf_file.conf```2.**修正指令格式**:将`fastcgi_param`指令的参数写在一行,并确保指令以分号结束:```nginxfastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;```如果因为长度需要换行,可以使用反斜杠`\`,但通常不建议,因为容易出错。3.**确保指令在正确的上下文中**:检查整个配置结构,确保`location~\.php$`块位于`server`块内,并且`server`块位于`http`块内。4.**检查文件路径**:`include`指令的文件路径是否正确?`fastcgi_params`文件通常位于Nginx配置目录(如`/etc/nginx/`)下。如果路径不对,可以使用绝对路径。5.**检查Nginx版本**:某些指令可能在旧版本中不可用,但`fastcgi_param`是基础指令,通常不会。6.**测试配置并查看日志**:```bashnginx-t```如果测试失败,查看错误日志(通常位于`/var/log/nginx/error.log`),根据日志进一步排查。修改后的配置块示例:```nginxlocation~\.php${fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;}```注意:每个指令的参数之间用空格分隔,指令结束必须有分号。如果问题仍然存在,请按照引用[1]的建议检查其他语法错误或查看错误日志。相关问题:1.如何配置Nginx支持PHPFastCGI?2.Nginx配置中`include`指令的作用是什么?3.如何调试Nginx配置错误?</think>## 解决 Nginx "unknown directive" 错误(PHP 配置块) ### 错误原因分析 根据您的配置片段和引用内容,`location ~ \.php$` 块出现 "unknown directive" 错误的主要原因有: 1. **隐藏字符污染**(最常见问题)[^1][^2] - 配置中的空格可能是全角空格(` `)而非标准空格 - 行尾可能有不可见的回车符(`^M`)或 BOM 头 2. **指令格式错误** - `fastcgi_param` 指令跨行书写时格式错误(如断行位置不正确) - 缺少必要的分号结尾 [^3] 3. **路径引用错误** - `$document_root` 变量未正确定义 - `fastcgi_params` 文件路径错误 ### 完整修复步骤 #### 第一步:清理隐藏字符 ```bash # 检查隐藏字符(注意行号可能变化) sudo cat -A /etc/nginx/sites-enabled/your_site.conf | grep -A5 "location ~ \\.php\$" # 清理全角空格和特殊字符 sudo sed -i \ -e 's/ / /g' \ # 替换全角空格 -e 's/\r//g' \ # 删除 Windows 回车符 -e 's/^ *//g' \ # 删除行首多余空格 /etc/nginx/sites-enabled/your_site.conf ``` #### 第二步:修正指令格式 ```nginx location ~ \.php$ { # 确保 fastcgi_param 完整在一行(重要!) fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 其他标准指令 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; # 注意结尾分号 } ``` #### 第三步:验证配置结构 ```nginx http { server { server_name your_domain.com; root /var/www/html; # 必须定义 $document_root # 正确的位置块结构 location ~ \.php$ { # 此处放置 fastcgi 指令 } } } ``` #### 第四步:检查依赖文件 ```bash # 确认 fastcgi_params 文件存在 ls -l /etc/nginx/fastcgi_params # 如果缺失,从官方获取 sudo curl -o /etc/nginx/fastcgi_params \ https://raw.githubusercontent.com/nginx/nginx/master/conf/fastcgi_params ``` ### 完整配置示例 ```nginx http { server { listen 80; server_name blog.oldoylinux.cn; root /var/www/blog; # 定义 $document_root location ~ \.php$ { # 关键修复:确保指令完整在一行 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; # 安全增强配置 fastcgi_param HTTPS $https if_not_empty; fastcgi_intercept_errors on; } } } ``` ### 测试与验证 ```bash # 测试配置语法 sudo nginx -t # 查看详细错误(如果测试失败) sudo grep "unknown directive" /var/log/nginx/error.log # 重启服务 sudo systemctl reload nginx # 测试 PHP 解析 echo "<?php phpinfo(); ?>" | sudo tee /var/www/blog/test.php curl -I http://blog.oldoylinux.cn/test.php ``` ### 预防措施 1. **使用语法检查工具**: ```bash # 安装配置验证工具 sudo apt install nginx-light && sudo nginx -t ``` 2. **版本兼容性检查**: ```bash nginx -V # 确认编译包含 --with-http_fastcgi_module ``` 3. **配置片段校验**: ```bash echo 'location ~ \.php$ { include fastcgi_params; }' | nginx -T - 2>&1 ``` > 参考 Nginx 官方文档:[Managing Configuration Files](https://docs.nginx.com/nginx/admin-guide/basic-functionality/managing-configuration-files/) [^5] --- ### 相关问题 1. 如何为 Nginx 配置 PHP-FPM 的 Unix socket 连接? 2. Nginx 的 `$document_root` 变量未定义会导致什么后果? 3. 为什么 `include fastcgi_params` 必须放在 `fastcgi_param` 自定义指令之前? 4. 如何诊断 Nginx 配置中的隐藏字符问题?[^1][^4] 5. FastCGI 参数 `SCRIPT_FILENAME` 和 `SCRIPT_NAME` 有什么区别?
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值