How To Configure Apache For Yii2-Advance

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



  - Common

  - Backend 

       - Web 

  - Frontend 

       - Web 

What we’re going to do is point Frontend > Web to


Backend Web to

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 either via 1) Add-on Domain or 2) Create Sub-cpanel account

  2. 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"


    # Other directives here


  1. 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


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]"

  1. Now you restart your apache server from cpanel.

  2. Now for the 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.