我對Wt和cgi的東西很新。我想要做的是用C++編寫一個Web應用程序。這可能是由於在重量庫:如何在我的本地apache服務器中顯示我的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
然後,
- 啓用的mod_fastcgi的Apache與a2enmod
- 修改配置文件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:
複製我的重量示例代碼爲/var/www/wt/hello.wt
的文件夾啓用網站和重裝阿帕奇
<Directory /var/www/wt/> Allow from all Options +ExecCGI </Directory>
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頁面?這是如何運作的?
看起來好像有些東西已經開始,但不能繼續運行。我在哪裏可以找到那些日誌?
在此先感謝!