programing:cpp_fastcgi
Differences
This shows you the differences between two versions of the page.
| programing:cpp_fastcgi [2025/12/17 01:39] – created mlivolsi | programing:cpp_fastcgi [2025/12/17 14:07] (current) – mlivolsi | ||
|---|---|---|---|
| Line 20: | Line 20: | ||
| In regular CGI, a request comes in. One of the web servers forks a new process, which then becomes it’s processing and returns the response. The forking and then mutating into the process (fork-exec is an interesting side conversation) is a time consuming process and doesn’t scale well. | In regular CGI, a request comes in. One of the web servers forks a new process, which then becomes it’s processing and returns the response. The forking and then mutating into the process (fork-exec is an interesting side conversation) is a time consuming process and doesn’t scale well. | ||
| - | Added Read: All About fork/exec. | + | Added Read: [[https:// |
| ==== FastCGI ==== | ==== FastCGI ==== | ||
| Line 34: | Line 34: | ||
| * apt-get install nginxsudo | * apt-get install nginxsudo | ||
| * apt-get install curl | * apt-get install curl | ||
| + | * The Gnu C++ compiler | ||
| + | |||
| + | |||
| + | ==== Configuring the Web Server ==== | ||
| + | |||
| + | **Create a Directory** | ||
| - | The Gnu C++ compiler | ||
| - | Configuring the Web Server | ||
| - | Create a Directory | ||
| First, create a directory for your fastCGI binary. It should be under your DOCUMENT_ROOT directory. | First, create a directory for your fastCGI binary. It should be under your DOCUMENT_ROOT directory. | ||
| - | Ie. For me, my site was located under / | + | For me, my site was located under / |
| - | mkdir / | + | |
| + | * chown www-data: | ||
| + | |||
| + | **Configuring NGINX Config** | ||
| - | Configuring NGINX Config | ||
| On Ubuntu (this should run on releases 18 and up), just add the following to any of your configuration files under / | On Ubuntu (this should run on releases 18 and up), just add the following to any of your configuration files under / | ||
| + | |||
| + | < | ||
| server { … | server { … | ||
| - | location /fcgi/ { gzip off; | + | location /fcgi/ { |
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| # Other listening stuff | # Other listening stuff | ||
| + | </ | ||
| + | |||
| + | Restart nginx: < | ||
| + | |||
| + | **Explanation** | ||
| + | |||
| + | * Location is where you will place your fastCGI scripts. | ||
| + | * The 127.0.0.1: | ||
| + | * fastCGI program that will listen on port 8000 | ||
| + | * Fastcgi_params come with nginx/ | ||
| - | Restart nginx: sudo systemctl restart nginx | ||
| - | Explanation | ||
| - | | ||
| - | The 127.0.0.1: | ||
| - | Factcgi_params come with nginx/ | ||
| You are now done with the NGINX webserver. | You are now done with the NGINX webserver. | ||
| - | Getting ready to Test | + | |
| - | You’re going to want to test POST and GET form submission. So for the POST, let’s create a basic page that will submit a form. Place this under any place you store your HTML | + | **Getting ready to Test** |
| + | |||
| + | You’re going to want to test POST and GET form submission. So for the POST, let’s create a basic page that will submit a form. Place this under any place you store your HTML. | ||
| < | < | ||
| Line 70: | Line 88: | ||
| </ | </ | ||
| - | NOTE: I called this fast.html | + | **NOTE:** I called this fast.html |
| Hmmm.. it looks like I’m going to call a program called “fast.cgi” under the fcgi directory | Hmmm.. it looks like I’m going to call a program called “fast.cgi” under the fcgi directory | ||
| - | Create Compile Scripts | + | |
| + | **Create Compile Scripts** | ||
| Before we get to coding, let’s set up the compile scripts. | Before we get to coding, let’s set up the compile scripts. | ||
| The program will create an object file whose purpose is to break up the query string into name/value pairs. This will be helpful later on in your code to find out the values for each field in your HTML form. | The program will create an object file whose purpose is to break up the query string into name/value pairs. This will be helpful later on in your code to find out the values for each field in your HTML form. | ||
| - | g++ common.cpp -c -Wall -Wno-deprecatedmv common.o ./objects | + | < |
| + | |||
| + | **The meat and potatoes program.** | ||
| - | The meat and potatoes program. | + | This will compile the fast.cpp into fast.cgi using the object file above. |
| < | < | ||
programing/cpp_fastcgi.1765935562.txt.gz · Last modified: by mlivolsi
