0

我尝试使用 PHP 部署器部署 laravel 5.6。该站点已成功部署。但是我在尝试访问该网站时看到以下错误,

Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /mnt/data/sites/laravel_deployer/releases/5/vendor/symfony/http-foundation/Request.php on line 1587

PHP 信息页面显示,该站点使用 PHP 7.0.27 运行 使用错误的 PHP 版本运行的站点

而部署服务器中的默认 PHP 版本是 7.1。

[surendar.m@testmachine current]$ php -v
PHP 7.1.17 (cli) (built: May 10 2018 17:38:04) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

我有以下疑惑,

  1. 为什么部署的站点没有使用系统默认的 PHP 版本?
  2. 这是因为 PHP 版本不匹配我在尝试访问网站时遇到解析错误吗?

我的作曲家版本是 1.9.1

Composer.json 文件如下,

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
    "php": "^7.1.3",
    "fideloper/proxy": "^4.0",
    "laravel/framework": "5.6.*",
    "laravel/tinker": "^1.0"
},
"require-dev": {
    "filp/whoops": "^2.0",
    "fzaninotto/faker": "^1.4",
    "mockery/mockery": "^1.0",
    "nunomaduro/collision": "^2.0",
    "phpunit/phpunit": "^7.0"
},
"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},
"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},
"extra": {
    "laravel": {
        "dont-discover": [
        ]
    }
},
"scripts": {
    "post-root-package-install": [
        "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@php artisan key:generate"
    ],
    "post-autoload-dump": [
        "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover"
    ]
},
"config": {
    "preferred-install": "dist",
    "sort-packages": true,
    "optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
4

1 回答 1

0

PHP 的 cli 版本和 Apache 使用的版本不必匹配。您需要重新配置 Apache 以使用 PHP 7.1。

于 2020-08-17T01:40:34.053 回答