Maitiro ekusetesa Magento 2 Ine Varnish uye Apache pane Ubuntu 16.04

 

Magento ndeye yemahara uye yakavhurwa sosi Yemukati Management Sisitimu yakavakirwa muPHP, Zend chimiro uye MySQL dhatabhesi. Iyo inozivikanwa kwazvo eCommerce webhu application inomhanya pamusoro pemazhinji akavhurwa sosi svomhu senge Apache, MySQL uye akawanda akawanda. Magento inouya nemazhinji akavakirwa-mukati maamoja anoshandiswa kuwedzera mamwe mashandiro.

Varnish Cache isimba rakavhurika sosi webhu yekuwedzera accelerator inozivikanwawo seye caching HTTP reverse proxy. Iyo inoshandiswa kumhanyisa yako webhusaiti nekukopa kopi yewebhu peji kekutanga mushandisi anoshanya. Magento uye Varnish mubatanidzwa unozivikanwa kuwedzera saiti kuita zvakanyanya. Varnish inosanganiswa nekumisikidza muMagento 2. Iwe unongoda chete kugadzirisa dzimwe shanduko kuti iite kuti ishande.

Mune ino dzidziso, isu tinodzidza maitiro ekuisa Magento 2 neVarnish seyakazara peji cache pane Ubuntu 16.04 server.

zvinodiwa

  • Avhareji inoshandisa Ubuntu 16.04.
  • Apache, PHP, uye MariaDB.
  • Mushandi asiri mudzi ane sudo mararamiro ekugadzirisa pane seva yako.

1 Kutanga

Usati watanga, zvinokurudzirwa kugadzirisa yako system neazvino package nekumhanya unotevera kuraira:

sudo apt-get update -y
sudo apt-get upgrade -y

Kana yako system yave kukwiridzira, tangazve yako system uye upinde mukati nemushandisi mushandisi.

2 Isa LAMP Server

Magento haishande pasina kuisa LAMP stack (Apache, PHP, MariaDB). Kutanga, isa Apache webhu server uye varnish nekumhanyisa unotevera kuraira:

sudo apt-tora kuisa apache2 varnish -y

Mushure mekuisa Apache, tanga basa reApache uye riigone kutanga panguva yebhoti nekumhanya unotevera kuraira:

sudo systemctl tanga apache2
sudo systemctl ipai apache2

Magento yakanyorwa mumutauro wePHP, saka iwe unodawo kuisa PHP nemaraibhurari ese kune yako system. Unogona kuzviisa zvese nekumhanya unotevera kuraira:

sudo apt-tora kuisa php7.0 libapache2-mod-php7.0 php7.0-mbstring php7.0-mysql php7.0-mcrypt php7.0-xsl php-imagick php7.0-gd php7.0-ehl php- peya php7.0-intl php7.0-curl php7.0-zip php7.0-gd php7.0-sipo php7.0-xml -y

Mushure mekuisa PHP pamwe nemaraibhurari ese anodiwa, iwe unozofanirwa kushandura mashoma default PHP marongero. Unogona kuita izvi nekugadzirisa php.ini faira:

sudo nano /etc/php/7.0/cli/php.ini

Shandura mitsara inotevera:

memory_limit = 512 upload_max_filesize = 128M zlib.output_compression = pa max_execution_time = 15000

Ponesa uye uvhare faira kana wapedza.

3 Isa uye Gadzira MariaDB

Magento anoshandisa MariaDB sedhatabhesi. Saka iwe uchafanirwa kuiisa kune yako server. Unogona kuiisa nekungomhanya unotevera kuraira:

sudo apt-get install mariadb-server -y

Mushure mekuisa MariaDB, tanga MariaDB sevhisi uye woigonesa kutanga panguva yebhoti nekumhanyisa unotevera kuraira:

sudo systemctl tanga mysql
sudo systemctl ipai mysql

Nekukanganisa, MariaDB haina kuchengetedzwa, saka iwe uchafanirwa kuiwana. Unogona kuichengetedza nekumhanya unotevera kuraira:

sudo mysql_secure_installation

Pindura mibvunzo yose sezvinoratidzwa pasi apa:

CHERECHEDZA: KUMHANYA KWESE ZVIMWE ZVIMWE ZVINYORWA CHINYORWA ZVINOGONESESWA KWEVANHU VOSE VEMADHARA veMariaDB MUKUSHANDISA KUSHANDISA! NDINODZIDZA VERENGA NZIRA NETE NENYAYA! Kuti ugone kupinda muMariaDB kuti tiichengetedze, isu tichada iyo yazvino password yemidzi mushandisi. Kana iwe uchangobva kuisa MariaDB, uye usati waisa mudzi password, password ichave isina chinhu, saka iwe unofanirwa kungo pinda pinda pano. Pinda password yazvino yemidzi (pinda pasina): Horaiti, wakabudirira kushandisa password, uchienderera mberi ... Kumisikidza iro password password rinoona kuti hapana munhu anogona kupinda muMariaDB midzi mushandisi pasina mvumo chaiyo. Iwe unotova nemudzi password password, kuti ugone kupindura zvakachengeteka 'n'. Chinja iro password password? [Y / n] n ... kusvetuka. Nokusingaperi, kuiswa kweMariaDB kune mushandisi asingazivikanwe, zvichibvumira chero munhu kuti apinde muMariaDB pasina kuve neakaundi account yemushandisi yakagadzirirwa ivo. Izvi zvinoitirwa kuongororwa chete, uye kuita kuti kumisikidzwa kuite zvishoma. Iwe unofanirwa kuvabvisa usati waenda munzvimbo yekugadzira. Bvisa vashandisi vasingazivikanwe? [Y / n] Y ... Kubudirira! Kazhinji, mudzi unofanirwa chete kubvumidzwa kubatana kubva 'localhost'. Izvi zvinoona kuti mumwe munhu haakwanise kufungidzira pazasi password kubva kunetiweki. Rega kubvumira midzi kupinda kure? [Y / n] Y ... Kubudirira! Nokusingaperi, MariaDB inouya ne database inonzi 'test' iyo chero munhu anogona kuwana. Izvi zvakagadzirirwawo chete kuyedzwa, uye zvinofanirwa kubviswa usati waenda munzvimbo yekugadzira. Bvisa test database uye uwane kwariri? [Y / n] Y - Kudonhedza bvunzo dhatabhesi ... ... Kubudirira! - Kubvisa ropafadzo pabvunzo dhatabhesi ... ... Kubudirira! Kudzoreredza matafura eropafadzo kuchaita shuwa kuti shanduko dzese dzakaitwa kusvika parizvino dzinozoshanda pakarepo Dzosera zvakare matafura eropafadzo izvozvi? [Y / n] Y ... Kubudirira! Kuchenesa ... Zvese zvaitwa! Kana iwe wapedza ese ari pamusoro matanho, yako MariaDB kuisirwa inofanirwa kuve ikozvino yakachengeteka. Kutenda nekushandisa MariaDB!

Tevere, pinda kuna MariaDB shell nemirairo inotevera:

mysql -u root -p

Pinda yako password password kana uchikurumidza, wobva wagadzira dhatabhesi yeMagento nemirairo inotevera:

MariaDB [(hapana)]> GADZIRA DZESVONDO magento_db;

Mushure mekugadzira dhatabhesi yeMagento, gadzira zita rekushandisa, uye password nemutemo unotevera:

MariaDB [(hapana)]> GADZIRA USER 'magento' @ 'localhost' IDENTIFIED NE 'password';

Tevere, ipa ropafadzo kune dhatabhesi reMagento nemirairo inotevera:

MariaDB [(hapana)]> GADZIRA ZVESE ZVEMAITI PA magento_db. * KU 'magento' @ 'localhost';

Tevere, mhanya iyo FLUSH PRIVILEGES yekuraira kurodha zvakare iwo maropafadzo:

MariaDB [(hapana)]> FLUSH PRIVILEGES;

Pakupedzisira, buda kubva kuMariaDB koni pamwe nemirairo inotevera:

MariaDB [(hapana)]> q

4 Dhawunirodha Magento

Kutanga, iwe uchafanirwa kurodha yazvino vhezheni yeMagento kubva kune yavo yepamutemo webhusaiti.

Mushure mekurodha pasi Magento, bvisa iyo yakadzingwa zip faira kune iyo apache webhu dhairekitori nemirairo inotevera:

sudo mkdir / var / www / html / magento /
sudo unzip magento2-develop.zip -d / var / www / html / magento

Tevere, chinja muridzi weiyo magento dhairekitori uye upe mvumo kwayo kwairi:

sudo chown -R www-data: www-data / var / www / html / magento
sudo chmod -R 777 / var / www / html / magento

Tevere, iwe unozofanirwa kuisa Composer kune yako system. Munyori ndewe maneja wekuvimbika uyo anoshandiswa kuisa zvese zvinodikanwa PHP kutsamira. Unogona kudhawunirodha nekuisa Composer binary nemirairo inotevera:

kupisa -SS https://getcomposer.org/installer | php
sudo mv composer.phar / usr / bha / / munyori

Tevere, mhanya composer raira yekuisa zvese zvinoenderana nezvinodiwa neMagento:

cd / var / www / html / magento
sudo muimbi wega

Kana zvese zvinoenderana zvaiswa, unogona kuenderera mberi nekugadzirisa Apache yeMagento.

5 Gadzira Apache yeMagento

Tevere, iwe unozofanirwa kugadzira iyo Apache chaiyo inomiririra faira yeMagento. Gadzira faira nyowani yekumisikidza yeApache inonzi magento.conf nemirairo inotevera:

sudo nano /etc/apache2/sites-available/magento.conf

Wedzera mitsara inotevera:

ServerAdmin [email inodzivirirwa]
GwaroRoot / var / www / html / magento ServerName 192.168.15.189 ServerAlias ​​www.example.com < Sarudzo FollowSymLinks BvumiraOverride All Order tendera, ramba bvumidza kubva kune vese ErrorLog / var / log / apache2 / magento-error_log CustomLog / var / log / apache2 / magento-access_log zvakajairika

Sevha iyo faira, wobva wagonesa yako chaiyo inomiririra neApache rewrite module iwo unotevera kuraira:

sudo a2ensite magento
sudo a2enmod rewrite

Tevere, iwe zvakare unozofanirwa kushandura Apache inoteerera chiteshi kubva ku80 kuenda ku8080. Nekuti isu tinochengetera chiteshi 80 chevarnish. Kuti uite kudaro, vhura ports.conf faira:

sudo nano /etc/apache2/ports.conf

Chinja iyo faira sezvakaratidzwa pazasi:

Teerera 8080

Pakupedzisira, tangazve basa reApache kuti ushandise shanduko idzi nemirairo inotevera:

sudo systemctl chikafu apache2

6 Kuwana Magento Webhu Kuisa Wizard

Magento ikozvino yaiswa, ikozvino yave nguva yekuisa Magento kuburikidza newebhu browser.

Kuti uite kudaro, vhura web browser yako uye nyora URL http://192.168.15.189:8080, iwe unofanirwa kuona rinotevera peji:

Magento Webhu Kuisa Wizard

Zvino, bvumirana neMitemo neMamiriro uye tinya pane "Bvumirana uye Setup Magento" bhatani, iwe unofanirwa kuona rinotevera peji.

Bvumiranai TOS

Tarisa zvese Kugadzirira uye tinya pane rinotevera "bhatani, iwe unofanirwa kuona rinotevera peji:

Dhatabhesi ruzivo

Ipa yako dhatabhesi ruzivo, sezita reDhatabhesi, Dhatabhesi username nePassword, wobva wadzvanya pane "Inotevera" bhatani, iwe unofanirwa kuona rinotevera peji.

ruzivo rwewebhusaiti

Ipa yako webhusaiti ruzivo uye tinya pane rinotevera "bhatani, iwe unofanirwa kuona rinotevera peji.

magento marongero

Gadzirisa Magento sekuenderana nezvaunoda uye tinya pane rinotevera "bhatani, iwe unofanirwa kuona rinotevera peji.

admin mushandisi ruzivo

Ipa yako admin mushandisi ruzivo uye tinya pane "Inotevera" bhatani, iwe unofanirwa kuona rinotevera peji.

Isa ikozvino

Zvino, tinya pane "Isa Izvozvi" bhatani kutanga Magento kuisirwa. Kana kumisikidza kwapera iwe unofanirwa kuona rinotevera peji:

Installaton akabudirira

Ongorora: Rangarira yako Magento Admin URL: http://192.168.15.189/admin_wczta4. Izvi zvinoshandisa kuwana Magento admin.

Iye zvino, tinya pane "Vhura Magento Admin" bhatani, iwe unofanirwa kuona iyo Magento yekupinda peji se pazasi:

Magento kupinda

Ipa hunhu hwako hweMagento admin uye tinya pane bhatani rekuti “Sign In”, unofanira kuona Magent-o Dashibhodhi sezasi:

Magento Dhibhodhi

Kubva kwauri Magento Admin dashibhodhi tinya pane iyo STORES bhatani (leftside)> Kugadziridza> YAKADZIDZWA> Sisitimu> Yakazara Peji Cache, wobva Usasarudza shandisa system kukosha uye sarudza Varnish Cache kubva kuCaching Chikumbiro runyorwa, chengetedza iyo gadziriso, tinya paVarnish Configuration link uye tinya pane Export VCL yeVarnish 4 bhatani (izvi zvichatumira kunze varnish.vcl faira mu / var / www / html / magento / var directoy) sezvakaratidzwa pasi apa:

Magento chitoro kumisikidzwa

Pakupedzisira, pusha Magento cache nemirairo inotevera:

cd / var / www / html / magento
sudo php bin / magento cache: chimbichimbi

Kana uchinge wapedza, unogona kuenderera mberi nekugadzirisa varnish.

6 Gadzira Varnish

Magento ikozvino yaiswa uye yakagadzirirwa. Yenguva yekugadzirisa varnish.

Kutanga bvisa iyo /etc/varnish/default.vcl faira uye gadzira symlink kubva kune yakatumirwa varnish kumisikidzwa:

sudo rm -rf /etc/varnish/default.vcl
sudo ln -s /var/www/html/magento/var/varnish.vcl /etc/varnish/default.vcl

Tevere, iwe unozofanirwa kugadzira iyo systemd sevhisi faira ye varnish. Unogona kuita izvi nekuteedzera varnish.service kubva / lib / systemd / system / to / etc / systemd / system / directory:

sudo cp /lib/systemd/system/varnish.service / etc / systemd / system /

Mushure mekuteedzera iyi faira, iwe uchafanirwa kuita shanduko mune varnish.service faira:

sudo nano /etc/systemd/system/varnish.service

Ita zvinotevera kuchinja:

[Chikamu] Tsananguro = Varnish HTTP accelerator Gwaro = https: //www.varnish-cache.org/docs/4.1/ murume: varnishd [Sevhisi] Type = yakapusa LimitNOFILE = 131072 LimitMEMLOCK = 82000 ExecStart = / usr / sbin / varnishd - j unix, mushandisi = vcache -F -a: 80 -T yemunharaunda: 6082 -f /etc/varnish/default.vcl -S / etc / varnish / secret -s malloc, 256m ExecReload = / usr / share / varnish / reload -vcl ProtectSystem = yakazara ProtectHome = yechokwadi PrivateTmp = yechokwadi PrivateDevices = ichokwadi [Isa] WantedBy = multi-user.target

Sevha iyo faira kana iwe wapedza, wobva watangazve varnish sevhisi nemirairo inotevera:

sudo systemctl daemon-reload
sudo systemctl kurodha zvakare varnish

Kana zvese zviri kushanda mushe, saka iwe unokwanisa kukwanisa kupinda kune yako Magento kumashure-magumo nekutaipa inotevera URL pane yako webhu browser.

http://192.168.15.189/admin_wczta4

Iwe unogona zvakare kutarisa kana varnish inogoneswa kana kwete nekumhanyisa unotevera kuraira:

curl -I http: // 192.168.15.189/admin_wczta4

Iwe unofanirwa kuona kuti varnish inogoneswa:

Zuva: Fri, 07 Jul 2017 17: 10: 01 GMT Server: Apache / 2.4.18 (Ubuntu) Set-Cookie: chitoro = default; zvinopera = Sat, 07-Jul-2018 17:10:03 GMT; Max-Zera = 31536000; nzira = /; HttpOnly Set-Cookie: PHPSESSID = irp2k8cmrhct0dfh18qk7ap0i4; expires = Fri, 07-Jul-2017 18:10:04 GMT; Max-Zera = 3600; nzira = /; domain = 192.168.15.189; HttpOnly Expires: Thu, 07 Jul 2016 17: 10: 04 GMT Cache-Control: max-age = 0, must-revalidate, no-cache, no-store Pragma: no-cache Nzvimbo: http: // 192.168.15.189/ admin_wczta4 /? SID = irp2k8cmrhct0dfh18qk7ap0i4 X-Yemukati-Type-Sarudzo: nosniff X-XSS-Kudzivirirwa: 1; mode = block X-Furemu-Sarudzo: SAMEORIGIN Zvemukati-Kureba: 0 Zvemukati-Rudzi: zvinyorwa / html; charset = UTF-8 X-Varnish: 2 Zera: 0 Via: 1.1 varnish-v4 Kubatana: chengeta-mupenyu

Makorokoto! wabudirira kugadzirisa Magento neVarnish pane Ubuntu 16.04 server.

mabviro