RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-4717

toorr2p's questions

Martin Hope
toorr2p
Asked: 2024-12-18 03:21:41 +0000 UTC

Docker 容器中的 Laravel - 为 PHP 和 NGINX 容器设置目录和文件的用户和权限

  • 6

laravel chmod

我只是找不到如何正确配置 PHP 和 NGINX 在容器中运行的用户的说明,以便主机系统上的用户有权访问目录和 xwr 文件,并且容器中或容器上都没有问题主持人(如果阅读、编辑、创建)。

我查看了向 Docker 添加项目的各种说明,但到处都忽略了这一点,因此 PHP 仅为所有者创建具有 xwr 权限的目录,导致 NGINX(或 Laravel)在访问文件时返回 404在这些目录中。

NGINX:docker/images/nginx/Dockerfile

FROM nginx:stable-alpine

WORKDIR /var/www/html/public

PHP:docker/images/php/Dockerfile

RUN usermod -u 1000 -a -G www-data www-data

USER www-data

WORKDIR /var/www/html

docker-compose.yml

services:
  nginx:
    build:
      context: docker/images/nginx
    volumes:
      - './docker/images/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf:ro'
      - './docker/logs/nginx:/var/log/nginx'
      - './source:/var/www/html'
    ports:
      - 80:80
    links:
      - php

  php:
    build:
      context: docker/images/php
    user: '1000:33'
    volumes:
      - './source:/var/www/html'
      - './docker/logs/php:/var/log/php/'

通过这些带有 nginx 和 php 的容器的配置,Laravel 创建一个具有以下权限和所有者的目录

drwx------ 3 www-data  www-data 4096 дек 17 22:10 upload

在这种情况下,将使用以下权限创建此目录中的文件

-rw-r--r-- 1 www-data www-data 17782 дек 17 22:10 sddefault.jpg

我使用该方法创建一个目录和图像

\Illuminate\Support\Facades\Storage::put

如何正确地完成所有操作,以便在读取、写入和执行文件时不会出现问题,请分享您的选择!

php
  • 2 个回答
  • 33 Views
Martin Hope
toorr2p
Asked: 2024-01-09 04:37:34 +0000 UTC

为不同的 PHP 版本安装 xhprof

  • 5

服务器有 PHP 8.1、8.2、8.3 三个版本标准安装后使用以下命令

sudo apt install php-pear
sudo apt install php-dev
sudo pecl install xhprof

由于某种原因,我的模块是为 PHP8.2 安装的

我尝试通过指定 php8.3 的路径来更改 pecl 设置,如下所示

which php8.3
pecl config-set php_dir /usr/bin/php8.3

然后再试一次

sudo pecl install xhprof

但出现模块存在的错误

结果8.3下只能通过使用后缀才能安装

sudo apt install php8.3-dev
sudo pecl -d php_suffix=8.3 install xhprof; sudo pecl uninstall -r xhprof

但我不明白为什么当我打电话时在控制台中

php -m 

或者

php8.3 -m

我没有看到 xhprof 模块!?

此外,在脚本中,在 phpinfo() 的输出中;我看到这个模块已连接(脚本在php8.3下运行)!

其中

sudo update-alternatives --config php

8.3 中发布 有 4 个 php 替代选项(提供 /usr/bin/php)。

  Выбор   Путь              Приор Состояние
------------------------------------------------------------
  0            /usr/bin/php.default   100       автоматический режим
  1            /usr/bin/php.default   100       ручной режим
  2            /usr/bin/php8.1        81        ручной режим
  3            /usr/bin/php8.2        82        ручной режим
* 4            /usr/bin/php8.3        83        ручной режим

还有团队

php -v 

显示

PHP 8.3.1 (cli) (built: Dec 21 2023 20:12:13) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.1, Copyright (c), by Zend Technologies
    with Xdebug v3.3.0, Copyright (c) 2002-2023, by Derick Rethans

你能解释一下吗?原因是什么,我在哪里还没有将其配置为默认仅使用 PHP8.3,如果我猜对了问题的原因......

php
  • 1 个回答
  • 34 Views
Martin Hope
toorr2p
Asked: 2023-08-27 07:05:11 +0000 UTC

NPM 错误 ERR! 错误:EACCES:权限被拒绝,重命名

  • 5

在 Ubuntu ~20.04.1 上部署 LEMP,安装 NVM,通过它安装 NPM、Composer,安装 Laravel,执行迁移,更改所有项目文件的所有者和组

$ sudo chown -R www-data:www-data /var/www/lara1.local

我在 NGINX 中配置了主机,在 /etc/hosts 中添加了分辨率,在浏览器中打开了站点(这里一切似乎都正常)。

然后我记得项目的根本需要做什么(顺便问一下,为什么?)

$ npm i

我尝试得到错误:

toorr2p@srv1:/var/www/lara1.local$ npm i
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /var/www/lara1.local/node_modules/axios
npm ERR! dest /var/www/lara1.local/node_modules/.axios-9HH0Je4B
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/var/www/lara1.local/node_modules/axios' -> '/var/www/lara1.local/node_modules/.axios-9HH0Je4B'
npm ERR!  [Error: EACCES: permission denied, rename '/var/www/lara1.local/node_modules/axios' -> '/var/www/lara1.local/node_modules/.axios-9HH0Je4B'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/var/www/lara1.local/node_modules/axios',
npm ERR!   dest: '/var/www/lara1.local/node_modules/.axios-9HH0Je4B'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in: /home/toorr2p/.npm/_logs/2023-08-26T22_52_07_490Z-debug-0.log

告诉我如何解决?一般来说,权限有什么问题,如何让 NPM 作为 www-data 运行或通过 sudo 作为 root 运行?

或者这里有什么大不了的?

P/S 我是第一次安装 Laravel。

linux
  • 1 个回答
  • 18 Views
Martin Hope
toorr2p
Asked: 2023-08-24 04:56:33 +0000 UTC

VSCode - 如何配置 .vscode 文件夹不会出现在服务器上

  • 1

是否有设置阻止将带有 .vscode 配置的目录发送到服务器?毕竟还可以访问服务器!

visual-studio-code
  • 1 个回答
  • 53 Views
Martin Hope
toorr2p
Asked: 2023-05-08 18:25:57 +0000 UTC

如何在 CRON 上运行 BASH 脚本以在 Ubuntu Linux 中显示带有文本的窗口

  • 5

如果显示窗口的命令是在 CRON 上运行的 BASH 脚本中,我不明白为什么向用户显示窗口不起作用。

happy.sh 脚本的内容

#!/bin/bash
zenity --info --text="Happy birthday!"

crontab 中的命令

*/1 * * * * /bin/sh /home/toorr2p/happy.sh >> /home/toorr2p/happy.log

此外,如果我只是从控制台 zenity --info --text="Happy birthday!" 运行命令 然后显示窗口

或者,如果我从控制台调用脚本 ./happy.sh,那么一切都还可以,但它拒绝在 cron 上工作...

请帮我弄清楚!

linux
  • 2 个回答
  • 23 Views
Martin Hope
toorr2p
Asked: 2023-05-08 05:31:45 +0000 UTC

如何在 linux bash 控制台中计算经过的年数

  • 5

告诉我计算从 1986 年到当前年份的年数的命令是什么样的?

它不是那样工作的,它没有写正确的语法,我不明白如何正确地写它来计算这个差异?

echo date +"%Y" - 1986
linux
  • 4 个回答
  • 37 Views
Martin Hope
toorr2p
Asked: 2020-06-16 16:29:22 +0000 UTC

如何计算 PHP CURL 上 POST 请求标头的 Content-Length?

  • 2

要与 OptiCore Warehouse-Cloud 服务集成,您需要在包含 XML 的 BODY 中执行 POST 请求 ClientOrder_CreateUpdate。此请求所需的 HTTP 标头是 Content-Length,如果未指定,则服务器简单地超时连接。

告诉我如何计算 PHP 中 Content-Length 的这个值?

这是 XML 请求正文

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ClientOrder_CreateUpdate xmlns="http://cowms.ru/outbound"><User>Onwer54797</User><Pass>99dc684baa6af26767e849335db57488</Pass><ClientOrderCode>40</ClientOrderCode><OrderDate>2020-06-16</OrderDate><ExpectedDeliveryDate>2020-06-16</ExpectedDeliveryDate><ExpectedShipmentDate>2020-06-16</ExpectedShipmentDate><OutcomeWarehouse_id>48</OutcomeWarehouse_id><Owner_id>54797</Owner_id><Client_id>0</Client_id><Contractor_id>0</Contractor_id><Agent_id>0</Agent_id><DeliveryType_id>13</DeliveryType_id><DeliveryType_Parameters><DeliveryType_Parameters><ParameterName>PVZCode</ParameterName><ParameterValue>MSK2</ParameterValue></DeliveryType_Parameters><DeliveryType_Parameters><ParameterName>SUMTOPAY</ParameterName><ParameterValue>500.00</ParameterValue></DeliveryType_Parameters></DeliveryType_Parameters><DeliveryMode_id>1</DeliveryMode_id><ClientOrder_Positions><ClientOrder_Positions><ClientOrder_PositionCode>62</ClientOrder_PositionCode><Sku_id></Sku_id><Unit_id>784</Unit_id><StockType_id>0</StockType_id><Price>1199.00</Price><VAT>0</VAT><Qty>1</Qty><IncomeRequest_PositionCode></IncomeRequest_PositionCode><LabelText></LabelText></ClientOrder_Positions><ClientOrder_Positions><ClientOrder_PositionCode>63</ClientOrder_PositionCode><Sku_id></Sku_id><Unit_id>784</Unit_id><StockType_id>0</StockType_id><Price>779.00</Price><VAT>0</VAT><Qty>1</Qty><IncomeRequest_PositionCode></IncomeRequest_PositionCode><LabelText></LabelText></ClientOrder_Positions><ClientOrder_Positions><ClientOrder_PositionCode>64</ClientOrder_PositionCode><Sku_id></Sku_id><Unit_id>784</Unit_id><StockType_id>0</StockType_id><Price>2999.00</Price><VAT>0</VAT><Qty>1</Qty><IncomeRequest_PositionCode></IncomeRequest_PositionCode><LabelText></LabelText></ClientOrder_Positions></ClientOrder_Positions></ClientOrder_CreateUpdate></soap:Body></soap:Envelope>

在 POSTMAN 请求中,由于该值是自动计算的,但如何在 PHP 中执行此操作?https://yadi.sk/i/oaSYQxLof1pS3w

php
  • 3 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5