2017-06-18 54 views
0

我对Wt和cgi的东西很新。我想要做的是用C++编写一个Web应用程序。这可能是由于在重量库:如何在我的本地apache服务器中显示我的Wt应用程序?

https://www.webtoolkit.eu/wt

显然有两种模式:HTTP和FastCGI。前者直接使用:我编译我的代码并运行bin。这启动了某种Web服务器(我的词汇可能不准确,因为我是这个域中的一个大白菜)并输出服务器的地址和端口。在我最喜欢的浏览器中键入所有内容将显示我用C++编写的网页。

我对后者有一个很大的问题,这非常烦人,因为这是在托管远程服务器上部署软件的唯一方法。

要部署测试Web服务器,我使用了Wt库中的hello示例,并通过定义cmake变量EXAMPLES_CONNECTOR = wtfcgi将其与wtfcgi关联。

之后,我安装了apache2并进行了设置。我做了以下内容:

我安装了以下的Ubuntu软件包:

libapache2-mod-fastcgi 
apache2 
apache2-bin 
apache2-data 
apache2-utils 

然后,

  1. 启用的mod_fastcgi的Apache与a2enmod
  2. 修改配置文件fastcgi.conf是这样的:

<IfModule mod_fastcgi.c>; AddHandler fastcgi-script .wt FastCgiIpcDir /var/lib/apache2/fastcgi FastCgiConfig -idle-timeout 100 -maxClassProcesses 1 -initial-env WT_APP_ROOT=/tmp FastCgiServer /var/www/wt/hello.wt </IfModule>

  • 创建重量应用的新的站点配置文件,/etc/apache2/sites-available/wt.conf:
  • <Directory /var/www/wt/> Allow from all Options +ExecCGI </Directory>

  • 复制我的重量示例代码为/var/www/wt/hello.wt

  • 的文件夹启用网站和重装阿帕奇

  • a2ensite wt service apache2 reload

    然后,在这之后,/var/log/apache2/error.log给我

    [Fri Jun 16 22:52:30.176846 2017] [core:notice] [pid 1676:tid 139808785006080] AH00094: Command line: '/usr/sbin/apache2' 
    [Fri Jun 16 22:52:30.177041 2017] [:warn] [pid 1678:tid 139808785006080] FastCGI: server "/var/www/wt/hello.wt" started (pid 1682) 
    [2017-Jun-16 22:52:30.328742] 1682 - [info] "WServer/wtfcgi: initializing relay server" 
    [2017-Jun-16 22:52:30.332011] 1682 - [info] "config: reading Wt config file: /etc/wt/wt_config.xml (location = '/var/www/wt/hello.wt')" 
    [2017-Jun-16 22:52:30.334308] 1682 - [info] "wtfcgi: spawned session process: pid = 1737" 
    [2017-Jun-16 22:52:30.334383] 1682 - [error] "wtfcgi: fatal: cannot create run directory '/var/run/wt'" 
    [Fri Jun 16 22:52:30.337635 2017] [:warn] [pid 1678:tid 139808785006080] FastCGI: server "/var/www/wt/hello.wt" (pid 1682) terminated by calling exit with status '1' 
    [2017-Jun-16 22:52:30.375392] 1737 - [info] "config: reading Wt config file: /etc/wt/wt_config.xml (location = '/var/www/wt/hello.wt')" 
    [2017-Jun-16 22:52:30.375519] 1737 - [info] "WServer/wtfcgi: initializing shared wtfcgi session process" 
    [2017-Jun-16 22:52:30.375708] 1737 - [error] "wtfcgi: fatal: bind(): No such file or directory" 
    

    在那之后,我跟着这个网页给出的建议是:

    http://redmine.webtoolkit.eu/projects/wt/wiki/Fastcgi_on_apache 
    

    例如,我自己创建了/ var/run/wt并将其所有者更改为www-data。然后我得到这个日志:

    AH00112: Warning: DocumentRoot [/var/www/html] does not exist 
    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message 
    [Fri Jun 16 23:15:53.355484 2017] [:notice] [pid 1994:tid 139719627398656] FastCGI: process manager initialized (pid 1994) 
    [Fri Jun 16 23:15:53.355544 2017] [mpm_event:notice] [pid 1656:tid 139719627398656] AH00489: Apache/2.4.18 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 configured -- resuming normal operations 
    [Fri Jun 16 23:15:53.355554 2017] [core:notice] [pid 1656:tid 139719627398656] AH00094: Command line: '/usr/sbin/apache2' 
    [Fri Jun 16 23:15:53.355676 2017] [:warn] [pid 1994:tid 139719627398656] FastCGI: server "/var/www/wt/hello.wt" started (pid 1995) 
    [2017-Jun-16 23:15:53.365485] 1995 - [info] "WServer/wtfcgi: initializing relay server" 
    [2017-Jun-16 23:15:53.365675] 1995 - [info] "config: reading Wt config file: /etc/wt/wt_config.xml (location = '/var/www/wt/hello.wt')" 
    [2017-Jun-16 23:15:53.365878] 1995 - [info] "wtfcgi: spawned session process: pid = 2052" 
    [2017-Jun-16 23:15:53.365942] 1995 - [info] "wtfcgi: reading FastCGI stream from stdin" 
    [2017-Jun-16 23:15:53.373121] 2052 - [info] "config: reading Wt config file: /etc/wt/wt_config.xml (location = '/var/www/wt/hello.wt')" 
    [2017-Jun-16 23:15:53.373243] 2052 - [info] "WServer/wtfcgi: initializing shared wtfcgi session process" 
    

    然后看起来很好。但是,当我现在在我的Firefox浏览器上显示地址127.0.1.1时,我仍然可以看到默认的apache2网页。为什么我没有看到hello示例?我该如何解决?我是否必须编写一个调用hello.wt的特殊html页面?这是如何运作的?

    看起来好像有些东西已经开始,但不能继续运行。我在哪里可以找到那些日志?

    在此先感谢!

    回答

    1

    我设法让它做的工作如下:

    1. 确保该文件夹的/ var/www/html等存在和复制我的重量的应用程序有

    2. 修改配置文件的FastCGI。 CONF这样的:

    <IfModule mod_fastcgi.c> AddHandler fastcgi-script .wt FastCgiIpcDir /var/lib/apache2/fastcgi FastCgiConfig -idle-timeout 100 -maxClassProcesses 1 -initial-env WT_APP_ROOT=/tmp FastCgiServer /var/www/html/hello.wt </IfModule>

  • 摆脱了重量应用站点配置文件:

    /etc/apache2/sites-enabled/wt.conf

  • ,因为它对过程没有影响

  • 重载阿帕奇

    服务apache2的重载

  • 现在,当我键入地址

    localhost/hello.wt 
    
    在我的浏览器

    ,我可以看到显示的例子,假设

    /var/run/wt 
    

    可以由www数据用户创建。

    相关问题