Ho theha Setšoantšo sa VPS ka Drupal 9 ho Centos 8

Re tsoela pele ho atolosa 'maraka oa rona. Re sa tsoa u bolella kamoo o entse setšoantšo sa Gitlab, mme bekeng ena Drupal e hlahile 'marakeng oa rona.

Re u bolella hore na ke hobane'ng ha re mo khethile le hore na setšoantšo se entsoe joang.

Ho theha Setšoantšo sa VPS ka Drupal 9 ho Centos 8

Drupal - sethala se bonolo le se matla sa ho theha mofuta ofe kapa ofe oa sebaka sa marang-rang: ho tloha ho li-microsites le li-blogs ho ea mererong e meholo ea sechaba, hape e sebelisoa e le motheo oa lits'ebetso tsa webo, tse ngotsoeng ho PHP le ho sebelisa marang-rang a amanang e le polokelo ea data.

Drupal 9 e kenyelletsa likarolo tsohle tse hlahisitsoeng ho mofuta oa 8.9. Phapang ea bohlokoa lipakeng tsa mofuta oa 9 le mofuta oa 8 ke hore sethala se tla tsoelapele ho fumana lintlafatso le litokiso tsa ts'ireletso kamora Pulungoana 2021. Mofuta oa 9 o boetse o nolofatsa ts'ebetso ea ntlafatso, e etsa hore ts'ebetso ea ntlafatso ho tsoa ho mofuta oa 8 e be bonolo le ho feta.

Litlhoko tsa seva

Ho sebelisa Drupal, ho khothalletsoa ho sebelisa 2 GB RAM le 2 CPU cores.

Lifaele tse ka sehloohong tsa Drupal li nka hoo e ka bang 100 MB, ho phaella moo u tla hloka sebaka sa ho boloka litšoantšo, database, lihlooho, li-module tse eketsehileng le li-backups, tse tla itšetleha ka boholo ba sebaka sa hau.

Drupal 9 e hloka PHP 7.4 kapa ho feta ka moeli o fokolang (memory_limit) bakeng sa memori ea 64 MB; haeba ho sebelisoa li-module tse ling, ho kgothaletswa ho kenya 128 MB.

Drupal e ka sebelisa Apache kapa Nginx e le seva sa marang-rang, 'me MySQL, PostgreSQL kapa SQLite e le database.

Re tla be re kenya Drupal re sebelisa Nginx le MySQL.

bophirima

Ha re ntjhafatseng liphutheloana tse kentsoeng mofuta oa morao-rao:

sudo dnf update -y

Ha re kenyelle tumello ea ka ho sa feleng bakeng sa sephethephethe se kenang ho http/80 le https/443 ports:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https

Ha re sebeliseng melao e mecha ea firewall:

sudo systemctl reload firewalld

Ha re kenye Nginx:

sudo dnf install nginx -y

Ha re qaleng le ho nolofalletsa seva sa Nginx:

sudo systemctl start nginx
sudo systemctl enable nginx

Kaha polokelo ea mantlha ea Centos hajoale e sebelisa PHP 7.2, ha re kenyeng polokelo ea REMI ka PHP 7.4 (bonyane mofuta oa Drupal 9).
Ho etsa sena, eketsa polokelo ea EPEL (e hlokoang ke polokelo ea REMI):

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Ha re kenyeng polokelo ea REMI:

sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Ha re lumelle php:remi-7.4 module ho kenya php 7.4:

sudo dnf module enable php:remi-7.4 -y

Kenya php-fpm le php-cli:

sudo dnf install -y php-fpm php-cli

Ha re kenyeng li-module tsa PHP tse hlokahalang hore Drupal e sebetse:

sudo dnf install -y php-mysqlnd php-date php-dom php-filter php-gd php-hash php-json php-pcre php-pdo php-session php-simplexml php-spl php-tokenizer php-xml

Hape re tla kenya li-module tsa PHP mbstring opcache tse khothalletsoang:

sudo dnf install -y php-mbstring php-opcache

Ha re kenye seva sa MySQL:

sudo dnf install mysql-server -y

Ha re bulele 'me re qale seva sa MySQL:

sudo systemctl start mysqld
sudo systemctl enable mysqld

Kaha re etsa template bakeng sa VDS, 'me e ka lieha, re tla eketsa mysqld ho qala ho lieha ha metsotsoana ea 30, ho seng joalo ho ka' na ha e-ba le mathata ka seva ho qala nakong ea boot system ea pele:

sudo sed -i '/Group=mysql/a 
ExecStartPre=/bin/sleep 30
' /usr/lib/systemd/system/mysqld.service

Ha re fetoleng sehlopha le mosebelisi eo nginx e tla sebetsa tlas'a eona ka ho etsa liphetoho ho /etc/php-fpm.d/www.conf:

sudo sed -i --follow-symlinks 's/user = apache/user = nginx/g' /etc/php-fpm.d/www.conf
sudo sed -i --follow-symlinks 's/group = apache/group = nginx/g' /etc/php-fpm.d/www.conf

Ha re fetoleng mong'a lethathamo la linako tsa PHP hore e be nginx ho latela:

sudo chown -R nginx. /var/lib/php/session

Ha re tloseng mela e nang le maikutlo ho tsoa faeleng ea tlhophiso /etc/nginx/nginx.conf (e le hore ho se be le li-triggers tse peli bakeng sa sed):

sudo sed -i -e '/^[ t]*#/d'  /etc/nginx/nginx.conf

Kenya litlhophiso tsa compression ea gzip ho /etc/nginx/nginx.conf

sudo sed -i '/types_hash_max_size 2048;/a 

    gzip on;
    gzip_static on;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/x-icon image/svg+xml application/x-font-ttf;
    gzip_comp_level 9;
    gzip_proxied any;
    gzip_min_length 1000;
    gzip_disable "msie6";
    gzip_vary on; 
' /etc/nginx/nginx.conf

Ha re kenyelleng litlhophiso tsa index.php file ho /etc/nginx/nginx.conf:

sudo sed -i '/        root         /usr/share/nginx/html;/a 
        index index.php index.html index.htm;
' /etc/nginx/nginx.conf

Ha re ke re eketse litlhophiso bakeng sa seva sa kamehla: Phetoho ea PHP ka sokete ea php-fpm, tima log bakeng sa lifaele tse tsitsitseng, eketsa nako ea ho felloa ke nako, tima phihlello le liphoso tsa favicon.ico le robots.txt, 'me u hane ho fihlella .ht lifaele tsa motho e mong le e mong:

sudo sed -i '/        location / {/a 
		try_files $uri $uri/ /index.php?q=$uri&$args;
        }
    
        location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|woff)$ {
        access_log off;
        expires max;
        }
    
        location ~ .php$ {
        try_files  $uri =404;
        fastcgi_pass   unix:/run/php-fpm/www.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_ignore_client_abort off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
        }
    
        location = /favicon.ico {
        log_not_found off;
        access_log off;
        }
    
        location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
        }
    
        location ~ /.ht {
        deny all;' /etc/nginx/nginx.conf

Kenya wget e hlokahalang bakeng sa ho kenya certbot:

sudo dnf install wget -y

Khoasolla faele e sebetsang ea certbot ho tsoa sebakeng se ka thoko:

cd ~
wget https://dl.eff.org/certbot-auto

Tsamaisa certbot ho /usr/local/bin/:

mv certbot-auto /usr/local/bin/certbot-auto

Mme a re faneng ka litokelo joalo ka mong'a ho metsa:

chown root /usr/local/bin/certbot-auto
chmod 0755 /usr/local/bin/certbot-auto

Ha re kenyeng litšepiso tsa certbot mme mothating ona re sitise mosebetsi oa eona (Likarabo: Y, c):

certbot-auto

Ha re khoasolle polokelo ea litaba ka mofuta oa morao-rao oa Drupal 9 ho tsoa sebakeng se ka thoko:

cd ~
wget https://www.drupal.org/download-latest/tar.gz

Kenya tar ho notlolla polokelong ea litaba:

sudo dnf install tar -y

Ha re hlakole lifaele tsa kamehla ho /usr/share/nginx/html/ directory:

rm -rf /usr/share/nginx/html/*

Ha re lokolle lifaele ka har'a bukana ea seva sa webo:

tar xf tar.gz -C /usr/share/nginx/html/

Ha re tloseng lifaele ho tloha ho subdirectory ho ea mohloling oa motso oa seva sa webo:

mv /usr/share/nginx/html/drupal-9.0.7/* /usr/share/nginx/html/

Ha re hlakole subdirectory:

rm -rf /usr/share/nginx/html/drupal-9.0.7

Ha re hlakole polokelo ka lifaele tsa ho kenya:

rm -f ./tar.gz

Ha re abele mong'a lifaele tsa nginx:

chown -R nginx. /usr/share/nginx/html

Mothating ona re tla tima seva ebe re nka snapshot:

shutdown -h now

Kamora ho qala VDS ho tsoa setšoantšong, re tla etsa setaele sa pele sa seva sa MySQL ka ho tsamaisa sengoloa:

mysql_secure_installation

Ha re lumelle ho netefatsa password:

Would you like to setup VALIDATE PASSWORD component? : y

Ha re behe phasewete bakeng sa mosebelisi oa motso oa MySQL:

New password:
Re-enter new password:

Ha re tloseng basebelisi ba sa tsejoeng:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Ha re thibeleng motso ho hokela u le hole:

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

Ha re hlakole database ea liteko:

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

Ha re kenye hape litafole tsa litokelo:

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Ka mor'a sena, ho qeta ho kenya, re ka ea ho vps_ip_aterese
Atereseng ena re tla bona leqephe la ho kenya Drupal.

Ha re khethe puo eo re tla e sebelisa. Ka mohlala: Serussia. Tobetsa "Save and Continue"

Ha re khethe profil ea ho kenya (demo e sebelisoa feela ho tloaelana le sistimi). Tabeng ea rona, e ke e be "standard".

Leqepheng le latelang re tla fana ka lebitso ho database, mohlala "drupal". Ha re bonts'e motso oa lebitso la mosebelisi oa database le password eo a e filoeng ha a ntse a sebelisa mysql_secure_installation. Tobetsa "Boloka 'me U Tsoele Pele."

Ha re emeleng hore ho kengoa le ho nchafatsa liphetolelo ho phethehe (ts'ebetso e ka nka metsotso e mengata).

Re tla bonts'a lebitso la sebaka sa marang-rang, beha lengolo-tsoibila la sebaka sa marang-rang (lebitso la sebaka sa marang-rang se tla romelloa), ho kena, password le lengolo-tsoibila la akhaonto ea Drupal administrator. Hape re tla beha naha le sebaka sa nako maemong a lebatooa. 'Me u qete ho kenya ka ho tobetsa "Boloka le Tsoela Pele".

Kamora sena, o ka ea phanele ea taolo ka ho kena le password ea Drupal administrator.

Ho theha HTTPS (boikhethelo)

Ho lokisa HTTPS, VDS e tlameha ho ba le lebitso le nepahetseng la DNS, le hlakisetse ho

/etc/nginx/nginx.conf

karolong ea seva lebitso la seva (mohlala):

server_name  domainname.ru;

Ha re qaleng hape nginx:

service nginx restart

Ha re qaleng certbot:

sudo /usr/local/bin/certbot-auto --nginx

Kenya lengolo-tsoibila la hau, lumellana le lipehelo tsa ts'ebeletso (A), Ingolise ho koranta (ka boikhethelo) (N), khetha mabitso a marang-rang ao u batlang ho fana ka setifikeiti sa ona (Kena bakeng sa motho e mong le e mong).

Haeba ntho e 'ngoe le e' ngoe e tsamaile ntle le liphoso, re tla bona molaetsa mabapi le phano e atlehileng ea litifikeiti le tlhophiso ea seva:

Congratulations! You have successfully enabled ...

Kamora sena, likhokahano ho port 80 li tla fetisetsoa ho 443 (https).

Eketsa ho /etc/crontab ho ntlafatsa setifikeiti ka bo eona:

# Cert Renewal
30 2 * * * root /usr/local/bin/certbot-auto renew --post-hook "nginx -s reload"

Ho theha Trusted Host Security (e ea khothaletsoa)

Tlhophiso ena e reretsoe ho ba tharollo bothateng bo amanang le dynamic base_url determination, 'me e etselitsoe ho thibela litlhaselo tsa HTTP HOST Header (ha sebaka sa hau sa marang-rang se nahana hore ke motho e mong).

Ho etsa sena, o hloka ho hlakisa mabitso a marang-rang a tšepahalang bakeng sa sebaka sa marang-rang ho faele ea litlhophiso.

Ka faele

/usr/share/nginx/html/sites/default/settings.php Ha re fetoleng maikutlo kapa re kenye litlhophiso tse nang le mabitso a sebaka sa marang-rang, mohlala:

$settings['trusted_host_patterns'] = [
  '^www.mydomain.ru$',
];

Ho kenya PHP APCu (E KHOTHATSOE)

Drupal e tšehetsa APCu - Cache e 'ngoe ea PHP User Cache, liphetolelo tsa 8 le 9 li sebelisa APCu haholo e le cache ea nakoana ea lehae ho feta liphetolelo tse fetileng. Cache ea kamehla (32 MB) e loketse libaka tse ngata, 'me e ke ke ea feta 512 MB.

Ho kenya tšebetsong, kenya mojule oa PHP APCu:

dnf -y install php-pecl-apcu

Qala hape nginx le php-fpm:

service nginx restart
service php-fpm restart

Haeba u sebelisa puo ea Serussia le APCu ka boholo ba memori e khothalletsoang bakeng sa cache, u ka bona temoso ho phanele ea taolo hore boholo ba memori e fanoeng bakeng sa cache e fapane le e khothalletsoang, empa ha e le hantle ntho e 'ngoe le e' ngoe e sebetsa ka nepo, mme tlhokomeliso e fosahetseng e tla lokisoa lintlafatsong tse latelang.

Kapa haeba temoso e utloisa mahlo a hao bohloko, u ka e sebelisa patch e tsamaellanang ho tloha kantle ho sebaka.

Re rata ho u hopotsa hore u ka boela ua re etsetsa setšoantšo

Ho na le likhetho tse tharo tsa mokhoa oa ho nka karolo.

Lokisetsa setšoantšo ka boeena 'me u fumane li-ruble tse 3000 ho tekanyo ea hau

Haeba u se u itokiselitse ho potlakela ntoeng 'me u iketsetsa setšoantšo seo u se hlokang, re tla u fa mokitlane oa li-ruble tse 3000 XNUMX ho leka-lekana ea hau ea ka hare - u ka e sebelisa ho li-server.

Mokhoa oa ho etsa setšoantšo sa hau:

  1. Etsa akhaonto le rona sebaka
  2. Bolella tšehetso hore u tlo theha le ho leka litšoantšo
  3. Re tla u fa mokitlane oa li-ruble tse 3000 'me re khone ho etsa li-snapshots
  4. Odara seva e nang le sistimi e hloekileng ea ts'ebetso
  5. Kenya software ho VPS ena 'me u e behe
  6. Ngola litaelo kapa script bakeng sa phepelo ea software
  7. Etsa senepe bakeng sa seva e hlophisitsoeng
  8. Odara sebatli se secha ka ho khetha senepe se entsoeng nakong e fetileng lethathamong le theohang la "Server template".
  9. Tabeng ea ho theha seva ka katleho, fetisetsa thepa e fumanoeng mohato oa 6 ho tšehetso ea tekheniki
  10. Haeba ho na le phoso, o ka hlahloba ka tšehetso bakeng sa lebaka mme o pheta ho seta

Bakeng sa beng ba likhoebo: fana ka software ea hau

Haeba u moqapi oa software e sebelisoang le ho sebelisoa ho VPS, re ka u kenyelletsa 'marakeng. Ke kamoo re ka u thusang ho tlisa bareki ba bacha, sephethephethe le ponahalo. Re ngole

Re bolelle maikutlong hore na u haelloa ke setšoantšo sefe?

'Me re tla e lokisetsa rona

Ho theha Setšoantšo sa VPS ka Drupal 9 ho Centos 8

Ho theha Setšoantšo sa VPS ka Drupal 9 ho Centos 8

Source: www.habr.com