Skip to main content
Image for post: Yii 2 on shared hosting

Yii 2 on shared hosting

There was something wrong

Yii 2 has a good documentation and it helps you to do almost anything you need for your application. I have had some trouble on deployment. I have a couple of websites on a shared hosting and I wanted to follow the tutorials but there was something wrong at the end. Let's see the links:

Backend Assets not loaded!

If you are using the yii 2 advanced template like, here you can see how you can move all the framework files. The procedure was ok for me but when I was on my backend login page the assets were not been loaded. That's because on linux, Yii 2 creates the symlinks to your frontend assets. If it can find the these directories, Yii 2 cannot find the assets to load and you will see your backend without css and javascripts!

The solution if to let your backend create the assets on its web/assets directory.

To do so, you have to specify this behaviour in your backend/config/main.php:


'components' => [

    'assetManager' => [

        'linkAssets' => true,

    ],

]

Now you can empty your assets directory deleting all files. When you will reload your page, the layout must be ok because Yii 2 must create its files instead of creating some broken symlinks,

I hope this will be useful. Happy coding!

Share this post

This website and/or any sub domains use cookies to understand how you to improve your experience.