How to Set Up Custom HTTPD Configuration for Yii2 on a Directadmin Server Running nginx

By | February 5, 2020

Today I’m coming with a setting for Yii2, as I haven’t found any documentation about this. So we will set up advanced template of Yii, on a Directadmin server, running on nginx.

First of all, you need to install Yii2 – you can do it as you like, via composer or regular installation. This step is very well documented and I will not pay attention to it. We are going to set up both frontend and backend on the same domain, so frontend will be accessible through, and backend – via

We need to have shell access to make a symbolic link from frontend to backend. In order to do this, please, access your command line and go to your frontend path. We suppose you use a default Directadmin configuration, and your installation is located at


Then you need to set up a symbolic link:

ln -s ../../backend/web admin

OK, now we know how to access backend from frontend, we need to set it up at custom httpd configuration section (you need to log in as admin in Directadmin to access this feature).

We need to set up the alternative document root.


Scroll to CUSTOM3 token and add the following code:

try_files $uri $uri/ /index.php?$uri&$args;

location /admin
try_files $uri $uri/ /admin/index.php?$uri&$args;

This will allow to pass GET variables to right places, for frontend and backend.

Save this configuration, and try – you should be done!

Leave a Reply

Your email address will not be published.