Ungayifaka kanjani i-web server nge-Nginx + MySQL + PHP5 + APC + Spawn_FastCGI [Isigaba sokuqala: Isethulo]

Esikhathini esingengakanani esedlule sishilo ukuthi manje iDesdeLinux (yonke imisebenzi yayo) iyangena Amaseva weGNUTransfer.com. Ibhulogi ithuthuke kakhulu maqondana nejubane, uketshezi, noma ngabe sisuka ekubeni (ngemuva kokuhlangana kwe-UsemosLinux) ukuvakashelwa okungaphezu kwama-30.000 nsuku zonke (cishe abasebenzisi abangama-200 baxhuma ngasikhathi sinye). Ungakufeza kanjani ukusebenza okuhle kweseva noma ngabe le volumu yethrafikhi?

Njengamanje iJustice (i-VPS lapho kubhalwe khona ibhulogi nenye insizakalo) ine-3GB ye-RAM, noma kunjalo kudliwe okungaphansi kuka-500MB, lokhu kungenzeka ngokukhetha okulungile kwesoftware ongayisebenzisa nokuyilungiselela okufanele. Isibonelo, i-Apache ngokungangabazeki inkulu emhlabeni, i-No.1 uma kukhulunywa ngokusingathwa, kepha ngenxa yalesi sizathu i-Apache akuyona inketho enhle ngaso sonke isikhathi. Lapho isiminyaminya siphezulu futhi nehardware ye-server ayinkulu kangako (Ex: 8 noma i-16GB ye-RAM) I-Apache ingahle idle i-RAM eningi kakhulu okwenza iseva ngezikhathi ezithile ithathe isikhathi eside ukuphendula, noma okubi kakhulu, ukuthi isiza sethu asixhunyiwe ku-inthanethi izinsiza ezinganele. Kungakho iningi lethu likhetha i-Nginx kune-Apache.

Nginx:

Sivele sikutshele ngeNginx ekuqaleni kwendatshana Nginx: Enye indlela ethokozisayo ye-Apache, lapho sikutshela ukuthi yiseva yewebhu efana ne-Apache, LightHttpd noma iCherokee, kepha lokho kuqhathaniswa ne-Apache kugqame ukusebenza kwayo nokusetshenziswa kwehadiwe ephansi, ngenxa yalesi sizathu amasayithi amaningi amakhulu afana neFacebook, MyOpera.com, iDropBox noma neWordPress .com sebenzisa i-Nginx esikhundleni se-Apache. Emhlabeni weLinux KusukelaLinux akuyona kuphela esebenzisa i-Nginx, ngokwazi kwami, i-emsLinux neMuyLinux bayayisebenzisa 🙂

Okuhlangenwe nakho kwami ​​ngeNginx kubuyela emuva eminyakeni eminingana, lapho ngaphandle kwesidingo ngaqala ukufuna ezinye izindlela ezingasindi ku-Apache. Ngaleso sikhathi i-Nginx yayifuna inguqulo engu-0.6 futhi ukuhambisana kwayo nezindawo ezifunwa kakhulu ezenziwe ku-PHP kwakungeyona okulungile kakhulu, kepha namuhla kusuka enguqulweni engu-0.9 kuye phambili (v1.2.1 itholakala ku-Debian Stable, v1.4.2 itholakala ku-ArchLinux) kuthuthuke kakhulu, kuze kufike ezingeni lokuthi ngokucushwa okufanele kanye nenyunyana yeNginx + PHP konke kuzosebenza njengentelezi.

Kulolu chungechunge lwezifundo Ngizosebenzisa inguqulo ye-Nginx 1.2.1-2.2, iyatholakala ezindaweni zokuhlala ze-Debian Stable (Wheezy).

I-PHP5:

I-PHP, lolo limi lohlelo amasayithi amaningi (kanye ne-CMS) asebenza nalo namuhla, ngokubona kwami, izimvu ezimnyama zomndeni. Okungukuthi, kokuhlangenwe nakho kwami ​​siqu, amasayithi amakhulu, anevolumu enkulu yokuvakashelwa, enezinketho eziningi, imisebenzi, njll., Uma isiza esinjalo senziwa ku-PHP sizosebenzisa izinsiza eziningi kunesiza esifanayo esenziwe, isibonelo, eRoR. Okuhlangenwe nakho kwami ​​kube ukuthi bantu, i-PHP yidrako enkulu yemithombo, i-PHP + i-Apache yanele ukugwinya amakhulu namakhulu ama-MB we-RAM ngaphandle kwesidingo sangempela.

Isizathu sokungasebenzisi i-RoR, i-Django noma omunye umuntu ukuthi nje i-DesdeLinux (ibhulogi, i-flagship yethu) isebenza ne-WordPress, i-CMS eyenziwe nge-PHP esisinikeza ukunethezeka okuningi, kangangokuthi asicabangi ukuyiguqula kufushane noma phakathi term, ngobuqotho, i-WordPress noma ingaphelele isisebenzisela lokho esikudingayo futhi mhlawumbe nokuningi.

Ngokuphathelene ne-PHP, kulezi zifundo ngizosebenzisa i- Uhlobo lwe-PHP 5.4.4-14 iyatholakala ku-Debian Wheezy (Esitebeleni)

Spawn_FastCGI:

Lokhu kungashiwo ukuthi yilokho okuhlanganisa i-Nginx ne-PHP, okungukuthi, noma ngabe banephakheji ye-PHP5 efakiwe uma bengenayo i-Spawn_FastCGI efakiwe futhi yenziwa lapho bevula isiza ku-PHP isiphequluli sizolanda ifayela, ngeke libakhombise noma yini ukuthi .php ihlelwe ngoba i-server ayazi ukuthi icubungula kanjani amafayela we-.php, yingakho kubalulekile ukufaka nokulungisa i-Spawn_FastCGI.

Uma sisebenzise i-Apache kungaba yinto elula njengokufaka iphakheji ye-libapache2-mod-php5 kepha njengoba sisebenzisa i-Nginx kuzofanele sifake iphakheji ye-spawn-fcgi. Futhi, esifundweni ngizochaza ukuthi ngingawakha kanjani umbhalo wokuqala kuwo ku /etc/init.d/ ukuze ukwazi ukuwulawula kahle.

I-MySQL:

Lokhu kungaba uphawu lombuzo olukhulu noma mhlawumbe, kwabanye, inothi elivumelanayo. Abaningi engibaziyo bazongibuza lo mbuzo: kungani usebenzisa iMySQL hhayi iMariaDB?

Into ukuthi anginaso isikhathi esanele sokuzinikela ekwenzeni ukufuduka ngalesi sikhathi kusuka ku-MySQL kuya eMariaDB, ukufuduka okufanele ukuthi kube sobala kuwo wonke umuntu, i-100% ihambisane nakho konke, kepha lokho ... njengoba ngishilo, ngombono. Ngesikhathi lapho ngiqala ukuhambisa izinsizakalo ze-FromLinux ngisuka kwenye i-VPS ngiye kwenye kwakumele ngishiye i-Apache ngisebenzise i-Nginx, lokhu kusho amafayela wokumisa ahlukile, izindlela ezahlukahlukene zokumemezela i-VHosts, ukufakwa nokucushwa kusuka ekuqaleni kweseva nezinsizakalo zayo, Ngangingeke ngikwazi ukufaka omunye umsebenzi ngaleso sikhathi, futhi ngokuthembeka, ngashintsha i-Apache ye-Nginx ngoba i-Apache yayingazanelisi izidingo zami, noma kunjalo, i-MySQL kuze kube manje yanelisa izidingo zami ngo-100%, angiziboni izizathu ngalowo mzuzu ngangeza umthwalo wami wokushintsha ngokushintsha into ebivele ingisebenzele kahle ngokomsebenzi.

Lapho sengichazile ukuthi kungani ngingafakanga iMariaDB, ngichaze nokuthi njengoba iningi lamawebhusayithi lidinga i-database yokusebenza kwawo, ngoba kulapho kuzogcinwa khona imininingwane eminingi (noma cishe konke). Kunabanye abathanda uPostgre noma omunye umuntu, kulolu chungechunge lwezifundo ngizochaza ukuthi kanjani faka i-MySQL futhi ulungiselele abasebenzisi abahlukene besiza ngasinye.

La Uhlobo lwe-MySQL engizolusebenzisa i-v5.5.31

I-APC:

I-APC isilungiselela i-PHP (ichazwe kalula). Kusivumela ukuthi silungiselele kahle ukuthi ukucubungula kwe-PHP kusebenza kangcono, ukuthi izimpendulo ezivela kuseva ziyashesha.

Kunezinye izindlela ezinjenge-memcache noma kunjalo, bengilokhu ngisebenzisa i-APC futhi ngibe nemiphumela emihle kakhulu. Ngincoma ukufunda le ndatshana ngesiNgisi: Ukuqhathanisa i-APC neMemcache njenge-cache yendawo yokuqukethwe

Ngizosebenzisa esifundweni inguqulo ye- php-apc v3.1.13-1 iyatholakala nasezikhundleni ze-Debian Stable.

Ukufingqa:

Le ndlela yokufaka ukumiswa kwesiphakeli sewebhu ayiyona engcono kunazo zonke, kude nayo, ngokwesibonelo abaningi bazoncoma i-Varnish, okuvela kulokho engikufundile kusebenza izimangaliso zangempela ngoba yonke into noma cishe konke kugcinwe kunqolobane, kepha, kithi asikudingi lokho I-100% yesayithi ihlala ifakwa kunqolobane njengoba singafuni noma sidinga ukuya kulokho kweqisa. Kodwa-ke, ngiyacacisa, njengoba ngishilo ngenhla: "kuze kufike lapho ngifunde khona", mina uqobo angizange ngisebenzise iVarnish kuze kube namuhla, ngakho-ke angikwazi ukukunikeza umbono we-100% wenhloso.

Lokhu kuzoba uchungechunge lwezifundo lapho ngizokukhombisa khona ukuthi ungayifaka kanjani isiphakeli sewebhu njengalesi esisingathwa i-FromLinux njengamanje (ibhulogi, iforamu, unamathisela, njll). I-blog ivakashelwa ama-30.000 nsuku zonke, cishe abasebenzisi be-200 bayifinyelela ngasikhathi sinye, futhi ngakho-ke i-RAM ayidluli i-500MB esetshenzisiwe, lokhu kwabanye kungaba ukusetshenziswa ngokweqile kepha ... hheyi, sine-3GB ye-RAM, engaphansi kuka-500MB (okubandakanya i-FTP, i-SSH, njll) kulungile impela? 🙂

Wonke 'umlingo' awenziwa kuphela yi-Nginx + Spawn_FastCGI + APC, uhlelo lwethu lwe-blog cache luhlelwe kahle futhi nemithetho ye-Nginx iqondile, lokhu kwenza ibhulogi noma ngabe ithola inqubo enkulu yethrafikhi ingaphansi kakhulu kwe-PHP kunalokho njengokujwayelekile, njengoba sekuvele kunesilondolozi esiningi. Uma unesayithi elifunwa kakhulu futhi unezinkinga zezinsizakusebenza, ngincoma ngaphandle kokungabaza ukuthi ufundela ukubona ukuthi yiluphi uhlelo lwe-cache oluzokusebenzela kangcono, yikuphi okuzohlangabezana nezidingo zakho.

Ngiyethemba ukuthi uzothola lezi zifundiso zithakazelisa, kuzo zonke zazo ngizozama ukuchaza konke ngendlela ephelele, enemininingwane futhi elula ngangokunokwenzeka.

Phendula ngokucaphuna


Okuqukethwe yi-athikili kunamathela ezimisweni zethu ze izimiso zokuhlelela. Ukubika iphutha chofoza lapha.

Amazwana ayi-27, shiya okwakho

Shiya umbono wakho

Ikheli lakho le ngeke ishicilelwe. Ezidingekayo ibhalwe nge *

*

*

  1. Ubhekele imininingwane: Miguel Ángel Gatón
  2. Inhloso yedatha: Lawula Ugaxekile, ukuphathwa kwamazwana.
  3. Ukusemthethweni: Imvume yakho
  4. Ukuxhumana kwemininingwane: Imininingwane ngeke idluliselwe kubantu besithathu ngaphandle kwesibopho esisemthethweni.
  5. Isitoreji sedatha: Idatabase ebanjwe yi-Occentus Networks (EU)
  6. Amalungelo: Nganoma yisiphi isikhathi ungakhawulela, uthole futhi ususe imininingwane yakho.

  1.   UBruno cascio kusho

    Kuhle kakhulu futhi kucacile! Ngiyakuhalalisela!

    1.    KZKG ^ Gaara kusho

      Siyabonga 🙂

  2.   UChristopher Castro kusho

    Isifundo esihle kakhulu.

    Okungigcwalisa ngokungabaza ukuthi bayilungiselele kanjani iseva ye-imeyili.

    1.    KZKG ^ Gaara kusho

      IMailServer yinto ehlukanisiwe, okungukuthi, ayihlangene neseva yewebhu njengoba wazi 🙂

      Kodwa-ke, kudala nginqume ukungazenzi inkinga ngeMailServer, ngakhetha ukusebenzisa iRedMail (ukwesekwa kwe-MySQL, i-LDAP ne-Postgre) nangamasethingi afanele nemininingwane engiyifaka kumafayili wokumisa, konke kusebenza kahle.

  3.   Rots87 kusho

    Ngiyayithanda le ndatshana, ngilinde uchungechunge lwezihloko

    1.    KZKG ^ Gaara kusho

      Ngiyabonga, ngiyethemba ukuletha elandelayo ngoMsombuluko noma ngoLwesibili, izobhekana nokufakwa nokulungiswa kwe-Nginx.

  4.   i-aca kusho

    Kuhle kakhulu, ukumiswa okulungile, kunzima ukukuthola, ukuyekethisa phakathi kwezici kwesinye isikhathi kucishe kungaxazululeki, ngiphinde ngaya ku-nginx esikhathini esedlule futhi kamuva nase-mariadb (muva nje, ngicabanga ukuthi ngonyaka odlule).

    // Njengoba ngishilo, kungakuhle uma uphakamise ukuthi kungenzeka ube yiproo, bese usebenzisa i- proxy_cache_path nayo ewusizo. Futhi ukuqhathaniswa kwesokhethi (ezimweni ezingenzeka) ngokumelene netheku. futhi uchaze kahle inani lezingane / inqama.

    Phendula ngokucaphuna

    1.    KZKG ^ Gaara kusho

      Ngiyabonga ngokuphawula kwakho 🙂
      Yebo kunjalo, kungaba kuhle kakhulu ukuvalela i-Nginx ukuyigcina ihlukile kunalolo lonke uhlelo, bengingakubonanga lokho okungenzeka kulezi zifundo, ngizobona ukuthi yini engingayenza. Mayelana nommeleli_cache_path, angikaze ngiyisebenzise, ​​ngizofunda kancane ngayo ukubona ukuthi kuhamba kanjani.

      Mayelana nenani lezintambo (min & max), ekucushweni kwe-Nginx kuchaziwe ngokusobala, eposini le-Nginx ngizokhuluma kakhulu ngefayela le-.conf 😉

      Futhi, ngiyabonga ngokuphawula kwakho.

  5.   msx kusho

    Lolu hlobo lweHowTos yilona olwenza iwebhu ibe namandla ngempela kososayensi bamakhompiyutha njengoba isisindisa amathani amaningi wokucwaninga nokuhlola size sigcine sithathe isinqumo ngenketho efanele, sibonga kakhulu!

    Umbuzo owodwa, ngabe lokhu kusebenza ku-Debian? Yiluphi uhlobo lwe-OS namaphakeji?

    Ukubingelela!

    1.    KZKG ^ Gaara kusho

      Ngiyabonga
      Ngempela, amasayithi abika, aphindayo futhi aphindaphinde izindaba sekuvele kuningi kakhulu ... okudingekayo amasayithi abeka okokufundisa, yilokho okudingwa iwebhu!

      Yebo, iDebian Wheezy (Esitebeleni samanje), izinhlobo zamaphakeji zilapho lapho okuthunyelwe 😉

  6.   eliotime3000 kusho

    Ukuphawula okuhle kakhulu. Ake sibheke ukuthi ngenza uhlobo lwe-Errata nge-ZPanel X, futhi ngenhlanhla, ngenza ukufakwa ngesandla ku-Debian Wheezy.

  7.   UFederico Antonio Valdés Toujague kusho

    Qhubeka KZKG ^ Gaara !!!, ukuthi The Best Criterion of Truth is Practice, futhi unolwazi ngalokho okubhalayo. Iwebhusayithi efanelekile futhi esebenzayo. IMajor League Baseball, Dude.

    1.    eliotime3000 kusho

      Yiqiniso. Futhi, lapho ngiqala ukudlala ngamaseva wewebhu engiwafakile kuWindows, iqiniso ukuthi i-Apache iyadubula ngokusetshenziswa kwezinsizakusebenza uma usebenzisa i-WordPress (eDrupal idle uhhafu wemithombo).

  8.   inqola kusho

    Ngicabanga ukuthi engxenyeni ye-Nginx lesi sifundo sizosiza kakhulu. Manje ngifuna ukufaka iseva nge-Nginx, php, Varnish neMariaDB. Kepha-ke, kufanele uqale, futhi ubuvila bungenza lukhulu uma kukhulunywa ngokulwa namaseva futhi manje ngijabule ngesibani esijwayelekile nememori enginayo i-xDD.

    A ukubingelela.

  9.   AurosZx kusho

    Kuhle, okukodwa kwalokhu kuzofika kahle 🙂 Omunye abheke phambili kukho.

  10.   U-Ivan Gabriel Sosa kusho

    Siyakulandela. Njengamanje siqala emhlabeni wamaseva wewebhu. Sathenga ezimbili kwa-Hostinger, futhi umngani usisizile ukumisa kusuka ekuqaleni (i-PHP, i-MySQL, i-Apache). Ukuphela kwenhlanganisela esetshenziswa kwiLinux, ipulatifomu ebengikade ngikhona kusukela ngoJanuwari.
    Kepha benginentshisekelo enkulu kulesi sihloko. Halala!

  11.   UJose Manuel kusho

    Angikaze ngiyifake i-web server kepha uma ngifuna ukuyenza, umbuzo, ingabe ileveli edingekayo ukuze kuqondwe okokufundisa futhi ukufakwa kube phezulu noma ngolwazi oluyisisekelo ngingayizama? Ngiyabonga kusengaphambili.

    1.    eliotime3000 kusho

      Iqiniso ukuthi akudingi ulwazi oluningi ukuze ukwazi ukuphatha iseva yedatha. Lowo osekuzamile lokho okuhlangenwe nakho uyakutshela.

  12.   Mauricio kusho

    Sawubona, kuhle kakhulu ozokwenza ngalolu chungechunge lwezikhala.

    Ngisanda kufaka i-Nginx + Php Fastcgi + Mariadb. Nginx.

    Konke lokhu, ngikwenze e-Archlinux, ngoba lokho kusatshalaliswa kungukuphela kombono wami, okungalethi okuhle okufana nokunye. Ngikubeka endaweni evalelwe ekhejini futhi kwanginika ukuphazamiseka okukhulu ukuze isebenze kahle.

    Manje isebenza ngokuphelele. Yize nginentshisekelo yokwazi imibono yakho, mayelana nezinqubo zezingane nobaba, amathiphu owengeziwe onginika wona, aba ngcono.

    Konke lokhu kwenzelwa ukuzijwayeza nje.
    Imishini ine-4GB yenqama ye-DDR2 kanye neprosesa ye-2Ghz Core 2.4duo.

    Sanibonani futhi ngibheke phambili okuthunyelwe okuzayo kwalolu chungechunge.

  13.   imisipha kusho

    Abasebenzisi abangama-200 baxhumeke ngasikhathi sinye?
    Ngezikhathi ezithile zosuku kuphela, akunjalo? Ngoba kungenjalo bekuzodlula lokho kuhambela kwansuku zonke okungama-30.000.

    1.    KZKG ^ Gaara kusho

      Yebo, kunjalo, abahlale bekhona abantu abangama-200 online, okwamanje baningi abacishe babe ngama-40 ngoba kusesekuseni, emahoreni ambalwa bazodlula i-100.

  14.   isihlibhi kusho

    Okokuzijabulisa nje ngivele ngashintsha ukusuka kukhanya ngaya ku-nginx esiteshini sami sokusebenzela (iSymfony2 khona manje), ngithathe i-conf lapha [1], elula kakhulu.

    [1] http://ihaveabackup.net/2012/11/17/nginx-configuration-for-symfony2

  15.   Ama-Apr4xas kusho

    Ilinde ukuqhubeka kwalokhu 😀

    1.    KZKG ^ Gaara kusho

      Kuleli sonto kumele ngilishicilele, ngiyabonga ngokusifunda 🙂

      1.    impilo kusho

        Y? kuningi okushodayo?

  16.   Dean kusho

    Okuthunyelwe okuhle…

  17.   UNOEL IVAN kusho

    SAWUBONA.
    NGENXA YOKUCACISWA KWEPHROJEKTHI YESIKOLO, BANGIVUMELE FAKA INGINX KU-OPENBSD 5.4 E-ORACLE MV VIRTUALBOX UKUZE UKUSEBENZISA I-PHP, I-MySQL, PHAKATHI KWABANYE, INADAMAS ENGINGAKWAZI UKUTHOLA IMINININGWANE MAYELANA NALOKHO OKUPHAKATHI, INGABE YINKINGA Kimi Phezulu.