Gara akawanda maVHost ane akasiyana vashandisi muNinx

Chinhu chakajairika kwazvo pasirese kana iwe uine server, kufunga nezvekuchengetedzeka uye nekuchengetedzeka, haugone kuve paranoid zvakakwana

Imwe tsika yakajairika uye PASINA chinhu chakakurudzirwa, kushandisa iyo imwechete mushandisi kune ese dhatabhesi, zvakanyanya kana mudzi uchinge washandiswa, izvo zvinoshamisira sezvingaite kunge pane, kune avo (nekuda kwekugara kana kusaziva) ita izvi, ini ndanga ndataura kare nezvekuti sei usingafanirwe kuita seizvi mu imwe chinyorwaIno yave nguva yekutsanangura kuti sei uye nei zviri nani kupatsanura webhu server kugadzirisa mune akasiyana vashandisi, ino nguva ichave iri kushandisa Nginx.

DedicatedServer_SubImage

Chii icho chevashandisi uye webhu server?

Kuti uitsanangure nenzira ipfupi uye yakapusa, iyo dura rewebhu (apache, nginx, chero chii) inoda kuvhura maitiro muhurongwa, maitiro anozove iwo anotora mafaera kubva kuHDD (mifananidzo, nezvimwewo) oita kuti iwanikwe kune browser remutengi . Iyo dura rewebhu haigone kungotora mafaera nekuaomesa kusava munhu, ndiko kuti, inoda mushandisi anova iye achaita zvese izvi pakupedzisira, uye iye mushandisi ndiye wandiri kutaura nezvake, unonzwisisa here?

Chii icho chekuparadzanisa mune vashandisi vanoverengeka?

Ngatifungei kuti pane server yedu isu tine mawebhusaiti maviri, edu inova chirongwa chega, uye imwe (ngatimbofungidzirai kuti ndeyedu musikana kana hama). Kunyangwe isu patinoshandisa akapatsanurwa dhatabhesi uye vashandisi vakasiyana kuti vawane iwo, pakupedzisira mafaira eese mawebhusaiti anoshandiswa nemushandisi mumwe chete, iyo PHP yekugadzirisa inotarisirwa nemushandisi mumwechete kune ese masosi (kazhinji www-data). Iyi tsika isingakurudzirwe, zvirinani kuve nezvose zvakanyatsopatsanurwa, sekutaura kwekare, zviri nani kuve wakachengeteka pane urombo.

Ok ndinonzwisisa, ndinozviita sei neNinx

2000px-Nginx_logo.svg

Chinhu chekutanga kucherechedza ndechekuti Nginx haina module yayo inobata PHP kugadzirisa sezvinoita Apache, yeNginx tinoda kushandisa PHP-CGI kana PHP-FPM, inoshanda chete (kana zvirinani) kupfuura Apache. Saka kupatsanura PHP kugadzirisa kune akasiyana vashandisi, isu tichafanirwa kuchinja mitsara muPHP yekumisikidza mafaira (CGI kana FPM), kwete Nginx pachayo.

Ngatiti iwe unoshandisa PHP-FPM, isu tichagadzira yekumisikidza faira ye dziva Kune chaiyo saiti, ndiko kuti, dziva ndiyo nzira yekuparadzanisa PHP kugadzirisa kubva kuPHP-FPM, asi isu tinoenda muzvikamu.

Chekutanga isu tinofanirwa kuziva kuti ndeupi mushandisi wesystem yatichashandisa, ndichafungidzira kuti isu hatisati tave neyakagadzirwa uye mushe, ngatigadzirei.

Yese mirairo inotevera INOFANIRA kuitiswa nerubatsiro rwekutonga, kungave nemidzi yakananga kana kushandisa Sudo

adduser blog

Tichatanga zvakajairika maitiro ekugadzira mushandisi, kuisa password, nezvimwe.

Ini ndinonyora mushandisi kungotevedzera iwo muenzaniso, kuti saiti yekutanga yatino gashira ichave blog, zvakanaka izvo ... kuziva mumwe nemumwe mushandisi ane saiti inoenderana

1. Kutanga ngatiendei ku /etc/php5/fpm/pool.d/:

cd /etc/php5/fpm/pool.d/

2. Zvino, isu tichagadzira iyo faira inonzi blog.conf:

touch blog.conf

3. Iye zvino isu tichaisa kumisikidza kwedziva iro ratichazoshandisa iyo VHost blog:

Rongedza iyo blog.conf faira ine nano ... semuenzaniso: sudo nano blog.conf
[Blog] mushandisi = Blog
boka = Blog
teerera = / var / run / php5-fpm-Blogteerera teerera.muridzi = Blog
teerera.boka = Blog
pm = ondemand pm.max_children = 96 chdir = /

Cherechedza: Zvandinozvimaka mutsvuku ndizvo zvavanofanira kugadzirisa zvichienderana nemushandisi wavakagadzira kare. Semuenzaniso, kana ivo vakagadzira imwe VHost nemumwe mushandisi (foramu semuenzaniso) ipapo pachinzvimbo cheblog bva kuisa forum mune yega yega mitsara, haina kunzwisiswa?

4. Kamwe kumisikidzwa kwedziva nyowani (iyo blog.conf faira iyo yatichangogadzira nekugadzirisa), inguva yekuudza Nginx VHost kuti ishandise sokisi rakasiyana reiyo VHost, yeiyi saiti. Iyo sock iyo ichashandiswa ichave iyo yatakambozivisa (/var/run/php5-fpm-blog.sock) Ngatigadzirisei Nginx VHost uye mune iyo PHP yekugadzirisa chikamu, isu tinoratidza kushandisa iwo masokisi. Semuyenzaniso:

nzvimbo ~ \ .php $ {kana (! -f $ chikumbiro_filename) {dzoka 404; }
fastcgi_pass unix: / var / run / php5-fpm-Blog.kutarisa;
inosanganisira fastcgi_params; fastcgi_param SCRIPT_FILENAME $ gwaro_root $ fastcgi_script_name; fastcgi_read_timeout 300; }

Sezvauri kuona, ini ndinoratidza kuti iyo PHP kugadzirisa kweiyo VHost (iyo mitsara ndeye semuenzaniso mukati / etc / nginx / saiti-inogoneswa / vhost-blogzviite nemasokisi anowanikwa mu /var/run/php5-fpm-blog.sock ... inova ndiyo yatakasika kare patakagadzirisa /etc/php5/fpm/pool.d/blog.conf ... zvinonzwisiswa kwete ?

5. Kana izvi zvangoitwa, isu tinotangazve ese ari maviri masevhisi (php5-fpm uye nginx) uye voila, tichaona kuti kugadziriswa kweiyo saiti (vhost) HAKUITWE ne www-data kana mudzi kana chero munhu akafanana, asi nemushandisi watakatsanangura kare .

Pano ini ndinokuratidza kuburitsa kwe ps aux | grep fpm pane rimwe remaseva angu enode:

ps aux | grep fpm ebook 586 0.0 0.0 349360 1204? S Mar30 0:00 php-fpm: dziva ebook ebook 589 0.0 0.0 349360 1204? S Mar30 0:00 php-fpm: dziva ebook www 608 0.0 0.2 350084 5008? S Mar30 0:00 php-fpm: dziva www www 609 0.0 0.2 350600 5048 30? S Mar0 00:3 php-fpm: dziva www tv611 0.0 0.0 349360 1204 30? S Mar0 00:3 php-fpm: dziva tv3 tv615 0.0 0.0 349360 1204 30? S Mar0 00:3 php-fpm: dziva tv1818 magazini 1.7 1.7 437576 36396 09? S 55:0 46:2264 php-fpm: dziva magazini yemagazini 1.9 1.7 437332 35884 10? S 15:0 26:2338 php-fpm: dziva remagazini mudzidzi 4.3 1.0 428992 22196 10? S 18:0 53:2413 php-fpm: dziva mudzidzi mudzidzi 1.8 1.7 437764 36152 10? S 22:0 18:2754 php-fpm: dziva gutl magazini 3.5 1.3 356724 27164 10? S 38:0 00:5624 php-fpm: dziva gutl cgr 0.0 1.0 365168 22696 28? S Apr0 16:7900 php-fpm: dziva cgr mudzidzi 0.3 2.5 457052 52444 25? S Apr20 23:11021 php-fpm: dziva mudzidzi mudzidzi 0.4 2.5 458316 52864 28? S Apr5 57:11254 php-fpm: dziva mudzidzi cgr 0.0 1.0 363152 21708 28? S Apr0 12:13184 php-fpm: dziva cgr cgr 0.0 1.0 362872 21360 28? S Apr0 08:XNUMX php-fpm: dziva cgr

Sezvauri kuona ... kupatsanura kushandiswa kwePHP nevashandisi vachishandisa Nginx + PHP-FPM kuri nyore chaizvo, ndipo paunoona kuti pane madziva akati wandei, sezvo paine vashandisi vakati wandei.

CONCLUSIONS

Kana zvasvika kumaseva, haumbofi wakanyarara zvakakwana ... chengetedzo hachisi chinhu chekutamba nacho, kunyanya patinogara tichiedza kusimudzira kuchengetedzeka kwemaseva edu nemasevhisi avo, pashoma patinozotya ne (kubudirira) kubira kuyedza kana chero chakafanana 😉


Izvo zviri muchinyorwa zvinoomerera pamisimboti yedu ye tsika dzekunyora. Kuti utaure chikanganiso tinya pano.

Makomendi gumi, siya zvako

Siya yako yekutaura

Your kero e havazobvumirwi ichibudiswa. Raida minda anozivikanwa ne *

*

*

  1. Inotarisira iyo data: Miguel Ángel Gatón
  2. Chinangwa cheiyo data: Kudzora SPAM, manejimendi manejimendi.
  3. Legitimation: Kubvuma kwako
  4. Kutaurirana kwedata
  5. Dhata yekuchengetedza: Dhatabhesi inobatwa neOccentus Networks (EU)
  6. Kodzero: Panguva ipi neipi iwe unogona kudzora, kupora uye kudzima ruzivo rwako

  1.   dhunter akadaro

    Gaara, munguva dzazvino zvinhu izvi zvinofanirwa kunge zvakagadzirwa zvakanyanya sezvinobvira, ndinokurudzira kuti uedze Ansible. Pasina mumiriri, iwe unongoda python pane iri kure inomiririra, yakapusa kugadzirisa, yaml mafaera, Jinja matemplate.

    https://github.com/ansible/ansible-examples/tree/master/wordpress-nginx

    1.    KZKG ^ Gaara akadaro

      Ngatione, izvo hazvisi nguva dzose zveWordPress saiti, uye ... haha ​​pamwe Anogona kubaya volao, asi ini ndinofarira kuziva chaizvo mashandiro anoita zvese pane server, kunyangwe dai ndichifanira kupedza 1 mineti ndichigadzira masokisi matsva uye nyowani VHost 😀

      1.    dhunter akadaro

        NeAnable iwe unogadzira zvese, iwe unoita chero chaunoda, mukana weiyi nzira ndeyekuti unokomberedza tsika uye wozoita madiro, fungidzira kuti une saiti yakatakurwa zvakanyanya uye iwe unoda kuita mutoro kuenzanisa pakati pemaseva ekushandisa, izvi zvinofanirwa kuve yakagadzirirwa zvakangofanana iwe haugone kutsika nhanho kana kuita chero chakasiyana mune chimwe chazvo, unogona here kufungidzira uchiita danho nedanho kanokwana kana? NeAnable zviri nyore sekuwedzera iro zita revaenzi kune iyo yefaira faira uye Voilá !!

        http://www.ansible.com/how-ansible-works

      2.    dhunter akadaro

        Ndine urombo pamusoro pechechi yeAnable, asi ndeimwe yeaya matekinoroji aunowana uye iwe unoda kuti munhu wese aushandise izvozvi nekuti iwo anotonhorera uye anoshanda, zvakaita senge paunowana NGINX uye iwe uchida kuti shamwari dzako dzese dzisiye Apache nekukasira.

        https://speakerdeck.com/slok/ansible-all-the-things

  2.   Mstaaravin akadaro

    Ndine chokwadi chekuti posvo yangu inozadzisa izvi ...
    http://blog.ngen.com.ar/configuracion-segura-de-un-webserver-con-nginx-php-fpm/

  3.   Rots87 akadaro

    Ini (kana kudzidza kuve) musimudziri uye ndine NGIX ndakave nematambudziko akawanda pandanga ndichigadzira nginx + php-fpm. Ndinoziva kuti archlinux distro haisi yakanakisa kuti iite sevha, asi pese pandino gadziridza vhezheni ye ngix kana php zvese zvinogara zvichipunzika saka ndasiya muyedzo lol ... Nekuti nhasi ndinogara neiyo yekare Apache + PHP asi Ndichaona kana ndikatenderedza NGIX zvakare ... pamwe muchina chaiwo

    1.    dhunter akadaro

      Iko kufunga kunoshanduka zvishoma, nginx inoshandira iyo inomira zvirimo uye inoshanda seyakagadzika proxy yeiyo php-fpm ndiyo inomhanya iyo chaiyo PHP, iwe unofanirwa kutanga muzvikamu uye kuzadzisa iyo deploy nhanho nhanho, tsvaga gwara rekuendesa iyo chimiro chaunoshanda nacho, yega yega ine ruzivo nezvayo mazita eruzhinji, static, zviwanikwa, nezvimwe

  4.   kusazivikanwa akadaro

    Ita munharaunda kufarira kukuru kwekusiya izwi rekuti "hostear", iro risipo. NaMwari, zvakaoma here kuti titi "muenzi"?

  5.   Wil akadaro

    Kwaziso, uchitevedzera muenzaniso wako ndinoda kuziva kana dziva ringaitwe chete neshoko rezwi rekutsigira, ndokuti, kune wp-admin inogadzira socket nyowani yekupinda kubatana kune backend

    nzvimbo / wp-admin {
    mudzi /var/www/yoursite.com/wp-admin;
    index index.php index.html index.htm;
    nzvimbo ~ ^ / wp-admin /(.+. php) $ {
    edza_files $ uri = 404;
    mudzi /var/www/yoursite.com/wp-admin;
    inosanganisira / etc / nginx / fastcgi_params;

    fastcgi_pass server unix:/run/php5-fpm2.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 256 4k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_read_timeout 1240;
    }
    location ~* ^/wp-admin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
    root /var/www/tusitio.com/wp-admin/;
    }
    }