How to upload Yii2 Proyect to server

Hey everyone!

I’m trying to upload my Yii2 Proyect to a hosting server but i don’t have a clue where some directories goes and which files i must modify to make it work.

(Because it says about i don’t have an index.php)

By the way i’m hosting in 000webhost

Can someone explain me please?

Thank you

Hello, NetoLozano.

You need personal server for this purposes.

Free shared hosting is bad idea for framework.

It may be possible to deploy yii application to a shared hosting environment.

But it requires much more tweaks than a stand-alone server.

http://www.yiiframework.com/doc-2.0/guide-tutorial-shared-hosting.html

As @umneeq suggests, I also recommend you to consider using some VPS.

I use amazon now but I use to have a yii2 site running on GoDaddy Linux hosting for awhile without issues and it was really easy to setup so it’s possible. You just need to be able to have a .htaccess and preferably be able to move your core files out of the root directory.

i had the front end web in the root and the back end web as a folder in the front end web. All of the core files were in the server root and the index.php (frontend and backend) pointed to them. They use apache so that’s why I needed a .htaccess for rewrite rules. The only two files you should have to modify are the index.php files in both root’s or if you use the basic site is the one. If you didn’t use the right url manager function in the right places you might have to edit some of your urls as well.

So to recap, the only files that should be in your web root are the contents of your "web" (not the actual folder but the contents) files which include the index.php, assets folder, .htaccess, theme files etc. The only files you should have to update are the paths in your config file (remove, debug panel and gii) index.php it should look something like this





<?php

require(__DIR__ . '/../../vendor/autoload.php');

require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');


$application = new yii\web\Application(

        yii\helpers\ArrayHelper::merge(

                require(__DIR__ . '/../../common/config/main.php'),

                require(__DIR__ . '/../../frontend/config/main.php'),

        )

);

$application->run();