Yii Framework Forum: How To Configure Apache For Yii2-Advance - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Configure Apache For Yii2-Advance Setting the Virtual Server so that it routes correctly Rate Topic: -----

#1 User is offline   auzadventure 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 20-August 15
  • Location:Singapore

Posted 21 October 2016 - 08:40 PM

Hi Everyone,

I thought I'd write this How To because this issue took me 1 day to resolve and there weren't very good tutorials out there. This is regards to the Yii2-Advance Template.



The Folder Structure
--App
  -
  - Common
  - Backend 
       - Web 
  - Frontend 
       - Web 



What we're going to do is point Frontend > Web to www.mysite.com

and

Backend Web to admin.mysite.com

This is the best solution without messing around with the .htaccess. It's a lot cleaner and using what Apache Virtual host is about.



1. Go to Cpanel and create a virtual host for www.mysite.com either via 1) Add-on Domain or 2) Create Sub-cpanel account

2. www.mysite.com will now be pointing to your --app folder, you want it to point to /frontend/web

Now login to your server via SSH root access and start navigating to /usr/local/apache/conf

You'll see the file

vi httpd.conf


Inside you'll see Virtual Host configurations Like

# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>

    DocumentRoot "/www/mysite"
    ServerName www.mysite.com

    # Other directives here
</VirtualHost>



3. Here is the tricky part. Do not edit this file. This file is automatically generated by cpanel so if you edit it, cpanel will override it once it restarts and wipe out your changers.

What you want to do is write a 'hook' that inserts itself into the code. You do this by creating a separate file in

/usr/local/apache/conf/userdata/std/2_2/$user/$domain/$includename.conf  


just use the vi command to create the file.

User is the name of the cpanel user and domain is the domain name you want to modify.
Include name is any name you want to call it. Above is for a stand not ssl virtual host.

Then make the path change

 DocumentRoot "/www/mysite[u]/frontend/web[/u]"


4. Now you restart your apache server from cpanel.

5. Now for the admin.mysite.com. You simple create a subdomain using the cpanel and point it to /backend/web, this is less difficult.



I hope you guys find this useful.
Questions are the Answer.

Wesvault - Premium Economy Software
Yii2 Framework Specialist
http://www.wesvault.com

Singapore
2

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users