T
T
Tlito2015-09-26 05:13:37
Nginx
Tlito, 2015-09-26 05:13:37

Nginx how to configure host to process object files via FastCGI?

I need to run a c++ page for the first time on my local computer.
I read different manuals and nothing happened to me.
for example, such a manual with host settings (but for apache, not nginx) and code and even an example demonstration: www.tutorialspoint.com/cplusplus/cpp_web_programmi...
and here there are settings for nginx habrahabr.ru/post/154187
regular php files and static pages.
that is, I wrote in /etc/hosts
127.0.0.1 f.ci
this is my site called f.ci
I installed nginx fcgi and other packages...
configured the server as described in the ubuntu manual help.ubuntu.ru/wiki/nginx-phpfpm
and added host:
Listing host file /etc/nginx/sites-available/f.ci

server
{
  listen	80;
  server_name		f.ci www.f.ci *.f.ci;
  root			/var/www/f.ci/public;
  index index.php index.html index.htm;

  location /
    {
    try_files	$uri $uri/	=404;
    }
 
        location ~ \.php$ 
    {
    try_files $uri =404;
                include fastcgi_params;
    fastcgi_pass  127.0.0.1:9000;
    }

}

spawn start code is written here https://www.nginx.com/resources/wiki/start/topics/... but I still don't understand how.
I currently have an
object file in /var/www/f.ci/public/cgi/cgi.cgi that I got by compiling the C++ program code:
листинг исходного кода программы cgi.cgi
#include <iostream>
using namespace std;
 
int main ()
{
    
   cout << "Content-type:text/html\r\n\r\n";
   cout << "<html>\n";
   cout << "<head>\n";
   cout << "<title>Hello World - First CGI Program</title>\n";
   cout << "</head>\n";
   cout << "<body>\n";
   cout << "<h2>Hello World! This is my first CGI program</h2>\n";
   cout << "</body>\n";
   cout << "</html>\n";
   
   return 0;
}

and now I want to make
this output appear when I access f.ci/cgi/cgi.cgi, I checked it in the console - it works.
tell me why I download this file?
how to edit the host settings file?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question