Ubuntu8.04快速搭建nginx+php系統(tǒng) |
發(fā)布時(shí)間: 2012/8/13 11:38:44 |
昨天在FreeBSD下玩了nginx+php,今天到ubuntu下來(lái)玩玩了,首先要感謝“過(guò)夠了”的文章以下是按他的文章修改而來(lái)。在ubuntu下搭建比f(wàn)reebsd下速度要快得多,因?yàn)樵趂reebsd我是用ports方式安裝,需要編譯,ubuntu下直接apt-getinstall的方式安裝,速度很快,下面就來(lái)開(kāi)始安裝吧!
1,安裝nginx,執(zhí)行以下命令,很快完成,不過(guò)目前apg-get方式安裝默認(rèn)是0.5.33的版本 sudoapt-getinstallnginx 配置文件默認(rèn)安裝位置: conf:/etc/nginx/nginx.conf 例:建一個(gè)虛擬Server server{ location/{ location~\.php${ 2,安裝php-cgi模塊 執(zhí)行sudoapt-getinstallphp5-cgi 配置文件默認(rèn)安裝位置: php-cgi:/usr/bin/php-cgi 修改php.ini文件的cgi.fix_pathinfo數(shù)據(jù)為1,默認(rèn)為0cgi.fix_pathinfo=1;這樣php-cgi方能正常使用SCRIPT_FILENAME這個(gè)變量
如果系統(tǒng)沒(méi)有安裝GCC編譯環(huán)境,剛需要在安裝lighttpd之前要安裝build-essential工具包,執(zhí)行以下命令 sudoapt-getinstallbuild-essential 這樣cgi控制器就安裝完成. 4.啟動(dòng)測(cè)試系統(tǒng).啟動(dòng)fast_cgi: spawn-fcgi-a127.0.0.1-p9000-C5-uwww-data-gwww-data-f/usr/bin/php-cgi 注意:ip,端口與nginx服務(wù)器中的cgi-pass要對(duì)應(yīng).-C表示打開(kāi)幾個(gè)cgi進(jìn)程 啟動(dòng)nginx sudo/etc/init.d/nginxstart 好了,如果沒(méi)有出錯(cuò)信息,則說(shuō)明配置成功了,現(xiàn)在寫(xiě)個(gè)phpinfo測(cè)試下吧! 最后,附上我的/etc/nginx/sites-enable/default的配置文件,此配置文件啟用了rewrite功能 server{ access_log/var/log/nginx/localhost.access.log; location/{ if(-f$request_filename/index.html){ } #error_page404/404.html; #redirectservererrorpagestothestaticpage/50x.html #proxythePHPscriptstoApachelisteningon127.0.0.1:80 #passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000 #denyaccessto.htaccessfiles,ifApache’sdocumentroot #anothervirtualhostusingmixofIP-,name-,andport-basedconfiguration #location/{ #HTTPSserver #sslon; #ssl_session_timeout5m; #ssl_protocolsSSLv2SSLv3TLSv1; #location/{ 本文出自:億恩科技【www.yaz797.com】 服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM] |