Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

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

    Scheduled Pinned Locked Moved webGUI
    11 Posts 3 Posters 1.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Meijink
      last edited by

      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 ^^

      GertjanG 1 Reply Last reply Reply Quote 0
      • GertjanG
        Gertjan @Meijink
        last edited by

        @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.

        No "help me" PM's please. Use the forum, the community will thank you.
        Edit : and where are the logs ??

        1 Reply Last reply Reply Quote 0
        • M
          Meijink
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • GertjanG
            Gertjan
            last edited by

            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.

            No "help me" PM's please. Use the forum, the community will thank you.
            Edit : and where are the logs ??

            1 Reply Last reply Reply Quote 0
            • M
              Meijink
              last edited by

              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)

              1 Reply Last reply Reply Quote 0
              • GertjanG
                Gertjan
                last edited by

                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.

                No "help me" PM's please. Use the forum, the community will thank you.
                Edit : and where are the logs ??

                1 Reply Last reply Reply Quote 0
                • M
                  Meijink
                  last edited by

                  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.

                  JeGrJ 1 Reply Last reply Reply Quote 0
                  • GertjanG
                    Gertjan
                    last edited by

                    @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'.

                    No "help me" PM's please. Use the forum, the community will thank you.
                    Edit : and where are the logs ??

                    1 Reply Last reply Reply Quote 0
                    • JeGrJ
                      JeGr LAYER 8 Moderator @Meijink
                      last edited by

                      @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.

                      Don't forget to upvote 👍 those who kindly offered their time and brainpower to help you!

                      If you're interested, I'm available to discuss details of German-speaking paid support (for companies) if needed.

                      GertjanG M 2 Replies Last reply Reply Quote 1
                      • GertjanG
                        Gertjan @JeGr
                        last edited by

                        @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.

                        No "help me" PM's please. Use the forum, the community will thank you.
                        Edit : and where are the logs ??

                        1 Reply Last reply Reply Quote 1
                        • M
                          Meijink @JeGr
                          last edited by

                          @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.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.