How is web GUI linked to freebsd and how does it work ?


  • Hey everyone i'm new here. I'm currently studying pfsense source code and i were wondering how the web GUI was made (i noticed it has been done with php). What i wan't is to find out and understand how it's linked to the freebsd OS, how it is set to the address and can be reached through the browser etc... If someone can help me it would be very appreciated. Best regards

    PS : sry for my bad english ^^


  • @Meijink said in How is web GUI linked to freebsd and how does it work ?:

    I'm currently studying pfsense source code

    Continue studying.
    The GUI is a classic web server, nginx, rooted in /usr/local/www/ - and lots of code in /etc/inc/.
    Basically, when you validate a GUI page with settings, the usual FreeBSD shell command line commands are executed, or configuration files are reconstructed, and the belonging process is restarted so the new settings are taken in account.

    Just like your .... coffee machine, acces point, ISP router, your DSM from Syno, Plex, etc etc etc.


  • Thanks for your reply i understood a lot now especially about how the GUI is developed. And how can the GUI made with php execute the BSD commands ? is there a particular way ? i looked for it in the files but coudn't guess how and where it was done.


  • PHP can do anything.

    Open a console/ssh connection, use option 8 and :

    cd /etc/inc/
    grep 'mwexec' *
        and
    grep ' exec(' *
    

    This is just an example.


  • Good morning ^^, thanks again for your help. I made a tons of research and i got what were explaining. One last thing : would you recommend python for this ? (i assume it's possible with python so tell me if i'm wrong)


  • Using Python to study the pfSense source code ?
    I would use my eyes and brains.

    pfSense could get rewritten in Python some day.
    PHP has become, like BASIC in the past, too basic.
    If it was me, it would be C and or C++.

    Take note that pfSense isn't only PHP - the GUI is for 99% PHP, but pfSense is more then that.
    A modified FreeBSD kernel, a boatload of FreeBSD packages, some C code, a sniff of Python, a modified layout of the FreeBSD file system.


  • I were meaning if you would recommend python to write the GUI instead of php or another language but i get your point there. I were actually just wondering why they would use php instead of another language. Thank for your help on this topic. Best regards.


  • @Meijink said in How is web GUI linked to freebsd and how does it work ?:

    they would use php instead of another language

    Check out where pfSense came from. That will fill in the why part.
    Back then, in the darker ages, everybody that could read and write, could 'code' PHP - as BASIC in the ancient period.
    In the past, pfSense was close to be rommable, with a minimal RAM needed as a scratch pad.

    And believe it or not, PHP code was easily maintainable (in the past).
    The other known web language was ASP but that needed an IIS server thus no very 'free'.

  • LAYER 8 Moderator

    @Meijink said in How is web GUI linked to freebsd and how does it work ?:

    I were meaning if you would recommend python to write the GUI instead of php or another language but i get your point there. I were actually just wondering why they would use php instead of another language. Thank for your help on this topic. Best regards.

    Would they do it in Python? No.
    Why? Because nowadays that's not what you would do to create a flexible webUI. If the UI will be redone I sincerely hope it will be the same way as in TNSR and use an API as ground layer (RESTCONF) and put a cli and UI on top of that. No playing around with a webstack but using a tiered architecture that can be expanded in multiple ways.


  • @JeGr said in How is web GUI linked to freebsd and how does it work ?:

    use an API as ground layer (RESTCONF) and put a cli and UI on top of that.

    Totally agree with that.
    It will be a huge task, and thus I'll doubt it's economically feasible.


  • @JeGr thanks for this intervention i didn't get everything about the technology you mentionned but i will try to find informations about it.
    @Gertjan thanks again for your support through this topic it helped me a lot.