leokhoa / laragon

Laragon is a portable, isolated, fast & powerful universal development environment for PHP, Node.js, Python, Java, Go, Ruby. It is fast, lightweight, easy-to-use and easy-to-extend.
https://laragon.org
4.35k stars 366 forks source link

[Virtual Hosts] Possible bug in auto .conf file for subdomains #90

Open lars-29palms opened 5 years ago

lars-29palms commented 5 years ago

Hi there and first of all a big thank you for this amazing software!

I had some nasty problems setting up virtual hosts properly and after reading everything there was to find about this issue, I finally found the solution.

Precondition: Create folders for a domain and a subdomain in "www" directory. For example: "domain.com" "sub.domain.com"

Expected behaviour: http://sub.domain.com.test points to the correct directory.

Behaviour: http://sub.domain.com.test points to the directory of domain.com.

Solution: The auto.sub.domain.com.test.conf file in Apache > sites-enabled looks like this:

define ROOT "C:/laragon/www/sub.domain.com/"
define SITE "sub.domain.com.test"

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

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

    SSLEngine on
    SSLCertificateFile      C:/laragon/etc/ssl/laragon.crt
    SSLCertificateKeyFile   C:/laragon/etc/ssl/laragon.key

</VirtualHost>

Removing the quotes in the solves the issue after reloading Apache.

Before: <Directory "${ROOT}">

After: <Directory ${ROOT}>

alexivashchenko commented 4 years ago

Hi! I faced with the same problem. But the solution was to comment the ServerAlias *.${SITE} for the main domain in auto.domain.com.test.conf

! you will have to remove auto. prefix from this conf file so the Laragon do not overwrite your changes, or you can edit the {LARAGON_ROOT}\usr\tpl\VirtualHost.tpl template file to apply it for all domains automatically.

0x800040005b commented 2 years ago

i removed auto prefix but it doesn't gave any changes.

krathos commented 6 months ago

Anyone solve this? even if i remove the quotes or comment the line, when try to load nothing change and if i reload laragon restore the files... :(

julesledev commented 2 months ago

I have found this answer useful