AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[laravel](server)

Martin Hope
Joshua Wilkeson
Asked: 2022-04-02 15:43:54 +0800 CST

为什么我的 Laravel 应用程序在生产中的 TTFB 超过 3 秒?

  • 0

我环顾四周,但找不到关于图像之类的东西是否会影响 TTFB 的明确答案,这将是我最好的猜测,为什么我的网站需要这么长时间才能加载到生产环境中。页面完全接收完成后,我看到它被传输40.7 mb resources了很多,但初始页面加载仅占其中的 20.1kb,其次是 images/js/css。

从网络检查器导出的 .har 文件:

"pages": [
  {
    "startedDateTime": "2022-04-01T23:10:26.010Z",
    "id": "page_1",
    "title": "https://example.com/",
    "pageTimings": {
      "onContentLoad": 5878.881000004185,
      "onLoad": 6390.734000000521
    }
  }
],

在这之后是诸如图像/js/css之类的东西。

我尝试过的事情:

  • 用一个简单的 echo 语句替换 index.php 中的内容,<?php echo 'foobar'; ?>这可以立即解决问题,因为页面加载时间不到一秒。
  • 确保它与托管在同一服务器上的其他应用程序具有相同的缓存配置,并且加载时间也更少。
  • composer install --optimize-autoloader --no-dev
  • composer dump-autoload -o
  • php artisan route:cache
  • php artisan config:cache

我的问题是:虽然图像/css/js 等资源有自己的 TTFB,但它们是否会增加初始页面的第一个字节的时间?

编辑:我想指出的另一件事是,这发生在资源不密集的页面上,而且它所在的服务器是Microsoft Windows Server 2016 Standard和VMware, Inc. VMware7.1

performance php laravel
  • 1 个回答
  • 339 Views
Martin Hope
Erfan Safarpoor
Asked: 2022-03-27 05:00:34 +0800 CST

错误 Process 类依赖于 proc_open,这在您的 PHP 安装中不可用

  • -1

在更改服务器并使用 cpanel lumen cron 作业设置 centos 后,每分钟将此错误添加到流明日志:

Process 类依赖于 proc_open,它在您的 PHP 安装中不可用。在 /home/username/public_html/api/vendor/symfony/process/Process.php:143

我看到活动的 php 版本 ini 并从禁用的功能中删除 proc_open 并重新启动 litespeed 但未解决此问题我更改了流明配置但未修复。如果你现在我该如何解决这个问题,请帮助我。

centos php laravel whm
  • 1 个回答
  • 1378 Views
Martin Hope
Abu Dawud
Asked: 2022-02-19 17:57:37 +0800 CST

Nginx:域的proxy_pass路径到不同的Web服务器

  • -1

我们计划将我们的 Web 应用程序从基于 php 本机的应用程序升级到基于 PHP 框架 (Laravel) 以增强应用程序的安全性和性能。我的任务是拆分流量,其中每个请求都指向app.localhost没有后缀的域,/v3仍然转发到 Web 服务器节点上的旧应用程序,并使用到 Web 服务器节点的路径php-native代理所有请求。下面是我的配置,导致 Laravel 生成的所有资产(css 和 js)和 URL 都指向根路径。/v3laravel

Laravel 生成的 URL 指向旧应用程序

前端代理(公共网络)

server {
    listen       80;
    listen  [::]:80;
    server_name  app.localhost;

    # PHP Native APP
    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://php-native/;
    }

    # Laravel (APP v3)
    location /v3/ {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://laravel/;
    }
}

Web 服务器(专用网络)

php-native网络服务器

server {
    listen       80;
    listen  [::]:80;
    server_name  app.localhost;

    root   /usr/share/nginx/html/webapp/app;

    location / {
        index index.php index.html index.htm;

        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass   php56-fpm:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME /var/www/html/webapp/app/$fastcgi_script_name;
        include        fastcgi_params;
    }
}

laravel网络服务器

server {
    listen       80;
    server_name  app.localhost;

    root   /usr/share/nginx/html/webapp/app-v3/public;
    index index.php index.html index.htm;

    location / {
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass   php74-fpm:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME /var/www/html/webapp/app-v3/public/$fastcgi_script_name;
        include        fastcgi_params;
    }
}

谢谢

更新

我的问题是:如何拆分流量,所以指向的任何请求app.localhost仍然转发到php-nativeWeb 服务器并且所有指向的请求都app.localhost/v3指向laravelWeb 服务器?

nginx laravel
  • 1 个回答
  • 445 Views
Martin Hope
Mohammad Zahed
Asked: 2022-02-08 05:21:55 +0800 CST

nginx大文件上传限制

  • 0

我正在使用 Laravel Forge 来管理我的服务器,但在使用 livewire 上传大文件时遇到了问题。100 秒后上传失败并显示此错误:

net::ERR_HTTP2_PING_FAILED

而有时:

ERR_CONNECTION_RESET

我的 PHP 超时为 1000,上传文件大小为 1.5 GB,但我不知道为什么会这样。我尝试在我的 nginx 配置中设置这些,但没有帮助。

fastcgi_read_timeout 1000;
client_header_timeout 1m;
client_body_timeout 1m;
proxy_connect_timeout 60s;
proxy_read_timeout 1m;
proxy_send_timeout 1m;
php upload nginx laravel
  • 2 个回答
  • 726 Views
Martin Hope
JohnnyAce
Asked: 2021-03-09 21:57:49 +0800 CST

代理转发在 Nginx、Laravel、弹性负载均衡器上不起作用

  • 0

我有一个 AWS 弹性负载均衡器,它接收域 (bunny.misite.dev) 的 https 请求,请求通过 http 发送到服务器 Nginx,Laravel 应用程序回答请求。

我遇到的问题是 Laravel 没有将请求识别为 Https,而是将请求识别为 http。

为了解决这个问题,Laravel 提供了一个我使用过的“可信代理”中间件:

<?php

namespace App\Http\Middleware;

use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;

class TrustProxies extends Middleware
{
    /**
     * The trusted proxies for this application.
     *
     * @var array|string|null
     */
    protected $proxies = '*';

    /**
     * The headers that should be used to detect proxies.
     *
     * @var int
     */
    protected $headers = Request::HEADER_X_FORWARDED_FOR |
        Request::HEADER_X_FORWARDED_HOST |
        Request::HEADER_X_FORWARDED_PORT |
        Request::HEADER_X_FORWARDED_PROTO |
        Request::HEADER_X_FORWARDED_AWS_ELB;
}

我的 nginx 配置是

server {
    listen                  80 ;
    listen                  [::]:80 ;

    server_name             bunny.misite.dev;
    server_tokens           off;
    error_log               /home/main/logs/nginx/bunny-master_error.log;
    access_log              /home/main/logs/nginx/bunny-master_access.log main buffer=16k;
    access_log              /var/log/nginx-rc/bunny-master_traffic.log traffic;

    client_max_body_size    256m;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    root /home/main/webapps/bunny-master/live/public;
    index index.php index.html index.htm;

    location / {
        
        proxy_send_timeout         60;
        proxy_read_timeout         60;
        proxy_buffer_size          128k;
        proxy_buffers              4 256k;
        proxy_busy_buffers_size    256k;
        proxy_temp_file_write_size 256k;
        proxy_connect_timeout       30s;

        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Server-Addr $server_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port  $server_port;

        proxy_pass http://backend;
    }

    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }

    location = /favicon.ico {
        log_not_found off;
    }

    location @proxy {
        proxy_send_timeout         60;
        proxy_read_timeout         60;
        proxy_buffer_size          128k;
        proxy_buffers              4 256k;
        proxy_busy_buffers_size    256k;
        proxy_temp_file_write_size 256k;
        proxy_connect_timeout       30s;

        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Server-Addr $server_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://backend;
    }
}
nginx laravel amazon-elb
  • 1 个回答
  • 1539 Views
Martin Hope
Carol.Kar
Asked: 2021-02-27 09:41:42 +0800 CST

从本地开发环境连接到 vps 上的生产数据库

  • 0

我正在使用Ubuntu 20.04.1 LTS带有已部署Laravel Framework 6.20.16应用程序的 VPS。

我目前正在使用 dbeaver 通过 ssh 连接到我的 mysql 数据库,使用 simpleroot@IP_Address和 mypassword进行连接。

但是,我还想通过 laravel 连接到我的暂存/生产数据库,因为它不是在本地镜像生产数据库的选项。

我知道,如果实施不当,可能会导致我的应用程序出现严重漏洞。

任何建议如何做到这一点?

我将衷心感谢您的帮助!

ubuntu mysql security vps laravel
  • 1 个回答
  • 188 Views
Martin Hope
Rohan
Asked: 2020-12-04 22:30:50 +0800 CST

调用 API 时如何更好地配置 nginx 以减少冗余系统调用?

  • 0

我有一个在生产环境中运行的 Laravel 应用程序,并且有一些 API 使用很多。某些东西造成了瓶颈,它曾经使我们的服务器停止运行(3 个带有负载均衡器)。在优化了 Laravel 的基础,缓存配置、路由、数据等,甚至解决了所有 n+1 个问题后,我们仍然在高峰期遇到问题。有人建议我们在其中一个 nginx 工作人员上运行 strace 以查看系统级别发生了什么,所以我们这样做了,而且很有趣,有很多冗余系统调用,当调用 API 时 nginx 会尝试查找文件:

部分跟踪:

240498 stat("/var/www/html/myProject/current/public/APIRequest/3d4f7518e04e9", 0x7ffc7ee6ff70) = -1 ENOENT (No such file or directory)
240498 stat("/var/www/html/myProject/current/public/APIRequest/3d4f7518e04e9", 0x7ffc7ee6ff70) = -1 ENOENT (No such file or directory)
240498 lstat("/var", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
240498 lstat("/var/www", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
240498 lstat("/var/www/html", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
240498 lstat("/var/www/html/myProject", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
240498 lstat("/var/www/html/myProject/current", {st_mode=S_IFLNK|0777, st_size=48, ...}) = 0
240498 readlink("/var/www/html/myProject/current", "/var/www/html/myProject/release"..., 4095) = 48
240498 lstat("/var", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
240498 lstat("/var/www", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
240498 lstat("/var/www/html", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
240498 lstat("/var/www/html/myProject", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
240498 lstat("/var/www/html/myProject/releases", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
240498 lstat("/var/www/html/myProject/releases/20201202085755", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
240498 lstat("/var/www/html/myProject/releases/20201202085755/public", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0

现在,在这种情况下使用 ID 调用 API 3d4f7518e04e9,并尝试遍历目录以查找该文件。但它不是一个文件,它是一个 API。我们运行 strace 的时间不到 30 秒,我们有 5k 次这样的调用,这对我来说没有意义。

那么,这些调用是否必要?我不这么认为,但如果我错了,请告诉我。如果我是对的,我怎样才能更好地配置我的 nginx,以便这些调用可以“及时捕获”并得到适当的解决。欢迎任何想法。:)

PS:我们也尝试过具有类似配置的 apache,在 strace 中出现了同样的问题。

编辑:我是否只需要在我的站点配置中添加某种位置指令来解决这个问题?我正在使用官方文档https://laravel.com/docs/8.x/deployment#nginx中的基本 nginx conf,并添加了更多内容,例如:

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;

        fastcgi_buffer_size 128k;
        fastcgi_buffers 256 16k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }

    client_body_buffer_size 10K;
    client_header_buffer_size 1k;
    client_max_body_size 8m;
    large_client_header_buffers 4 16k;

    client_body_timeout 12;
    client_header_timeout 12;
    keepalive_timeout 15;
    send_timeout 10;

编辑:

location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

我确实按照 Danila Vershinin 在回答中的建议尝试了文件

apache-2.2 nginx laravel strace
  • 1 个回答
  • 209 Views
Martin Hope
imori
Asked: 2020-09-16 00:08:41 +0800 CST

无法在 Laravel 上部署到 Google Cloud Platform

  • 1

使用“gcloud app deploy”在 GCP 上部署 laravel 时出现以下错误。

ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build ID~~~ status: FAILURE
Error ID: 5888fcc4
Error type: UNKNOWN
Error message: Loading composer repositories with package information
Installing dependencies from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - This package requires php ^7.3 but your HHVM version does not satisfy that requirement.
  Problem 2
    - Installation request for laravel/framework v8.2.0 -> satisfiable by laravel/framework[v8.2.0].
    - laravel/framework v8.2.0 requires php ^7.3 -> your PHP version (7.2.33) does not satisfy that requirement.
  Problem 3
    - Installation request for nunomaduro/collision v5.0.2 -> satisfiable by nunomaduro/collision[v5.0.2].
    - nunomaduro/collision v5.0.2 requires php ^7.3 -> your PHP version (7.2.33) does not satisfy that requirement.
  Problem 4
    - laravel/framework v8.2.0 requires php ^7.3 -> your PHP version (7.2.33) does not satisfy that requirement.
    - laravel/tinker v2.4.2 requires illuminate/console ^6.0|^7.0|^8.0 -> satisfiable by laravel/framework[v8.2.0].
    - Installation request for laravel/tinker v2.4.2 -> satisfiable by laravel/tinker[v2.4.2].


php -v
PHP 7.3.22-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Sep  9 2020 06:46:30) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.22, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.22-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

我还检查了 php 版本,但我能够确认它是 7.3

我检查了 composer.json 并在 7.3 中指定

 "require": {
        "php": "^7.3",
            },

我参考网上的资料尝试了“composer install”、“composer update”和“composer upgrade”,但问题没有解决。

我检查了这个站点以了解如何部署

google-cloud-platform laravel ubuntu-18.04 php7 google-app-engine-standard
  • 1 个回答
  • 687 Views
Martin Hope
Riccardo Giannini
Asked: 2020-08-28 05:21:14 +0800 CST

App Engine 与 PostgreSQL 数据库的连接突然断开

  • 0

App Engine 与 PostgreSQL 数据库的连接突然断开

我的 App Engine 与其 CloudSQL 数据库的连接不再有效。直到昨天(26/08/2020)我能够正常使用我的 App Engine 网站。突然发生了一些变化,它说“SQLSTATE[08006] [7] 无法连接到服务器:连接被拒绝服务器是否在主机“127.0.0.1”上运行并接受端口 5432 上的 TCP/IP 连接?

我不得不说我从未设置 App Engine 应用程序通过端口 5432 连接到数据库。我可以向您展示我当前关于数据库连接的 app.yaml 配置:

beta_settings:
  cloud_sql_instances: "beecoms:europe-west3:beecoms-db"
  
env_variables:
[omissis]
  DB_CONNECTION: pgsql
  DB_HOST: "/cloudsql/PROJECTID:beecoms-db"

它曾经工作得很好。我在 Google Cloud Platform Debugger 中追溯了我的应用程序引擎版本,发现一个运行良好:一个正常运行,虽然有点过时,但当前的一个无法连接到 DB。

我尝试查看旧文件以查看 config 文件夹中的 app.yaml 或 .env 或某些 laravel 的配置文件是否与我当前的版本不同,但我找不到任何区别。

我还应该从我的本地机器上补充一点,我仍然可以使用 cloud_sql_proxy 访问数据库,所以这不是 CloudSQL 服务器问题,我相信这是 App Engine 和 CloudSQL 之间的连接问题

如何恢复 App Engine 与其 CloudSQL 数据库的连接?

问候,里卡多

google-app-engine google-cloud-platform laravel google-cloud-sql
  • 1 个回答
  • 200 Views
Martin Hope
Coola
Asked: 2020-07-25 19:01:39 +0800 CST

为 Laravel 应用程序选择 Google App Engine 标准环境还是灵活环境?

  • 0

我正在 GCP App Engine 上部署 Laravel 应用程序(内容管理系统),但我不确定标准环境与灵活环境的优缺点是什么,以及它将如何影响 Laravel 应用程序。该应用程序不会有很多用户(低流量),但需要读取数据库并显示多行的输出等。有人可以突出差异并提供建议。如果这个问题不适合这里,我很抱歉,因为我是这个 StackExchange 的新手。

google-app-engine laravel
  • 1 个回答
  • 810 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve