Changing DocumentRoot for localhost only


  • | 322 points

    I want to change the DocumentRoot only for "localhost".
    Backstory: In LAN domain it.example.com pointing to my PC. I want to share under that domain one of my project from /laragon/www/ directory. By default under localhost Laragon shows /laragon/www content. How can i serve /laragon/www/example?


  • administrators
    | 91044 points

    @michalp : You can change the setting in Menu > Laragon > Preferences


  • | 322 points

    I know, but this way, all my new projects will be created inside that directory. I have many projects and want to share in LAN only one of them. Ngrok is not an option becouse of bad performance. I thought that easiest way to share my local application in LAN is to point domain to my ip and set DocumentRoot to directory that I want to share. Also it would be nice to have an option to change it easily.


  • administrators
    | 91044 points

    @michalp : Ah, I see. There is also a topic like yours:
    https://forum.laragon.org/topic/1127/how-to-use-proper-dir-and-virtual-hosts/9

    Let me check and get back to you soon.


  • | 322 points

    I tried something like this (00-default.conf file):

    AFTER:

    define ROOT "C:/laragon/www/example/public/"
    define SITE "it.example.pl"
    
    <VirtualHost _default_:80>
        DocumentRoot "${ROOT}"
        ServerName ${SITE}
        ServerAlias *.${SITE}
        <Directory "${ROOT}">
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
    

    BEFORE:

    <VirtualHost _default_:80>
        <Directory "C:/laragon/www/">
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
    

    Looks like it works, but let me know if this is not a proper way to do this.


  • administrators
    | 91044 points

    @michalp : I'm glad to see you could make it. However, the 00-default.conf file may be re-generate. You should copy the content to a different file such as example.conf.


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.