E
E
Evgeny Glumov2021-03-25 12:06:04
Yii
Evgeny Glumov, 2021-03-25 12:06:04

Why doesn't $application->run(); in YII2?

Moved the project from Debian8 to Centos7 and the Yii application stopped working.
Run() is displayed on the screen and that's it.
All configs are copied from the old server, all dependencies are installed
. What could be the problem?

code index.php
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'prod');

require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/bootstrap.php');
require(__DIR__ . '/../config/bootstrap.php');

$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../..
require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/../config/main.php'),
require(__DIR__ . '/../ config/main-local.php')
);

(new yii\web\Application($config))->run();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeniy Glumov, 2021-03-30
@ViktoriaSchool

Added
< FilesMatch "\.ph(p[3-5]?|tml)$" >
SetHandler application/ x-httpd-php5
< /FilesMatch > to Apache config
and it worked

V
vitaly_74, 2021-03-29
@vitaly_74

It looks like something is wrong with your configuration, here are a few things you can check:
Make sure PHP is installed and working correctly. It may seem silly, but you never know for sure. An easy way to check this is to run php -v from the command line and see if it returns version information or any errors.
Make sure the PHP module is listed and uncommented inside your Apache httpd.conf, it should be something like LoadModule php5_module "c:/php/php5apache2_2.dll" in the file. Find LoadModule php and make sure there is no comment ( ; ) in front of it.
Make sure the Apache httpd.conf file has a PHP MIME type. It should be something like AddType application/x-httpd-php .php . This tells Apache to run .php files as PHP. Find AddType and then make sure there is an entry for PHP and that it is uncommented.
Make sure your file has a .php extension, or whatever extension is specified in the MIME definition in #3, otherwise it will not be executed as PHP.
Make sure you don't use short tags in your PHP file ( <?), they are not enabled by default on all servers and their use is not recommended. Use <?php instead (or enable short tags in your php.ini with short_open_tag=On if you have code that relies on them).
Make sure you are accessing your file via webserver using url likelocalhost/file.php , not via local file access file://localhost/www/file.php
Make sure the php configuration file
/etc/apache2/mods-available/php7.conf is present:
SetHandler application/x-httpd- php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question