構建linux下的web伺服器

來源:互聯網
上載者:User

1、從源碼安裝 apache
=================================================================
apache
-----------------------------------------------------------------
./configure --prefix=/usr/local/httpd --enable-mods-shared=all --enable-so --enable-deflate --enable-rewrite --enable-info

make && make install

# 查看配置參數
httpd -V

 

2、源碼安裝 php
=================================================================
php
-----------------------------------------------------------------
dependences:
libxml2.x86_64
libxml2-devel.x86_64
./configure --prefix=/usr/local/php-5.2.17 --with-apxs2=/usr/local/httpd-2.2.22/bin/apxs --with-mysql=shared,/usr --with-zlib-dir --with-mysqli=/usr/lib64/mysql/mysql_config --libdir=/usr/lib64 --with-libdir=lib64 --with-pdo-mysql --with-curl --with-gd --with-config-file-path=conf/php.ini

make && make install

編譯php產生擴充

     進入php來源程式目錄中的ext目錄中,這裡存放著各個擴充模組的原始碼,選擇你需要的模組,比如curl模組:
     cd curl
     執行phpize產生編譯檔案,phpize在PHP安裝目錄的bin目錄下
     /usr/local/php5/bin/phpize
     運行時,可能會報錯:Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
                                 environment variable is set correctly and then rerun this script.“,需要安裝autoconf:
     yum install autoconf(RedHat或者CentOS)、apt-get install autoconf(Ubuntu Linux)

組建組態檔案,並編譯產生模組:

     /usr/local/php-5.2.17/bin/phpize
     ./configure --enable-shared --with-eaccelerator-info --with-php-config=/usr/local/php-5.2.17/bin/php-config  
     make && make install  

這樣,curl.so就被複製到PHP對應目錄(如:/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/)

 

3、源碼編譯 nginx

=================================================================
configure with nginx:
-----------------------------------------------------------------
./configure configure arguments: --prefix=/usr/local/nginx-1.2.6 --with-pcre=/app/temp/pcre-8.32 --with-debug --with-http_realip_module --with-poll_module --with-ipv6 --with-http_ssl_module --with-http_geoip_module --with-http_gzip_static_module --with-mail --with-mail_ssl_module --with-http_stub_status_module --add-module=/NGX_CONCAT_SOURCE_FILE_PATH

make && make install

# 查看配置參數
/usr/local/nginx-1.2.8/sbin/nginx -V

 

4、安裝 apache rpaf 模組

=================================================================
安裝 mod_rpaf 模組
-----------------------------------------------------------------
安裝
tar zxvf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/local/www/apache/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
接著在 httpd.conf 中添加
LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1 # 填寫Nginx的的ip 
RPAFheader X-Forwarded-For 
這樣就可以擷取用戶端訪問的真實IP了

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.