Run yii2 app locally from files in CPanel

Hi, I am quite new to Yii framework and got confused when I wanted to run deployed Yii2 app locally on my mac. It is currently giving me error 500 when I run it on localhost.

What I have done so far:

  • Installed Xampp(PHP=>7.3.28) and composer version 1.10.22 (I had to composer self-update --1 due to “fxp/composer-asset-plugin”)
    Then I was getting error about Object that should have been BaseObject in vendor folder
  • Next I removed Vendor and composer.lock, then successfully did “composer install”
    I am confused about the structure of folders on my CPanel, here it is:

I have 2 .htaccess(one in project folder and one is in web)
The one in project folder:

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteRule ^favicon\.png web/favicon.png [L]

RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^font-awesome-4.7.0/(.*)$ web/font-awesome-4.7.0/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^img/(.*)$ web/img/$1 [L]
RewriteRule ^fonts/(.*)$ web/fonts/$1 [L]
RewriteRule (.*) /web/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php

In web:

Options +FollowSymlinks

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# В противном случае перенаправляем на index.php
RewriteRule . index.php

php_value upload_max_filesize 100M
php_value post_max_size 100M

Help me please, if you need any other info or code then let me know.

Btw, I have also exported db from phpmyadmin in cpanel and imported it locally with the same name.

You need to point your web root to web where your index.php is.

you mean I have to add '@webroot' => '@web/index.php' into aliases in config/web.php file, right?

I’m thinking what @samdark is trying to say is… you see the entry point for your server which is usually public_html/index.html? public_html is your webroot. To use Yii, this should point to the web/ directory within your Yii2 installation.

For mine, I had to install Yii on the root folder, where web and public_html are on the same level. Then I copied the files within web into public_html. After fixing some references, twas all grand.