{"id":469,"date":"2010-11-23T21:14:37","date_gmt":"2010-11-23T19:14:37","guid":{"rendered":"http:\/\/www.shukko.com\/x3\/?p=469"},"modified":"2010-11-23T23:09:22","modified_gmt":"2010-11-23T21:09:22","slug":"debian-lenny-openvz-vps-nginx-mysql-munin-etc-etc","status":"publish","type":"post","link":"https:\/\/www.shukko.com\/x3\/2010\/11\/23\/debian-lenny-openvz-vps-nginx-mysql-munin-etc-etc\/","title":{"rendered":"Debian Lenny, Openvz VPS, Nginx, MySQL, Munin, etc. etc."},"content":{"rendered":"<p>1 sitemiz var, uzerinde calisan basit php mysql script ile randevu kaydi aliyoruz.<br \/>\nAma cogu zaman alamiyoruz cunku yogun oldugu zamanlarda anlik 1000 &#8211; 1200 request geliyor.<br \/>\napache dayanmiyor, mysql sapitiyor. sonucta site erisilmez oluyor. apacheyi, phpyi tweak etmek , mysqli tweak etmek sorunu cozmuyor. Sorunun cozumu kuvvetli bir vps ve dogru duzgun hafif ve hizli bir php,mysql altyapisi.<br \/>\nUbuntu 10.10 ustunde nginx ve php-fpm olabilir &#8212; Olamaz &#8212; cunku php kodumuz php 5.3 uyumlu degil. O zaman debian lenny? Default olarak php5.2 var? Olabilir ancak Php-FPM default repo larda yok? Derleriz. Bosver standart disina cikma. Ok.<br \/>\nSonuc: Debian lenny, nginx, php 5.2 (spawn-cgi(lighthttpd)) mysql. Monitor etmek icin nginx destekli Munin. Ok kuruluma basla&#8230;<\/p>\n<p>1-debian lenny vpsimizi hazir edelim, guncel edelim.<br \/>\n2-mysql kuralim<br \/>\naptitude install mysql-server mysql-client<br \/>\n3-nginx kuralim,calistiralim<br \/>\naptitude install nginx<br \/>\n\/etc\/init.d\/nginx start<br \/>\n4-php 5 kuralim<br \/>\n<code>aptitude install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl<\/p>\n<p>nano \/etc\/php5\/cgi\/php.ini<\/p>\n<p>en altina ekle<\/p>\n<p>cgi.fix_pathinfo = 1<br \/>\n<\/code><br \/>\nDebian Lenny icin FastCGI daemon paketi yok o yuzden lighttpd icindeki spawn-fcgi programini kullanicaz.<br \/>\n<code><br \/>\naptitude install lighttpd<\/p>\n<p>hata vericek port80 kullanimda diye onemli degil kapat gitsin<\/p>\n<p>update-rc.d -f lighttpd remove<\/p>\n<p>Php FasCGI daemonu calistiralim<\/p>\n<p>\/usr\/bin\/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f \/usr\/bin\/php5-cgi -P \/var\/run\/fastcgi-php.pid<\/p>\n<p>bunu \/etc\/rc.local icine ekleyelim ayni sekilde ki reboot ettigimizdede calissin<\/p>\n<p>nano \/etc\/rc.local ve ekle yukaridaki satiri<br \/>\n<\/code><br \/>\nphp isimiz bitti<\/p>\n<p>5- nginx i konfigure edelim<\/p>\n<p>nano \/etc\/nginx\/nginx.conf<\/p>\n<p>onemli 3 ayarimiz var<br \/>\n<code><br \/>\nworker_processes  5;<br \/>\nworker_connections  4096;<br \/>\nkeepalive_timeout   2;<br \/>\n<\/code><\/p>\n<p>defaut nginx sitemizi konfigure edelim<br \/>\n<code><br \/>\nserver {<br \/>\n        listen   80;<br \/>\n        server_name  _;<\/p>\n<p>        access_log  \/var\/log\/nginx\/localhost.access.log;<\/p>\n<p>        location \/ {<br \/>\n                root   \/var\/www\/nginx-default;<br \/>\n                index  index.php index.html index.htm;<br \/>\n        }<\/p>\n<p>        #error_page  404  \/404.html;<\/p>\n<p>        # redirect server error pages to the static page \/50x.html<br \/>\n        #<br \/>\n        error_page   500 502 503 504  \/50x.html;<br \/>\n        location = \/50x.html {<br \/>\n                root   \/var\/www\/nginx-default;<br \/>\n        }<\/p>\n<p>        # proxy the PHP scripts to Apache listening on 127.0.0.1:80<br \/>\n        #<br \/>\n        #location ~ \\.php$ {<br \/>\n                #proxy_pass   http:\/\/127.0.0.1;<br \/>\n        #}<\/p>\n<p>        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br \/>\n        #<br \/>\n        location ~ \\.php$ {<br \/>\n                fastcgi_pass   127.0.0.1:9000;<br \/>\n                fastcgi_index  index.php;<br \/>\n                fastcgi_param  SCRIPT_FILENAME  \/var\/www\/nginx-default$fastcgi_script_name;<br \/>\n                include        fastcgi_params;<br \/>\n        }<\/p>\n<p>        # deny access to .htaccess files, if Apache's document root<br \/>\n        # concurs with nginx's one<br \/>\n        #<br \/>\n        location ~ \/\\.ht {<br \/>\n                deny  all;<br \/>\n        }<br \/>\n        location \/nginx_status {<br \/>\n                stub_status on;<br \/>\n                access_log   off;<br \/>\n                allow x.x.x.x;<br \/>\n                allow 127.0.0.1;<br \/>\n                allow x.x.x.x;<br \/>\n                deny all;<br \/>\n        }<br \/>\n}<br \/>\n<\/code><br \/>\nNOT: burada munin ile daha sonra monitor edecegimizden nginixi uygun status kayitlarinida simdiden ekledik. Hazir olsun.<br \/>\nNginx ayari bitti yeniden baslatim bir tanede info.php atip durumuna bakalim.<br \/>\n<code><br \/>\nnano \/var\/www\/nginx-default\/info.php ve ekle<br \/>\n<?php\nphpinfo();\n?><\/p>\n<p>sonra<\/p>\n<p>\/etc\/init.d\/nginx restart<\/code><\/p>\n<p>son olarak duruma bakalim , hersey hazir<br \/>\nhttp:\/\/ip.ad.re.si\/info.php<br \/>\nhttp:\/\/ip.ad.re.si\/nginx_status<\/p>\n<p>6- phpmyadmin kuralim lazim olur<br \/>\napt-get install phpmyadmin<\/p>\n<p>repodan gelen phpmyadmin sorunsuz sekilde calissin nginximizde<br \/>\n cd \/var\/www\/nginx-default\/<br \/>\nln -s \/usr\/share\/phpmyadmin phpmyadmin<\/p>\n<p>7- MySQL imizi azicik tweak edelim<br \/>\nasagidaki my.cnf gayet guzel is goruyor.<br \/>\n<code><br \/>\n# The MySQL server<br \/>\n[mysqld]<br \/>\nwait_timeout=60<br \/>\nconnect_timeout=10<br \/>\ninteractive_timeout=120<\/p>\n<p>port            = 3306<br \/>\nsocket          = \/var\/run\/mysqld\/mysqld.sock<br \/>\nskip-locking<br \/>\nkey_buffer = 384M<br \/>\nkey_buffer_size=64M<br \/>\nmax_allowed_packet = 1M<br \/>\ntable_cache = 1024<br \/>\nsort_buffer_size = 8M<br \/>\nread_buffer_size = 8M<br \/>\nread_rnd_buffer_size = 8M<br \/>\nmyisam_sort_buffer_size = 64M<br \/>\nthread_cache_size = 8<br \/>\nquery_cache_size = 128M<br \/>\nquery_cache_limit = 2M<br \/>\n# Try number of CPU's*2 for thread_concurrency<br \/>\nthread_concurrency = 8<br \/>\n<\/code><\/p>\n<p>8- munin kuralim<br \/>\n<code><br \/>\napt-get install munin munin-node<br \/>\n\/etc\/init.d\/munin-node restart<br \/>\ncd \/var\/www\/nginx-default\/<br \/>\nln -s \/var\/www\/munin monitoring<br \/>\n<\/code><br \/>\nhttp:\/\/ip.ad.re.si\/monitoring<br \/>\naltinda munin hazir calisiyor. 15 20 dakka beklemek gerek dogru duzgun grafikler icin sadece \ud83d\ude42<\/p>\n<p>9- munin nginx monitoring ayarlarini yapalim<br \/>\nhttps:\/\/github.com\/perusio\/nginx-munin adresine gidilir download diyip munin nginx plugin paketi indirilir. kurulumun istedigi nginx status isini halletmistik o zaman:<br \/>\npaketin icindekileri \/etc\/munin\/plugins altina atalim<br \/>\nsonra<br \/>\n<code><br \/>\nnano \/etc\/munin\/plugin-conf.d\/munin-node<\/p>\n<p>icine an alta yaz<\/p>\n<p>[nginx_status]<br \/>\nenv.url=http:\/\/ip.ad.re.si\/nginx_status nginx_status<\/p>\n<p>[nginx_connection_request]<br \/>\nenv.url=http:\/\/ip.ad.re.si\/nginx_status nginx_status<\/p>\n<p>[nginx_request]<br \/>\nenv.url=http:\/\/ip.ad.re.si\/nginx_status nginx_status<\/p>\n<p>kaydet cik<\/p>\n<p>\/etc\/init.d\/munin-node restart<br \/>\n<\/code><br \/>\ndiyip bastan calistir munini oldu bitti<br \/>\nhttp:\/\/ip.ad.re.si\/monitoring altinda nginx lerimizde geldi.<\/p>\n<p>Gule gule kullanalim olsun da bitsin masallah.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1 sitemiz var, uzerinde calisan basit php mysql script ile randevu kaydi aliyoruz. Ama cogu zaman alamiyoruz cunku yogun oldugu zamanlarda anlik 1000 &#8211; 1200 request geliyor. apache dayanmiyor, mysql sapitiyor. sonucta site erisilmez oluyor. apacheyi, phpyi tweak etmek , mysqli tweak etmek sorunu cozmuyor. Sorunun cozumu kuvvetli bir vps ve dogru duzgun hafif ve [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-469","post","type-post","status-publish","format-standard","hentry","category-kategerisiz"],"_links":{"self":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/comments?post=469"}],"version-history":[{"count":4,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/469\/revisions"}],"predecessor-version":[{"id":471,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/469\/revisions\/471"}],"wp:attachment":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/media?parent=469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/categories?post=469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/tags?post=469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}