雖然假期的餘額不足了,可是仔細想一想放假又有多少事情能夠作呢?休息的差很少了,仍是上班的好,長時間的休息人就廢了。贊成的舉手,不一樣意的就算了。html
httpd.conf 的配置apache
我這裏使用的是 Wamp 的 Apache 服務器,其配置在 C:\wamp64\bin\apache\apache2.4.33\conf 目錄下,而後修改配置以下:瀏覽器
LoadModule cgi_module modules/mod_cgi.so ScriptAlias /cgi-bin/ "${INSTALL_DIR}/cgi-bin/" # # "c:/Apache24/cgi-bin" should be changed to whatever your ScriptAliased # CGI directory exists, if you have that configured. # <Directory "${INSTALL_DIR}/cgi-bin"> AllowOverride None Options None Require all granted Options ExecCGI Order allow,deny Allow from all </Directory> AddHandler cgi-script .cgi
上面的修改一共是四個部分,並無在一塊兒,查找一下便可。修改完配置之後記得重啓一下服務器。服務器
C 測試代碼微信
修改完 Apache 的配置之後來一段簡單的 C 的代碼,代碼以下:ide
1 #include <stdio.h> 2 3 void main() 4 { 5 printf("\n"); 6 printf("<html><head><title>test</title></head><body>"); 7 printf("<a href=\"www.baidu.com\">test</a>\r\n"); 8 printf("C CGI Test"); 9 printf("</body></html>"); 10 }
代碼很簡單,我使用的是 VS 的 IDE,所以使用 cl 在命令行下編譯一下便可。將編譯完的 exe 文件修改成 cgi 的擴展名,放入 CGI 的目錄下(我這裏是 C:\wamp64\cgi-bin),而後在瀏覽器中輸入地址 http://localhost/cgi-bin/test.cgi 便可。測試
運行效果ui
具體的運行效果就不看了,看一下瀏覽器中「查看源碼」的功能吧,源碼以下:spa
1 <html><head><title>test</title></head><body><a href="www.baidu.com">test</a> 2 C CGI Test</body></html>
效果就是這樣了。.net
注意:在 C 的代碼中,第一行的換行是必需要的,緣由我也不知道。
記錄在此了!
另外,作一個有節操的人,把參考的兩個鏈接給出,並在此感謝。
1 Apache Web 服務器配置CGI程序,執行Python、Perl腳本 - 哎咿呀 - CSDN博客 2 https://blog.csdn.net/sotower/article/details/41014767 3 4 Windows下配置Apache運行C語言的CGI腳本 - u013005924的博客 - CSDN博客 5 https://blog.csdn.net/u013005924/article/details/52021152
個人微信公衆號:「碼農UP2U」