Ubuntu安裝Lighttpd

來源:互聯網
上載者:User

標籤:linux   ubuntu   web伺服器   

介紹

lighttpd是眾多OpenSource輕量級的web server中較為優秀的一個。支援FastCGI, CGI, Auth, 輸出壓縮(output compress), URL重寫, Alias等重要功能。

[編輯]Lighttpd
sudo apt-get install lighttpd   #安裝lighttpd

安裝後系統會自動啟動lighttpd,開啟http://localhost 便是,如果你之前有裝Apache,那預設首頁換成 http://localhost/index.lighttpd.html 。

web伺服器的根目錄是在 /var/www/ ,設定檔是在/etc/lighttpd/lighttpd.conf。

重啟lighttpd的命令

sudo /etc/init.d/lighttpd restart 
Lighttpd預設頁面
[編輯]啟用使用者目錄

啟用使用者目錄後,每個使用者的home目錄便有自個的web目錄。命令:

sudo lighttpd-enable-mod userdir

重新載入配置

sudo service lighttpd reload

現在使用者可以放置檔案到home目錄下的public_html檔案夾內。比如qii使用者需要放置檔案到/home/joe/public_html,開啟 http://loaclhost/~qii

參考圖
[編輯]PHP

安裝php5-cgi

sudo apt-get install php5-cgi

啟用fastcgi:

sudo lighttpd-enable-mod fastcgi

重新載入配置:

sudo service lighttpd reload

建立、測試phpinfo:

sudo vi /var/www/info.php
<?php phpinfo(); ?>

開啟 http://localhost/info.php 。

[編輯]安裝Zend Optimizer

要求PHP版本為5.2,不支援Ubuntu10.04的PHP5.3,請參照PHP5.2。

下載 Zend Optimizer。 直接貼,參考版本號碼改(這是32位的),不然首頁要註冊才能下

 http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz 
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
cd ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_compsudo mkdir /usr/local/zendsudo cp ZendOptimizer.so /usr/local/zend 

編輯php.ini

sudo gedit /etc/php5/cgi/php.ini

開頭加入,注意標點符號要英文。

[Zend Optimizer]zend_optimizer.optimization_level=1  zend_extension="/usr/local/zend/ZendOptimizer.so"

重啟lighttpd

sudo /etc/init.d/lighttpd restart 

還是上面那個phpinfo檔案,要能看到如下資訊

This program makes use of the Zend Scripting Language Engine:Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies    with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
[編輯]安裝XCache
sudo apt-get install php5-xcache
[email protected]:/home/qii# dpkg -l | grep xcachii  php5-xcache                          1.2.2-5                                         Fast, stable PHP opcode cacher

xcache設定檔路徑是

/etc/php5/conf.d/xcache.ini

編輯php.ini

sudo gedit /etc/php5/cgi/php.ini

把xcache.ini的內容加入到php.ini。 重啟lighttpd

sudo /etc/init.d/lighttpd restart  

檢查安裝是否成功

[email protected]:/home/qii# php -vPHP 5.2.10-2ubuntu6 with Suhosin-Patch 0.9.7 (cli) (built: Oct 23 2009 16:30:10) Copyright (c) 1997-2009 The PHP GroupZend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies    with XCache v1.2.2, Copyright (c) 2005-2007, by mOo

還有前面info.php頁應該有XCache模組

info頁面的XCache模組

這裡有點奇怪的是,如果不把xcache.ini的內容加入php.ini,apache也能載入XCache,但info.php上沒XCache模組。

[編輯]安裝eAccelerator
sudo apt-get install php5-dev

下載 eAccelerator

wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1 
phpizesudo ./configure -enable-eaccelerator=sharedsudo make
[email protected]:~/tmp/eaccelerator-0.9.6.1$ sudo make installInstalling shared extensions:     /usr/lib/php5/20060613+lfs/

修改php.ini檔案,安裝為Zend擴充,最好放在開頭,放到[zend]之前,免的出莫名其妙的問題:

sudo vi /etc/php5/cgi/php.ini
[eaccelerator]zend_extension="/usr/lib/php5/20060613+lfs/eaccelerator.so" eaccelerator.shm_size="16" eaccelerator.cache_dir="/tmp/eaccelerator" eaccelerator.enable="1" eaccelerator.optimizer="1" eaccelerator.check_mtime="1" eaccelerator.debug="0" eaccelerator.filter="" eaccelerator.shm_max="0" eaccelerator.shm_ttl="0" eaccelerator.shm_prune_period="0" eaccelerator.shm_only="0" eaccelerator.compress="1" eaccelerator.compress_level="9" eaccelerator.allowed_admin_path="/var/www/control.php"

建立cache緩衝目錄

eaccelerator.cache_dir="/var/cache/eaccelerator"   這裡定義cache路徑

預設值是/tmp/eaccelerator,這非常簡單因為任何人都對該目錄可寫,但是並不明智,因為重啟後系統會自動清理該目錄。一個更好的地方是/var/cache/eaccelerator。建立該目錄並確保它對eAccelerator的使用者可寫(通常該使用者是你的網路伺服器運行者,可能是www-data)。 使用預設值的話這樣繼續:

mkdir /tmp/eaccelerator
chmod 777 /tmp/eaccelerator

改成 /var/cache/eaccelerator的話這樣繼續,先改php.ini

eaccelerator.cache_dir="/var/cache/eaccelerator" 
sudo mkdir /var/cache/eacceleratorsudo chown root:www-data /var/cache/eacceleratorsudo chmod u=rwx,g=rwx,o= /var/cache/eaccelerator

複製控制檔案control.php到網站根目錄

sudo cp control.php /var/www/

修改control.php的$user和$pw,預設是admin和eAccelerator

sudo vi /var/www/control.php 

重啟lighttpd

sudo /etc/init.d/lighttpd restart

開啟 http://localhost/control.php

eAccelerator control.php頁面

查看之前的info.php頁面,有下欄欄位:

This program makes use of the Zend Scripting Language Engine:Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies    with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator    
[編輯]ROR+MySQL[編輯]安裝
sudo apt-get install ruby ruby1.8-dev rubygems 
sudo apt-get install mysql-server mysql-client  #中途需要輸入root使用者密碼
sudo gem install mysql 
sudo gem install rails
sudo apt-get install  libfcgi-dev libfcgi-ruby1.8 

Ubuntu安裝Lighttpd

聯繫我們

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