Can i reload nginx from command line like the Reload button in the main ui?


  • | 722 points

    I love Laragon and ever since i found just what i personally use, thank you!
    Im working a small project and i would like to reload nginx after i made new folders. But instead that i must click the Reload button, i want run a command in the shell for example laragon -reload or something, because the Reload command edit the hosts file and update nginx configurations after i clicked - lazy i know.
    I want list and manage my projects with a small laravel application. I learn about sockets now and i invent this.
    Here is my half-baked solution - it isnt too informative: http://pastebin.com/kuFAh4CC


  • administrators
    | 46801 points

    @x-rep-zm: I believe you want to automate Laragon and your code looks fine :)
    I'll release Laragon 2.1.5 which supports laragon reload soon.


  • | 722 points

    Really? I love You, thanks! I share with you the code if im ready.


  • administrators
    | 46801 points

    @x-rep-zm: Laragon 2.1.5 is ready :)
    You can call laragon reload for your purpose.
    https://forum.laragon.org/topic/323/laragon-2-1-5-release-announcement-auto-created-virtual-hosts-from-command-line-laragon-reload


    Note, because Laragon can run with both Nginx & Apache, you can specify service to be reloaded:
    laragon reload nginx
    laragon reload apache


  • | 722 points

    Thank you! This is a Christmas gift


  • | 722 points

    In my computer i used simple setup for creating new hosts without problems and keeping safety.
    Log in with a user with Administrators group (e.g. the firts installed user).

    # Activate superuser and setup the new password
    net user Administrator /active:yes *
    # Create a new command window with administrator privileges
    runas /user:Administrator cmd
    # Create a new usergroup
    net localgroup /add Developers
    # Always prompt when changing is detected (useraccount control settings)
    reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 2 /f
    # Add write only acces to the hosts file for Developers usergroup
    icacls %systemroot%\System32\drivers\etc\hosts /grant Developers:w
    # Create a new user (the new user autmatically assigned with Users group too)
    net user /add developer /fullname:"Developer" *
    # Add the new user to the created usergroup
    net localgroup /add Developers developer
    # Leave superuser command window
    exit
    # Logout: rundll32 user32.dll,LockWorkStation
    

    Logged in with developer user

    # Create new host
    cd %laragonroot% && mkdir www/newhost && echo It works! > www/newhost/index.php
    # And now enjoy the auto virtualhost feature
    laragon reload && start http://newhost.dev
    

  • administrators
    | 46801 points

    Nice :) You must be a Windows guru!


  • | 722 points

    @leokhoa No, im not. I have got a mistake, sorry.

    "The snake can sometimes stumble."


    # Correct
    cd %laragonroot% && mkdir www/newhost && echo It works! > www/newhost/index.php
    # Wrong. Must create the folder before creating the index file
    cd %laragonroot% && echo It works! > www/newhost/index.php
    

  • administrators
    | 46801 points

    No worries, I see that you are very keen on what you are trying to achieve.
    Good to know you :)
    Merry Xmas!


  • | 722 points

    @leokhoa Merry Christmas to You too!


  • | 722 points

    @leokhoa I have got an issue.
    After reload ran, nginx won't serve the new host correctly. And the windows message is get stuck on tray. Is clickable but dont solve anything.

    • stop laragon (elephant)
    • delete all generated nginx sites (Menu/Nginx/sites-enabled/Delete all [auto]
    • remove current host from hosts file (h)
    • remove current directory
    • start laragon (elephant)
    • visit manager site then click the button
    • laragon reloaded
    • host added in the hosts file
    • nginx create the new config file
    • visit the page, but i see only the laragon logo

    I stop and start laragon then everything is fine.
    Have You any idea?

    https://github.com/xrepzm/project-manager (not eventual)

    I use win 10 x64 with nginx-ed laragon.


  • administrators
    | 46801 points

    I had tested laragon reload carefully with Win 7 x32/Win 10 x64/Win 2012 x64
    I guess the issue is on your code when calling laragon reload


Log in to reply
 

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