I've read many comments that it's not possible to install Yii 2 advanced on a shared hosting environment, as it has two webroots. This is partially true.
In this tutorial I'm going to demonstrate how to install Yii 2 advanced on GODADDY shared hosting. Why GODADDY? In GODADDY it's possible to set the document root of the subdomains and addon domains out of the public_html folder. (In other hostings this trick might not work).
My main website is in Yii 1, which is hosted on Godaddy shared hosting. I've also installed a Yii 2 advanced website on subdmain. Look:
- Main domain (Yii 1): http://oligalma.com
- Subdomain (Yii 2): http://edu.oligalma.com
Take note that, in this example, I installed Yii 2 advanced on a subdomain (in order not to buy a new domain). But you can install Yii 2 advanced on a domain as well.
How to achieve this? Well, we just need to create a folder on the /home/myself directory called, for example, sites (or whatever). Then we upload the Yii 2 advanced files on /home/myself/sites/yii2advanced (you can give the directory any name you want). Then, using the Godaddy cPanel, we create 2 subdomains:
- yii2advanced.website.com ---> /home/myself/sites/yii2advanced/frontend/web
- admin.yii2advanced.website.com ---> /home/myself/sites/yii2advanced/backend/web
home
├── myself
├── public_html
├── sites
├── yii2advanced
├── frontend
├── web
├── backend
├── web
Finally, you may need to add an A record of your main domain.
And that's all!!
(You can create the sites folder if you plan to put several domains/subdomains there. If not, you can just put the yii2advanced folder directly in /home/myself)
If you want to install Yii 2 on a domain instead of a subdomain you need to purchase a deluxe plan https://www.godaddy.com/hosting/web-hosting, which allows you to have multiple sites (and therefore create addon domains).
It's important to note that we don't use the public_html folder to install the Yii 2 advanced. If you want you can install any website there that doesn't need to set the document root (Joomla, Wordpress, Yii 1, etc.)
Works on Dreamhost
On Dreamhost you can set the webroot too.
I usually put the backend on a subdomain - admin.host.name - so it is possible :)
Hi!, sorry what do you mean with this?
"Finally, you may need to adjust the A records of your main domain."
Wich are the A records?
Thanks!!
Hello @Patoinguai. I mean the DNS records. You may need to add an A record.
https://kinsta.com/wp-content/uploads/2017/08/change-godaddy-a-record-1.png
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.