ubuntu上的laravel申请20.4投掷作曲家错误

发布于 2025-02-04 08:00:57 字数 1987 浏览 2 评论 0原文

我完全知道服务器管理,并拥有一个Ubuntu 20.4实例来启动PHP-Laravel 9应用程序。

到目前为止,我已经安装了PHP 8,MySQL,Nginx,Composer,下载了与作曲家的Laravel应用程序,然后搬到/var/www/html,这意味着我应用程序的路径是:

/var/www/html/my-app

的.env看起来像:

APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

我 它是还是在哪里可以找到正确的app_url?

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=username
DB_PASSWORD=password

我本地主机是正确的数据库主机?

然后,我运行以下命令:

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

将文件配置为如下:

server {

      listen 80;
      server_name ip-111-222-11-111;
      root /var/www/html/my-app/public;
      add_header X-Frame-Options "SAMEORIGIN";
      add_header X-Content-Type-Options "nosniff";
      index index.php;
      charset utf-8;
      location / {
         try_files $uri $uri/ /index.php?$query_string;
      }

       location = /favicon.ico { access_log off; log_not_found off; }
       location = /robots.txt  { access_log off; log_not_found off; }
       error_page 404 /index.php;
       location ~ \.php$ {
            fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            include fastcgi_params;
        }
       location ~ /\.(?!well-known).* {
          deny all;
       }
  }

对SSH,我使用:

ssh [email protected]

因此,我假设12.xxx地址是我应该使用的一个通过浏览器来访问网站的地址,但是当我按照浏览器访问该网站时在浏览器中的地址,我会看到以下内容:

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0".

如果我检查PHP版本,我将获得以下内容:

PHP 8.1.6 (cli) (built: May 17 2022 16:48:09) (NTS)

如何通过浏览器访问网站?

为什么我必须使用sudo运行作曲家安装?

I am completely knew to server management, and have a ubuntu 20.4 instance to launch a PHP-Laravel 9 application.

So far, I have install PHP 8, mysql, nginx, composer, downloaded a laravel application with composer and moved to /var/www/html, meaning that the path to my app is:

/var/www/html/my-app

My .env looks like the following:

APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

What would it be or where can I find the correct APP_URL?

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=username
DB_PASSWORD=password

I localhost the correct database host?

I then ran the following command:

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

When configured the file to look like this:

server {

      listen 80;
      server_name ip-111-222-11-111;
      root /var/www/html/my-app/public;
      add_header X-Frame-Options "SAMEORIGIN";
      add_header X-Content-Type-Options "nosniff";
      index index.php;
      charset utf-8;
      location / {
         try_files $uri $uri/ /index.php?$query_string;
      }

       location = /favicon.ico { access_log off; log_not_found off; }
       location = /robots.txt  { access_log off; log_not_found off; }
       error_page 404 /index.php;
       location ~ \.php$ {
            fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            include fastcgi_params;
        }
       location ~ /\.(?!well-known).* {
          deny all;
       }
  }

To ssh, I use:

ssh [email protected]

So I assumed that the 12.x.x.x address is the one I should use to access the site through the browser, but when I hit that address in the browser, I see the following:

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0".

If I check the PHP version, I get the following:

PHP 8.1.6 (cli) (built: May 17 2022 16:48:09) (NTS)

How do I access the site through the browser?

Why do I have to run composer install using sudo?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文