Me manaaki i nga VHosts maha me nga kaiwhakamahi rereke i Nginx

Ko te mea noa i te ao ka whai koe i tetahi kaitoha ko te whakaaro mo te ahuru me te nui o te ahuru, kaore koe e mate moemoea 😉

He mahinga noa noa iho kaore he mea e taunakitia ana, ko te whakamahi i te kaiwhakamahi kotahi mo nga putunga pātengi katoa, he kino ake mena ka whakamahia te pakiaka, he ahua whakaharahara te ahua, kei kona etahi (e tika ana ki te moepuku kuware ranei) mahia tenei, kua korero ano ahau mo te aha kaua e penei te mahi i roto tetahi atu pouKua tae ki te waa ki te whakamarama me pehea te pai ake ki te wehe i te tukatuka a te kaituku paetukutuku ki nga kaiwhakamahi rereke, i tenei waa ka whakamahia Nginx.

WhakatapuaTohuWhakaahuaMaaro

He aha tera o nga kaiwhakamahi me te kaituku paetukutuku?

Hei whakamaarama ma te korero poto, maamaa hoki, me whakatuwhera te kaituku paetukutuku (apache, nginx, nga mea katoa) ki te punaha i roto i te punaha, nga mahinga ka tangohia nga konae mai i te HDD (whakaahua, me etahi atu) ka waatea ki te tirotiro a te kaihoko. . Kaore e taea e te kaiwhakarato paetukutuku te tango i nga konae me te raweke i te mea ehara i te tangata, ara, me whakamahi te kaiwhakamahi ko wai ra ka mahi i enei mahi katoa i te mutunga, ana ko taua kaiwhakamahi taku e korero nei, kei te maarama koe?

He aha te wehewehe o nga kaiwhakamahi maha?

Me whakaaro kei runga i ta tatou kaitoha, e rua nga paetukutuku a taatau, he kaupapa takitahi taatau, me tetahi atu (kia whakaaro o to tatou kaumeá teina ranei o). Ahakoa ka whakamahia e maatau nga papaanga wehe me nga kaiwhakamahi rereke kia uru atu ki a raatau, i te mutunga ko nga konae o nga paetukutuku e rua e whakamahia ana e taua kaiwhakamahi, ko te tukatuka PHP e whakahaeretia ana e taua kaiwhakamahi mo nga waahi katoa (te tikanga ko te www-raraunga). Ehara tenei i te mahi e manakohia ana, he pai ake te wehe wehe i nga mea katoa, hei ki ta te koroheke, he pai ake te ahuru i te pouri.

Ok Kei te maarama ahau, me pehea taku mahi me Nginx

2000px-Nginx_logo.svg

Ko te mea tuatahi kia mahara kaore a Nginx i a ia ake kaupapa whakahaere i te tukatuka PHP pera me Apache, mo Nginx me whakamahi i te PHP-CGI, i te PHP-FPM ranei, he pai ake te mahi (pai ake ranei) i a Apache. Na, hei wehe i te tukatuka PHP puta noa i nga kaiwhakamahi rereke, me huri nga raina ki nga konae whirihora PHP (CGI, FPM ranei), kaua ko Nginx ake.

Whakaarohia e whakamahi ana koe PHP-FPM, ka hangahia e maatau he konae whirihoranga o poka Mo tetahi papanga motuhake, ara, ko te puna kauka te huarahi ki te wehe i te tukatuka PHP mai i te PHP-FPM, engari he waahanga taatau.

1. Tuatahi me mohio taatau ko wai te kaiwhakamahi o te punaha ka whakamahia e taatau, ka kii ahau kaore ano o maatau hanga me te pai, kia hanga e tatou:

Ko nga whakahau katoa e whai ake nei me mahi me nga mana whakahaere, ma te pakiaka tika ranei te whakamahi i te sudo

adduser blog

Ka tiimata e maatau te mahinga noa o te hanga kaiwhakamahi, whakauru i te kupuhipa, etc.

Ka tuhia e au te tuhinga ki te kaiwhakamahi ki te whai i te tauira, ko te papaanga tuatahi ka whakahaerehia e maatau he blog, he pai ... kia mohio ko ia kaiwhakamahi e hono ana ki te papaanga

1. Tuatahi kia haere tatou ki /etc/php5/fpm/pool.d/:

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

2. Na, ka hangaia e maatau he konae e kiia nei ko blog.conf:

touch blog.conf

3. Inaianei ka tukuna e maatau te whirihoranga o te puna kaukauranga ka whakamahia e maatau mo te tuhinga VHost:

Whakatikahia te konae blog.conf me te nano ... hei tauira: sudo nanoblog.conf
[rangitaki] kaiwhakamahi = rangitaki
roopu = rangitaki
whakarongo = / var / oma / php5-fpm-rangitaki.sock whakarongo. rangatira = rangitaki
whakarongo.ropu = rangitaki
pm = ondemand pm.max_ tamariki = 96 chdir = /

Tuhipoka: Ko te mea ka tohua e ahau ki a ratou i roto i te whero te mea me whakarereke e pa ana ki te kaiwhakamahi i waihangahia e ratou i mua. Hei tauira, mena ka hangaia e raatau tetahi atu VHost me tetahi atu kaiwhakamahi (huinga hei tauira) ka waiho ki te blog te waiho noa i te huinga ki ia raina, kaore e marama?

4. Kia te whirihoranga o te puna kaukau hou (te konae blog.conf i waihangahia nei e maatau me te whakatika), ko te huringa ki te korero ki a Nginx VHost kia whakamahia he tokena rereke mo tera VHost, mo tenei papaanga. Ko te tokena e whakamahia ana ko ta maatau i kii i mua (/var/run/php5-fpm-blog.sock). Me whakatika te Nginx VHost me te waahanga tukatuka PHP, ka tohu maatau ki te whakamahi i nga tokena. Hei tauira:

waahi ~ \ .php $ {mena (! -f $ request_filename) {whakahoki 404; }
fastcgi_pass unix: / var / oma / php5-fpm-rangitaki.tokena;
whakauruhia nga fastcgi_params; fastcgi_param SCRIPT_FILENAME $ tuhinga_root $ fastcgi_script_name; fastcgi_read_timeout 300; }

Kei te kite koe, e tohu ana ahau ko te tukatuka PHP o taua VHost (ko era raina he tauira i roto / etc / nginx / whakahohe-pae / blog-wairua) mahia ki nga tokena i kitea i /var/run/php5-fpm-blog.sock ... koinei te mea i hangaia e maatau i te wa e whakatika ana /etc/php5/fpm/pool.d/blog.conf ... kaore i te marama ?

5. Ka oti ana tenei, ka tiimata ano e taatau nga ratonga e rua (php5-fpm me nginx) me te voila, ka kite taatau ko te tukatuka o taua papaanga (vhost) KAORE i mahia e te tuhinga-www, te pakiaka ranei tetahi ranei e rite ana, engari na te kaiwhakamahi i whakatauhia e maatau i mua. .

Ka whakaatu atu ahau ki a koe i te putanga o a ps aux | grep fpm i runga i tetahi o nga kaituku o taku kōpuku:

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

Kei te kite koe ... he mea ngawari te wehe i te tukatuka PHP ma nga kaiwhakamahi e whakamahi ana i a Nginx + PHP-FPM, i reira ka kite koe he maha nga puna, na te mea he maha nga kaiwhakamahi.

Tuhinga

Ka tae ana ki nga kaiwhakarato, kaore koe e tino pohehe ... ehara te haumarutanga i tetahi mea hei takaro, ka kaha tonu taatau ki te whakapai ake i te ahuru o a tatou kaituku me a raatau ratonga, ka kore pea tatou e mataku i te ngana o te (angitu) hack tetahi mea rite 😉


Ko nga korero o te tuhinga e piri ana ki o maatau kaupapa o matatika whakatika. Ki te ripoata i tetahi paatene paato Here.

9 korero, waiho maau

Waiho to korero

Ka kore e whakaputaina tō wāhitau īmēra.

*

*

  1. He kawenga mo nga raraunga: Miguel Ángel Gatón
  2. Te kaupapa o te raraunga: Whakahaerehia te SPAM, te whakahaere korero.
  3. Ture: To whakaae
  4. Whakawhitinga korero: Kaore nga korero e tukuna ki nga taha tuatoru engari ma te ture herenga.
  5. Rokiroki raraunga: Paetukutuku e whakahaerehia ana e Occentus Networks (EU)
  6. Tika: I nga wa katoa ka taea e koe te whakaiti, te whakaora me te muku i o korero.

  1.   Pūoro ka mea

    Gaara, i nga waa o enei wa me mahi noa nga mea nei, ka tono atu ahau kia whakamatau koe i te Ansible. Kaore he kaihoko, me maarama noa koe i te kaitautoko mamao, he maamaa noa ki te whirihora, konae nga konae, tauira Jinja.

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

    1.    KZKG ^ Gaara ka mea

      Tirohia, ehara i te mea ko nga waahi anake o te WordPress, me ... haha ​​akene he paatene Anosible, engari he pai ke ahau ki te mohio me pehea te mahi o nga mea katoa ki te kaitoha, ahakoa ka whakapau ahau ki te 1 meneti te hanga hutu hou me VHost hou 😀

      1.    Pūoro ka mea

        Ma te Maatau ka whakaratuhia e koe nga mea katoa, ka mahi koe i nga mea katoa e hiahia ana koe, ko te painga o tenei tikanga ko te whakakotahi i te mahi ka mahia i te wa e pai ai koe, whakaarohia he papa taumaha taau me te hiahia ki te whakariterite kawenga i waenga i nga kaitono tono he rite tonu te whirihora kaore e taea te peke i tetahi hikoi, te mahi ranei i tetahi mea rereke i roto i tetahi o raatau, ka taea e koe te whakaaro ki te mahi i nga tikanga taahiraa i te taahiraa 4 wa? Ma te Ansible he maamaa ano he taapiri i te ingoa rangatira ki te konae rārangi me te Voilá !!

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

      2.    Pūoro ka mea

        Aroha mai mo te haahi Ansible, engari koinei tetahi o enei hangarau e kitea ana e koe ana kei te hiahia koe kia whakamahia e nga tangata katoa inaianei na te mea he tino hauhautanga me te whaihua, penei i te wa ka kitea e koe a NGINX me te hiahia koe kia whakarere wawe atu o hoa ki Apache.

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

  2.   mstaaravin ka mea
  3.   Roti87 ka mea

    Ko au (he ako ranei hei) kaiwhakawhanake me NGIX He maha nga raru i au i te whirihora nginx + php-fpm. Kei te mohio au ko te distro archlinux ehara i te mea pai ki te waiho hei kaiwhakarato, engari i nga wa katoa ka whakahou au i te momo ngix php ranei ka pakaru noa i nga mea katoa ka whakarere ahau i te nganatanga lol ... Mo tenei ra i noho ahau ki te Apache + PHP tawhito engari ka kite au mena ka hikoi ano au ki NGIX ... akene kei runga i te miihini mariko

    1.    Pūoro ka mea

      Ka rereke te rereketanga o te hinengaro, ka whakamahia e te nginx nga korero pumau me te mahi hei takawaenga whakamuri mo te php-fpm maana e whakahaere te PHP pono, me tiimata e koe nga waahanga ka whakatutuki i nga waahanga taapiri, rapua he aratohu hei hora. te anga e mahi ana koe, kei ia tangata nga taipitopito taitara ingoa o te iwi whanui, taatai, rauemi, aha atu.

  4.   ingoamuna ka mea

    Kia kaha te hapori ki te whakarere i te kupu "hostear", kaore nei. Na te Atua, he uaua ki te kii "manaaki"?

  5.   Wil ka mea

    Tena koe, e whai ake nei i taau tauira E hiahia ana ahau ki te mohio mena ka taea te hanga poka wai mo te kupu anake ki muri, ara mo te kaiwhakahaere-wp te hanga turanga hou mo nga hononga taumai ki te tuara.

    tauwāhi / wp-kaiwhakahaere {
    pakiaka /var/www/yoursite.com/wp-admin;
    index index.php index.html index.htm;
    wāhi ~ ^ / wp-kaiwhakahaere /(.+. php) $ {
    try_files $ uri = 404;
    pakiaka /var/www/yoursite.com/wp-admin;
    whakauru / 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/;
    }
    }