David
David

Reputation: 121

Yii 2 application deployment in laragon local server with virtual hosts

How to deploy yii 2 application on laragon local server ? Laragon automatically creates virtual host file but after changing that server breaks. Application is in C:/laragon/www/yii-app folder laragons created auto.yii-app.conf virtual host file

define ROOT "C:/laragon/www/yii-app"
define SITE "yii-app"

<VirtualHost *:80> 
    DocumentRoot "${ROOT}"
    ServerName ${SITE}
    ServerAlias *.${ALIAS}
    <Directory "${ROOT}">
        AllowOverride All
        Require all granted
    </Directory>    
</VirtualHost>

I'm changing that to this

define ROOT "C:/laragon/www/yii-app/frontend/web"
define SITE "front.yii.com"

<VirtualHost *:80> 
    DocumentRoot "${ROOT}"
    ServerName ${SITE}
    ServerAlias *.${ALIAS}
    <Directory "${ROOT}">
        AllowOverride All
        Require all granted
    </Directory>    
</VirtualHost>

after server breaks and application didn't work. Also I'm removing the "auto." prefix from the Virtual Host file from "auto.yii-app.conf" to "yii-app.conf" because every time when apache is reloading laragon rewrites all virtual host files which have "auto" prefix.

What I'm doing wrong? And how can I solve this problem?

Upvotes: 0

Views: 1392

Answers (1)

Leo Khoa
Leo Khoa

Reputation: 957

You did not define ALIAS. Just replace it with SITE:

define ROOT "C:/laragon/www/yii-app/frontend/web"
define SITE "front.yii.com"

<VirtualHost *:80> 
    DocumentRoot "${ROOT}"
    ServerName ${SITE}
    ServerAlias *.${SITE}
    <Directory "${ROOT}">
        AllowOverride All
        Require all granted
    </Directory>    
</VirtualHost>

Btw - when having errors, the first action you should take is checking Apache error.log (Menu > Apache > error.log)

Upvotes: 0

Related Questions