欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
利用Nginx替代apache實(shí)現高性能的Web環(huán)境
利用Nginx替代apache實(shí)現高性能的Web環(huán)境 更新時(shí)間:2007-11-27作者:NetSeek歡迎轉載,轉載請注明出處: http://bbs.linuxpk.com原文鏈接:http://bbs.linuxpk.com/thread-11845-1-1.html Nginx介紹:Nginx發(fā)音為[engine x],是由俄羅斯人Igor Sysoev建立的項目,基于BSD許可。據說(shuō)他當初是F5的成員之一,英文主頁(yè):http://nginx.net。俄羅斯的一些大網(wǎng)站已經(jīng)使用它超過(guò)兩年多了, 一直表現不凡,相信想了解nginx的朋友都讀過(guò)阿葉大哥的利用nginx實(shí)現負載均衡的文章相關(guān)鏈接見(jiàn)(六)。 測試環(huán)境:紅動(dòng)中國(redocn)提供運營(yíng)服務(wù)器環(huán)境.關(guān)于紅動(dòng)服務(wù)環(huán)境:紅動(dòng)中國在早期利用apache環(huán)境,再加上一些優(yōu)化的工作,一直是相對很穩定,但是最近由于網(wǎng)站發(fā)展,訪(fǎng)問(wèn)量越來(lái)越大,在線(xiàn)人數一多經(jīng)常出現,負載過(guò)高,性能急劇下降,經(jīng)過(guò)雙木站長(cháng)的同意,考慮是否能利用nginx來(lái)代替apache,經(jīng)過(guò)長(cháng)時(shí)間的觀(guān)察目前nginx工作很穩定,系統也不會(huì )再說(shuō)現高負載的狀況,占用內存也很低,訪(fǎng)問(wèn)速率從用戶(hù)體驗來(lái)看明顯有提升.關(guān)于紅動(dòng)中國:紅動(dòng)中國(redocn)論壇經(jīng)過(guò)近1年的快速發(fā)展,目前日均頁(yè)面訪(fǎng)問(wèn)量超過(guò)100萬(wàn),位居全球設計論壇(中文)第1位,是國內最具影響力的設計論壇之一。目前論壇擁有近20萬(wàn)會(huì )員,包括眾多設計界領(lǐng)軍人物在內的行業(yè)中堅力量、相關(guān)藝術(shù)院校師生以及部分設計愛(ài)好者等。 遷移目標:實(shí)現網(wǎng)站論壇靜態(tài)化,防盜鏈,下載并發(fā)數和速率限制,實(shí)現原站apache所具有的所有功能,將原apache環(huán)境下的站點(diǎn)全部遷移到Nginx 一.PHP(Fastcgi)編譯安裝[root@att php-5.2.4]# cat in.sh復制內容到剪貼板代碼:./configure --prefix=/usr/local/php-fcgi --enable-fastcgi --enable-discard-path --enable-force-cgi-redirect --with-config-file-path=/usr/local/php-fcgi/etc --enable-zend-multibyte --with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd2 --with-jpeg-dir --with-png-dir --with-bz2 --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-openssl=/usr/local/openssl --with-mcrypt=/usr/local/libmcrypt --enable-sysvsem --enable-inline-optimization --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-debug --disable-ipv6 makemake installcp php.ini-dist /usr/local/php-fcgi/etc/php.ini注:關(guān)于如何安裝gd庫,mysql的編譯安裝,本文將不介紹,本文重點(diǎn)在于介紹nginx的安裝與配置,如想了解其它相關(guān)的問(wèn)題可以到LinuxPk去找相關(guān)的貼子(http://bbs.linuxpk.com)二.Nginx編譯安裝1.創(chuàng )建nginx運行用戶(hù)和虛擬主機目錄復制內容到剪貼板代碼:groupadd www -g 48useradd -u 48 -g www wwwmkdir -p /data/www/wwwrootchown -R www:www /data/www/wwwroot2.安裝lighttpd中附帶的spawn-fcgi,用來(lái)啟動(dòng)php-cgi先編譯安裝lighttpd產(chǎn)生spawn-fcgi二進(jìn)制文件.復制內容到剪貼板代碼:cd /usr/local/src/lighttpd-1.4.18cp src/spawn-fcgi /usr/local/php-fcgi/bin/啟動(dòng)php-cgi進(jìn)程,監聽(tīng)127.0.0.1的8085端口,進(jìn)程數為250(如果服務(wù)器內存小于3GB,可以只開(kāi)啟25個(gè)進(jìn)程),用戶(hù)為www:/usr/local/php-fcgi/bin/spawn-fcgi -a 127.0.0.1 -p 8085 -C 250 -u www -f /usr/local/php-fcgi/bin/php-cgi3.nginx的安裝與配置 安裝Nginx所需的pcre庫: http://ftp.dk.debian.org/exim/pcre/pcre-7.3.tar.gz復制內容到剪貼板代碼: tar zxvf pcre-7.2.tar.gz cd pcre-7.2/ ./configure make && make install cd ../ http://sysoev.ru/nginx/nginx-0.5.32.tar.gz tar zxvf nginx-0.5.32.tar.gz cd nginx-0.5.32./configure --user=www --group=www --prefix=/usr/local/nginx/ --with-http_stub_status_module --with-openssl=/usr/local/openssl make && make install此模塊非核心模塊,需要在編譯的時(shí)候手動(dòng)添加編譯參數 --with-http_stub_status_module 配置nginx三.Nginx主配置文件及PHP支持.1.nginx.conf 主配置文件的配置#cd /usr/local/nginx/conf/#cp nginx.conf nginx.conf.cao #cat /dev/null > nginx.conf#vi nginx.conf //主配置文件復制內容到剪貼板代碼:user www www;worker_processes 10;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;pid /var/run/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.worker_rlimit_nofile 51200;events{ use epoll; #maxclient = worker_processes * worker_connections / cpu_number worker_connections 51200;}http{ include conf/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; #access_log /data/www/logs/access.log main; #sendfile on; tcp_nopush on; tcp_nodelay off; keepalive_timeout 60; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; connection_pool_size 256; client_header_buffer_size 1k; large_client_header_buffers 4 2k; request_pool_size 4k; output_buffers 4 32k; postpone_output 1460; client_max_body_size 10m; client_body_buffer_size 256k; client_body_temp_path /dev/shm/client_body_temp; proxy_temp_path /usr/local/nginx/proxy_temp; fastcgi_temp_path /usr/local/nginx/fastcgi_temp; #gzip gzip on; gzip_http_version 1.0; gzip_comp_level 2; gzip_proxied any; gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_min_length 1100; gzip_buffers 4 8k; # The following includes are specified for virtual hosts //以下是加載虛擬主機配置. #[url]www.redocn.com[/url] include conf/vhosts/www_redocn_com.conf; #bbs.redocn.com include conf/vhosts/bbs_redocn_com.conf; #blog.redocn.com include conf/vhosts/blog_redocn_com.conf; #down.redocn.com include conf/vhosts/down_redocn_com.conf;}2.配置支持Fastcgi模式的PHP[root@redocn conf]# cat enable_php5.conf復制內容到剪貼板代碼:fastcgi_pass 127.0.0.1:8085;fastcgi_index index.php;fastcgi_param GATEWAY_INTERFACE CGI/1.1;fastcgi_param SERVER_SOFTWARE nginx;#new ac upload#fastcgi_pass_request_body off;#client_body_in_file_only clean;#fastcgi_param REQUEST_BODY_FILE $request_body_file;#fastcgi_param QUERY_STRING $query_string;fastcgi_param REQUEST_METHOD $request_method;fastcgi_param CONTENT_TYPE $content_type;fastcgi_param CONTENT_LENGTH $content_length;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param SCRIPT_NAME $fastcgi_script_name;fastcgi_param REQUEST_URI $request_uri;fastcgi_param DOCUMENT_URI $document_uri;fastcgi_param DOCUMENT_ROOT $document_root;fastcgi_param SERVER_PROTOCOL $server_protocol;fastcgi_param REMOTE_ADDR $remote_addr;fastcgi_param REMOTE_PORT $remote_port;fastcgi_param SERVER_ADDR $server_addr;fastcgi_param SERVER_PORT $server_port;fastcgi_param SERVER_NAME $server_name;# PHP only, required if PHP was built with --enable-force-cgi-redirectfastcgi_param REDIRECT_STATUS 200;四,多虛擬主機應用配置案例.#mkdir /usr/local/nginx/conf/vhosts //建立虛擬主機配置存放目錄.1.www.redocn.com //首站配置[root@redocn vhosts]#vi www_redocn_com.conf復制內容到剪貼板代碼:server { listen 80; server_name www.redocn.com; index index.html index.htm index.php; root /data/www/wwwroot; error_page 404 http://bbs.redocn.com; rewrite ^/bbs/(.*) http://bbs.redocn.com/$1; location ~ .*\.php?$ { include conf/enable_php5.conf; } }注: 關(guān)于rewite需求,紅動(dòng)中國希望當用戶(hù)訪(fǎng)問(wèn)http://www.redocn.com/bbs的時(shí)候自動(dòng)轉至http://bbs.redocn.com在原apache中利用redirect實(shí)現 Redirect /bbs http://bbs.redocn.com本文中在nginx下利用rewrite實(shí)現:rewrite ^/bbs/(.*) http://bbs.redocn.com/$1;2.[root@redocn vhosts] vi bbs_redocn_com.conf復制內容到剪貼板代碼:server { listen 80; server_name bbs.redocn.com yan.redocn.com majia.redocn.com wt.redocn.com; index index.html index.htm index.php; root /home/www/htdocs/bbs; access_log /var/log/nginx/access_bbs.redocn.com.log combined; location / { #bbs rewrite rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last; rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last; rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page\%3D$3&page=$2 last; rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last; rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last; break; #error error_page 404 /index.php; #redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } #Preventing hot linking of images and other file types location ~* ^.+\.(gif|jpg|png|swf|flv|rar|zip)$ { valid_referers none blocked server_names *.redocn.com redocn.com *.taobao.com taobao.com bbs.blueidea.com bbs.asiaci.com bbs.arting365.com forum.chinavisual.com softbbs.pconline.com.cn bbs.chinaddu.com bbs.photops.com *.baidu.com *.google.com *.google.cn *.soso.com *.yahoo.com.cn *.yahoo.cn; if ($invalid_referer) { rewrite ^/ http://www.redocn.com/images/redocn.gif; #return 403; } } #support php location ~ .*\.php?$ { include conf/enable_php5.conf; } }注:1.紅動(dòng)中國采用高性能的Discuz!論壇,原apache的rewrite規則幾乎不要做什么修改即可全部移植到nginx下.靜態(tài)化配置見(jiàn)面上面的:#bbs rewrite部分.2.一般論壇都希望實(shí)現防盜鏈功能,在apache很輕松實(shí)現?在nginx下是否容易實(shí)現呢?答案是肯定的.復制內容到剪貼板代碼: #Preventing hot linking of images and other file types valid_referers none blocked server_names *.redocn.com redocn.com ...你允許連接的網(wǎng)址; if ($invalid_referer) { rewrite ^/ http://www.redocn.com/images/redocn.gif; //讓別人盜鏈時(shí)顯示你指定的圖片. #return 403; }3.blog.redocn.com [root@redocn vhosts]#vi blog_redocn_com.conf復制內容到剪貼板代碼:server { listen 80; server_name blog.redocn.com; index index.html index.htm index.php; root /data/www/wwwroot/blog; error_page 404 http://bbs.redocn.com; #supsite rewrite rewrite ^([0-9]+)/spacelist(.*)$ index.php?$1/action_spacelist$2; rewrite ^([0-9]+)/viewspace_(.+)$ index.php?$1/action_viewspace_itemid_$2; rewrite ^([0-9]+)/viewbbs_(.+)$ index.php?$1/action_viewbbs_tid_$2; rewrite ^([0-9]+)/(.*)$ index.php?$1/$2; rewrite ^([0-9]+)$ index.php?$1; rewrite ^action_(.+)$ index.php?action_$1; rewrite ^category_(.+)$ index.php?action_category_catid_$1; rewrite ^itemlist_(.+)$ index.php?action_itemlist_catid_$1; rewrite ^viewnews_(.+)$ index.php?action_viewnews_itemid_$1; rewrite ^viewthread_(.+)$ index.php?action_viewthread_tid_$1; rewrite ^index([\.a-zA-Z0-9]*)$ index.php; rewrite ^html/([0-9]+)/viewnews_itemid_([0-9]+)\.html$ index.php?action_viewnews_itemid_$2; rewrite ^/([0-9]+)/spacelist(.+)$ /index.php?uid/$1/action/spacelist/type$2; rewrite ^/([0-9]+)/viewspace(.+)$ /index.php?uid/$1/action/viewspace/itemid$2; rewrite ^/([0-9]+)/viewbbs(.+)$ /index.php?uid/$1/action/viewbbs/tid$2; rewrite ^/([0-9]+)/(.*)$ /index.php?uid/$1/$2; rewrite ^/([0-9]+)$ /index.php?uid/$1; rewrite ^/action(.+)$ /index.php?action$1; rewrite ^/category(.+)$ /index.php?action/category/catid$1; rewrite ^/viewnews(.+)$ /index.php?action/viewnews/itemid$1; rewrite ^/viewthread(.+)$ /index.php?action/viewthread/tid$1; rewrite ^/mygroup(.+)$ /index.php?action/mygroup/gid$1; location ~ .*\.php?$ { include conf/enable_php5.conf; } }注:blog采用功能強大的Supesite作為Blog站點(diǎn): http://www.supesite.com/1.Blog如何在Nginx里實(shí)現靜態(tài)化,具體設置見(jiàn),上面的#supesite rewrite4.down.redocn.com[root@redocn vhosts]# vi down_redocn_com.conf復制內容到剪貼板代碼:limit_zone one $binary_remote_addr 10m; server { listen 80; server_name down.redocn.com; index index.html index.htm index.php; root /data/www/wwwroot/down; error_page 404 /index.php; # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } #Zone limit location / { limit_conn one 1; limit_rate 20k; } # serve static files location ~ ^/(images|javascript|js|css|flash|media|static)/ { root /data/www/wwwroot/down; expires 30d; } }注:由于現在的BT下載軟件越來(lái)越多了,我們如何限制下載的并發(fā)數和速率呢?apache需要三方模塊,nginx就不用了在nginx利用兩個(gè)指令即可實(shí)現:limit_zone(limit_conn) 來(lái)限制并發(fā)數,limit_rate來(lái)限制下載的速率,請看上面的配置實(shí)例.5.啟動(dòng)nginx服務(wù)復制內容到剪貼板代碼:/usr/local/php-fcgi/bin/spawn-fcgi -a 127.0.0.1 -p 8085 -C 250 -u www -f/usr/local/php-fcgi/bin/php-cgi/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf你可以把上面兩條命令制做成系統啟動(dòng)服務(wù)腳本,相關(guān)的腳本在網(wǎng)上也很多,本文就不再貼出來(lái)了,給出一個(gè)實(shí)例鏈接:http://topfunky.net/svn/shovel/nginx/init.d/nginx五.問(wèn)題及經(jīng)驗總結:1.安裝Discuz論壇后,無(wú)法上傳大于M以上的附件?在主配置文件里加入:client_max_body_size 10m; 詳細指令說(shuō)明請參見(jiàn)(六)提供的Wiki鏈接.2.Discuz附件無(wú)法下載附件?最近遇到一個(gè)奇怪的問(wèn)題在nginx下discuz論壇無(wú)法下載附件,后來(lái)打開(kāi)error_log才知道,仍后一看/usr/local分區滿(mǎn)了,清了一大堆無(wú)用文件后,馬上就正常了.以上是本人遷移和測試過(guò)程中遇到的兩個(gè)小問(wèn)題,在此附上說(shuō)明,只是希望配置nginx的朋友不要犯我一樣的問(wèn)題.歡迎聯(lián)系NetSeek(狂熱linux愛(ài)好者^(guò)_^ msn:cnseek@msn.com QQ:67888954 Gtalk:cnseek@gmail.com).六.相關(guān)鏈接: 1.Discuz!.net高性能的PHP論壇程序 http://www.discuz.net Supesite: http://www.supesite.com/ 2.Nginx參考文檔:http://wiki.codemongers.com/ 3.利用Nginx實(shí)現負載均衡(阿葉大哥的文章):http://www.imysql.com/comment/reply/210 4.linuxPk[Linux寶庫]:http://bbs.linuxpk.com 5.紅動(dòng)中國 http://bbs.redocn.com
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
關(guān)于大型論壇系統環(huán)境搭建(20萬(wàn)日IP負載平衡實(shí)戰)–Nginx Apache2 PHP MySQL - Nginx
nginx應用總結(1)--基礎認識和應用配置
moodle 2.0.2 安裝圖文教程 2——PHP Mysql環(huán)境搭建和moodle安裝 - 喬木的日志 - ICT教育 - 中小學(xué)信息技術(shù)教育和教育信息化網(wǎng)站
Nginx0.5.33+PHP5.2.5(FastCGI)搭建勝過(guò)Apache10倍的Web服務(wù)器
nginx+PHP+PHP-FPM(FastCGI)在Ubuntu上的安裝和配置
Nginx PHP-FPM APC=絕妙的組合(1) - 51CTO.COM
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久