Linux搭建apache2.2.6 伺服器的fcgi開發平台(自己總結)

來源:互聯網
上載者:User

注意以下的命令操作都是在root下的,ubuntu 下用sudo command
root@host src]# pwd
/usr/local/src
需要的包
apache伺服器源檔案包 httpd-2.2.6.tar.gz
apache的fastcgi模組源檔案包 http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
fastcgi開發套件工具包 http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz(C, C++, Perl, and Java)

步驟
------------------------------------------------------------------------------------------
1.安裝apache伺服器
[root@host src]# tar zxvf httpd-2.2.6.tar.gz
[root@host src]# cd httpd-2.2.6
[root@host httpd-2.2.6]# ./configure --prefix=/usr/local/apache2.2.6
......(configure過程,略)
[root@host httpd-2.2.6]# make
......(make過程,略)
[root@host httpd-2.2.6]# make install
......(makeinstall過程,略)
如果在make過程中出現
......
include/apr.h:392:2: #error no decision has been made on APR_PATH_MAX for your platform
......
先備份apr.h,然後在apr.h的
#if defined(PATH_MAX)
#define APR_PATH_MAX PATH_MAX
之前加上
#if !defined(PATH_MAX)
#define PATH_MAX 4096
#endif
(Just check your PATH_MAX in limits.h to see if it's actually 4096)
[root@host httpd-2.2.6]# pwd
/usr/local/src/httpd-2.2.6

apache伺服器被安裝到了/usr/local/apache2.2.6

[root@host httpd-2.2.6]# cd /usr/local/apache2.2.6/

啟動apache伺服器

[root@host apache2.2.6]# bin/apachectl start
[root@host apache2.2.6]#
在瀏覽器地址欄輸入http://localhost/
出現apache預設頁面。
-------------------------------------------------------------------------------------------
安裝cgi模組:(開發cgi/fcgi應用時最好安裝)

看看/usr/local/apache2.2.6/modules下有沒有mod_cgi.so模組,沒有的話,我們來裝下
[root@host apache2.2.6]# cd bin
[root@host bin]# pwd
/usr/local/apache2.2.6/bin
[root@host bin]# ./apxs -c -i /usr/local/src/httpd-2.2.6/modules/generators/mod_cgi.c
(備忘:./apxs -c -i /apache源檔案路徑/modules/generators/mod_cgi.c )
--------------------------------------------------------------------------------------------
安裝fastcgi模組

[root@host src]# tar zxvf mod_fastcgi-2.4.6.tar.gz
[root@host src]# cd mod_fastcgi-2.4.6
[root@host mod_fastcgi-2.4.6]# cp Makefile.AP2 Makefile
[root@host mod_fastcgi-2.4.6]#
修改Makefile中的幾個目錄
top_dir 需要指定,用apache安裝的路徑,我們當前的是/usr/local/apache2.2.6
APXS 與 APACHECTL使用絕對路徑
APXS      = /usr/local/apache2.2.6/bin/apxs
APACHECTL = /usr/local/apache2.2.6/bin/apachectl
[root@host mod_fastcgi-2.4.6]# make
......(make過程,略)
[root@host mod_fastcgi-2.4.6]# make install
......(makeinstall過程,略)
完成之後/usr/local/apache2.2.6/modules下應該有mod_fastcgi.so
3.修改apache設定檔/usr/local/apache2.2.6/confhttpd.conf
在相應的地方增加
LoadModule fastcgi_module modules/mod_fastcgi.so
AddHandler cgi-script .cgi .pl # 傳統的CGI處理副檔名
AddHandler fastcgi-script .fcgi .fpl # FastCGI處理的副檔名
具體的位置見該部落格頁面最後,注意要找准位置,否則有可能不成功。。。。
重啟apache伺服器
[root@host apache2.2.6]# bin/apachectl restart
[root@host apache2.2.6]#
此時cgi程式和fastcgi程式應該可以跑起來了
---------------------------------------------------------------------------------------------
<Directory "/usr/local/apache2.2.6/cgi-bin">    #CGI set  這個節點是內建的,下面接著FastCGI設定要自己設定
    AllowOverride None
    Options None
    #Options +ExecCGI
    Order allow,deny
    Allow from all
</Directory>
#fcgi
#如果你不想把FastCGI程式放在cgi-bin檔案夾中
#你想放在自己建立的檔案夾下,假如你在目錄apache2.2.6下建立一個檔案夾fcgi-bin存放fcgi檔案
#那麼你就要加入下面的路徑設定。當然如果你直接把fcgi檔案放在cgi-bin目錄中執行,那這就不需要了。
<Directory "/usr/local/apache2.2.6/fcgi-bin">    #FastCGI set 
    AllowOverride None
    Options FollowSymLinks
    Order allow,deny
    Allow from all   
# AddHandler fastcgi-script.fcgi.fpl
</Directory>
................................
# Virtual hosts  
#Include conf/extra/httpd-vhosts.conf

LoadModule fastcgi_module modules/mod_fastcgi.so   #自己添加這三行
AddHandler cgi-script .cgi .pl # 傳統的CGI處理副檔名
AddHandler fastcgi-script .fcgi .fpl # FastCGI處理的副檔名
---------------------------------------------------------------------------------------------

參考文章:

http://blog.csdn.net/su_ocean16/archive/2010/06/07/5652232.aspx

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.