Premium Economy Software

Perth W Australia

Modifying Apache Virtual Host Httpd files For Yii2

October 3, 2016 Coding 0 comments

I had a big amount of trouble with this when I shifted my local files onto my apache LAMP server. As by now you know, Yii2 separates files into frontend/web and backend/web from the route directory. So when you first upload your files, you get a path error.


First Create Your Virtual Server

If you have not yet created your virtual server go ahead and do it. You can use cpanel or WHM to add a sub cpanel account with the domain or created an addon domain to an existing account. This will automatically generate the virtual host text.

Edit Httpd

The Httpd file is the file that tells Apache where to route the virtual servers to. My httpd file was found in


Use SSH to login and view the httpd file using the ‘VI’ editor.

vi httpd

See if you can find your ‘’ virtualhost.

Do not edit this file. When you use Cpanel and WHM, the scripts automatically generate this file. So any changers you make to it will automatically be removed once the file is re-generated. Once you have done that type “:q”

What you will do is create a ‘plugin’ file that will make the changers.

Create the files


Where $user is your cpanel user and $domain is the name of your domain in the virtual host. Use

VI and :wq – save and quit to create this new plugin instructions.

So your instruction inside could be. You do not need the <virtual host> tags because Apache already knows its a plugin to an existing instruction.

ServerRoot = ''

Then all you need to do now is type.

/scripts/ensure_vhost_includes --all-users

This tells apache to update the scripts and include all virtual host hooks that have been created.