Yii2 shows server interval 500 error

The day before yesterday, I owed a composer update. As a result, Hula Hula upgraded a bunch of things, and continued to encode without problems, so I did not take it seriously.

The next day, there was a problem with the deployment update to the server, a server 500 error was reported, and no specific reason was suggested. . .

Bring the bricks to the table and record the solution.

1. Let the server display the error message first, edit the server php.ini, find display_errors, modify to display_errors = On, save, restart the service

2. The running service is displayed as follows

Parse error: syntax error, unexpected 'function' (T_FUNCTION), 
expecting identifier (T_STRING) or \\ (T_NS_SEPARATOR) 
in /data/qisi_class/vendor/myclabs/deep-copy/src/DeepCopy/deep_copy.php 
on line 5

Usually this kind of grammatical error is caused by the low version language not compatible with the high version writing

3. Check the server php version 5.4.16, 7.2.10 when developing environment

4. The problem is here, the composer is upgraded according to the higher version of the machine, but the server operating environment is too low and incompatible causes errors

5. The server cannot be upgraded casually, the only way is to downgrade the composer matching version, modify composer.json, add the following content

"config": {
        ***
        "platform": {
            "php": "5.4.16"
        }
    },

In this way, composer can match dependent packages according to the specified version.

6. Select the update of composer again and start to rely on the downgrade operation

- Downgrading sebastian/recursion-context (3.0.0 => 1.0.5): Downloading 
- Downgrading sebastian/exporter (3.1.0 => 1.2.2): Downloading (connecting...)
- Installing phpunit/phpunit-mock-objects (2.3.8): Downloading (connecting...)

7. Because the local environment PHP version is high and backward compatible, it will naturally not go wrong. Wait for the downgrade to complete, and the problem of redeploying the server is solved.

For the sake of physical and mental health, don't just order composer update. . .

Published 14 original articles · Like8 · Visit 70,000+

Guess you like

Origin blog.csdn.net/wm20000/article/details/89291421