Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

WordPress bụ usoro njikwa ọdịnaya kachasị nke edere na PHP, jikọtara ya na MySQL ma ọ bụ nchekwa data MariaDB. Ị nwere ike ịmepụta ma jikwaa saịtị na-enweghị ihe ọmụma ọ bụla na mmepe weebụ ma ọ bụ nzuzo. Emepụtara ụdị WordPress mbụ na 2003 site n'aka Matt Mullenweg na Mike Little ma ugbu a 70% nke ahịa webụ ama ama, dịka W3Tech si kwuo. WordPress na-abịa na nsụgharị abụọ: isi mmalite mepere emepe n'efu WordPress.org na WordPress.com, ọrụ akwụ ụgwọ na-amalite na $5 kwa ọnwa ruo $59. Iji usoro njikwa ọdịnaya a dị mfe ma na-ahụkarị dị ka ihe mgbago maka ịme blọgụ ma ọ bụ saịtị yiri ya.

N'ime nkuzi a, ị ga-amụta otu esi etinye WordPress nke na-akwado onwe ya site na iji ụdị Nginx, MariaDB na PHP kachasị ọhụrụ dị.

Prerequisites

  • OS akwadoro: Rocky Linux 8.+.
  • Akaụntụ onye ọrụ: Akaụntụ onye ọrụ nwere sudo ma ọ bụ ohere mgbọrọgwụ.

Melite Sistemụ Ọrụ

Melite gi Nkume linux Sistemụ arụmọrụ iji hụ na ngwugwu niile dị adị adịla ugbu a:

sudo dnf upgrade --refresh -y

Nkuzi a ga-eji ya sudo iwu na na-eche na ị nwere ọnọdụ sudo.

Iji nyochaa ọkwa sudo na akaụntụ gị:

sudo whoami

Ihe atụ na-egosi ọkwa sudo:

[joshua@rockylinux ~]$ sudo whoami
root

Ka ịtọlite ​​akaụntụ sudo dị adị ma ọ bụ ọhụrụ, gaa na nkuzi anyị na Otu esi etinye onye ọrụ na Sudoers na Rocky Linux.

Iji mgbọrọgwụ akaụntụ, jiri iwu na-esonụ na paswọọdụ mgbọrọgwụ banye.

su

Wụnye ngwugwu CURL & UNZIP

Nkuzi na-eji ihe curl na unzip iwu n'oge ụfọdụ akụkụ. Iji jide n'aka na etinyere nke a, gbanye iwu a na ọdụ gị:

sudo dnf install curl unzip -y

Advertisement


Wụnye Nginx - (LEMP Stack)

Nhọrọ. Gbanwee ụdị Nginx ka ọ bụrụ EPEL

Iji malite nrụnye nchịkọta LEMP, ị ga-achọ ịwụnye ya Nginx sava weebụ. Nkuzi a ga-egosi nhọrọ nhọrọ nke iyi Nginx ka ịwụnye, nke dị mma ma ọ bụrụ na ị tinye ebe nchekwa EPEL.

Mbụ, depụta profaịlụ Nginx dị site na iji dnf modul ndepụta iwu n'ọnụ ọnụ gị:

sudo dnf module list nginx

Ihe atụ mmepụta:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ebe nkuzi a na-elekwasị anya n'iji ntọhapụ EPEL, a ga-ahọrọ Nginx mainline. Mana nke mbụ, ịkwesịrị ịtọgharịa modul Nginx ka ọ gbanwee.

sudo dnf module reset nginx

Ihe atụ mmepụta:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ụdị "Y," wee pịa "Tinye igodo" ka ịga n'ihu na ịtọgharịa ndepụta modul.

Na-esote, mee ka modul Nginx masịrị gị. Maka nkuzi a, a ga-ahọrọ EPEL, ma ọ bụrụ na ịchọrọ iji Nginx mainline, ị ga-abanye "nginx: mainline," ọ bụrụ na ịchọrọ ụdị kwụsiri ike, mgbe ahụ ọ ga-abụ “nginx.1:20”.

Iji tinye EPEL mainline:

sudo dnf module enable nginx:mainline

Iji wụnye ụlọ EPEL:

sudo dnf module enable nginx:1.20

Wụnye Nginx

Ugbu a ọ bụ oge ịwụnye Nginx dị ka akụkụ nke nrụnye LEMP. Ma ị tinyela EPEL na iji Nginx wuru dabere na ebe nchekwa ahụ ma ọ bụ jiri ndabara Rocky Linux 8 App iyi, iwu ga-abụ otu; naanị ụfọdụ n'ime nsonaazụ ndị bụ naanị ihe atụ ga-adị iche.

Iji tinye Nginx, jiri iwu na-esonụ na njedebe gị:

sudo dnf install nginx

Ihe atụ mmepụta:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ụdị "Y," wee pịa "Tinye igodo" ịga n'ihu na nwụnye.

Kwado nrụnye site na ịlele ụdị nrụpụta:

nginx -v

Ihe atụ mmepụta:

nginx version: nginx/1.14.1

Site na ndabara, mgbe ị na-etinye Nginx na Rocky Linux, anaghị enyere ya aka. Iji mee ka boot na ịmalite, jiri ihe ndị a:

sudo systemctl enable nginx --now

Ọmụmaatụ nke iji mee nke ọma (symlink):

Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.

Ugbu a, lelee ka ịhụ ọkwa ọrụ Nginx gị site na iji iwu ọnụ na-esonụ:

systemctl status nginx

Ihe atụ na-ekwu na ihe niile dị mma:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ugbu a, ị nwere ike kwado na sava weebụ Nginx gị na-arụ ọrụ site na ịbanye HTTP://server-ip or HTTP: // ngalaba-aha na ihe nchọgharị ịntanetị gị, ị ga-enweta ihe ndị a:

Otu esi etinye phpBB na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ọ bụrụ na ịnweghị ike ịnweta ibe a, ị nwere ike ịhazi ntọala firewall kpuchiri na ngalaba na-esote.

Hazie Iwu Firewall

Ọ naghị agbakwunye iwu firewall na akpaghị aka na ọdụ ụgbọ mmiri 80 ma ọ bụ 443 mgbe ị na-etinye Nginx. Tupu ị gaa n'ihu, ịkwesịrị ịtọ iwu ndị a, nke a ga-adabere na ọdụ ụgbọ mmiri ị ga-eji, mana edepụtara nhọrọ niile.

Mepee ọdụ ụgbọ mmiri 80 ma ọ bụ HTTP:

sudo firewall-cmd --permanent --zone=public --add-service=http

Mepee ọdụ ụgbọ mmiri 443 ma ọ bụ HTTPS:

sudo firewall-cmd --permanent --zone=public --add-service=https

Bugharịa firewall iji mee mgbanwe ka ọ dị irè

sudo firewall-cmd --reload

Advertisement


Wụnye MariaDB (LEMP STACK)

Nhọrọ. Gbanwee na MariaDB 10.5

Rocky Linux App iyi site na ndabara wụnye MariaDB 10.3, ụdị ochie mana kwụsiri ike nke ukwuu. Otú ọ dị, MariaDB kachasị ọhụrụ n'oge nkuzi a nke a na-ahazi dị ka ntọhapụ kwụsiri ike bụ MariaDB 10.6.4. Dị ka ị nwere ike iche n'echiche, ọdịiche ahụ dị ịrịba ama; Otú ọ dị, dị ka ọtụtụ ndị ọrụ nke Rocky Linux na-ahọrọ iji nkwụsi ike n'elu mbepụ ọnụ, ihe ngwọta ga-abụ iji MariaDB 10.5 nke dị ọhụrụ ma n'otu oge ahụ na-akwụsi ike ma na-enweta mmezi ahụhụ na mmelite nche.

Mbụ, tọgharịa ndepụta MariaDB modul:

sudo dnf module reset mariadb

Ihe atụ mmepụta:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ụdị "Y," wee pịa "Tinye igodo" ka ịga n'ihu na nrụpụta modul.

Na-esote, mee ka MariaDB 10.5 bụrụ isi mmalite mgbe ị na-etinye MariaDB.

sudo dnf module enable mariadb:10.5

Ihe atụ mmepụta:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ụdị "Y," wee pịa "Tinye igodo" ka ịga n'ihu na modul gbanwee gaa na MariaDB 10.5.

Tinye MariaDB

Ugbu a, ọ bụ oge iji wụnye MariaDB; dabere n'ụdị ị họọrọ, nsonaazụ ya nwere ike ịdị iche, mana iwu ga-abụ otu.

sudo dnf install mariadb-server mariadb

Ihe atụ mmepụta:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ụdị "Y," wee pịa "Tinye igodo" ịga n'ihu na nwụnye.

Iji kwado nrụnye nke MariaDB yana ịlele ihe arụnyere arụnyere, pịnye iwu a:

mysql --version

Ihe atụ mmepụta:

mysql  Ver 15.1 Distrib 10.5.9-MariaDB, for Linux (x86_64) using  EditLine wrapper

Lelee ọkwa nkesa MariaDB

Ugbu a ị tinyela MariaDB, ị nwere ike nyochaa ọnọdụ nke ngwanrọ nchekwa data site na iji usoro systemctl na-esonụ:

systemctl status mariadb

Site na ndabara, ị ga-ahụ ọkwa MariaDB ka ọ kwụsịrị. Iji malite MariaDB, jiri iwu a:

sudo systemctl enable mariadb --now

Ugbu a lelee ọkwa ahụ, ma ị ga-enweta ihe ndị a:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Iji kwụsị MariaDB:

sudo systemctl stop mariadb

Iji mee ka MariaDB nwee ike na mmalite sistemụ:

sudo systemctl enable mariadb

Iji gbanyụọ MariaDB na mmalite sistemụ:

sudo systemctl disable mariadb

Ka ịmalitegharịa ọrụ MariaDB:

sudo systemctl restart mariadb

Chekwaa MariaDB site na iji script nchekwa

Mgbe ị wụnye MariaDB Ọhụrụ, ntọala ndabara ka a na-ewere dị ka adịghị ike site n'ọtụtụ ụkpụrụ ma na-ebute nchegbu maka ike ikwe ka mbubata ma ọ bụ na-erigbu ndị hackers. A ngwọta bụ na-agba ọsọ nwụnye nche script na-abịa na MariaDB ndozi.

Mbụ, jiri iwu na-esonụ iji malite (mysql_secure_installation):

sudo mysql_secure_installation

Na-esote, a ga-enye gị ngwa ngwa na-arịọ gị ka ịbanye (MariaDB mgbọrọgwụ paswọọdụ). Maka ugbu a, pịa ( Tinye) igodo ka edobeghi mgbọrọgwụ okwuntughe dị ka n'okpuru:

Ọzọ, ụdị (NA) wee pịa tinye ka ịtọlite ​​​​ (mgbọrọgwụ) paswọọdụ dị ka n'okpuru:

Usoro ajụjụ ndị ọzọ ị nwere ike ịkụ n'enweghị nsogbu ( Tinye), nke ga-aza (NA) nye ajụjụ niile na-esote nke na-ajụ gị (wepụ ndị ọrụ na-amaghị aha, gbanyụọ nbanye mgbọrọgwụ dịpụrụ adịpụ, wee wepụ nchekwa data ule). Rịba ama (NA) bụ isi, nke pụtara na ọ bụ azịza ndabara mgbe ị pịa ya ( Tinye) isi.

Ọmụmaatụ n'okpuru:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Nchịkọta nke ihe kwesịrị ka eme n'elu:

  • Ịtọ ntọala paswọọdụ maka mgbọrọgwụ akaụntụ.
  • Iwepu akaụntụ mgbọrọgwụ nke a na-enweta site na mpụga onye ọbịa mpaghara.
  • Iwepu akaụntụ onye ọrụ amaghị aha.
  • Iwepu nchekwa data ule, nke ndị ọrụ amaghị aha nwere ike ịnweta na ndabara.

Nzọụkwụ a dị mkpa maka nchekwa nchekwa data MariaDB na e kwesịghị ịgbanwe ma ọ bụ wụpụ ọ gwụla ma ịmara ihe ị na-eme.

Wụnye PHP & PHP-FPM (LEMP STACK)

Nhọrọ. Bubata ebe nchekwa PHP 8.0

Akụkụ ikpeazụ ịwụnye na nrụnye LEMP gị bụ PHP. Ị ga-achọ ịwụnye (PHP-FPM) nke dị mkpụmkpụ maka (Onye njikwa usoro FastCGI). A na-atụ aro ka ịwụnye PHP (Remi) ebe nchekwa. Maka ndị na-amaghị, Remi bụ onye na-ahụ maka mwepụta PHP na ezinụlọ Rhel.

Maka nkuzi a, anyị ga-etinye PHP 8.0 kacha ọhụrụ. Otú ọ dị, a ghaghị ịmara mgbe WordPress na-arụ ọrụ nke ọma na PHP 8.0 na elu, ụfọdụ n'ime plugins nwere ike iche nsogbu ihu, ya mere jide n'aka na ị na-etinye naanị plugins na-arụ ọrụ na emelitere nke kwesịrị ịbụ ọkọlọtọ na CMS ọ bụla. Ọ bụrụ na ị zutere nsogbu, wepụ PHP 8.0, wee jiri PHP 7.4.

Iji tinye PHP site na ebe nchekwa Remi, ị ga-achọ itinye ebe nchekwa EPEL na mmalite nkuzi. Site na ndabara, PHP 7.2 bụ nhọrọ PHP ndabara maka nrụnye ọkọlọtọ na Rocky Linux. Ndụmọdụ dị ngwa bụ iji (depụta php) iwu ka ịhụ nhọrọ dị na ndabara.

nwee (Nchekwa Remi) ya na ndi a:

sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Ọzọ dị ka ihe atụ mmepụta, pịnye (NA) wee banye ka gaba n'ihu:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ọzọ, jiri (dnf) iwu ka imelite ndepụta nchekwa gị:

sudo dnf update

Ugbu a depụta modul dị maka PHP site na iji iwu a:

sudo dnf module list php

Ị ga-enweta ihe mmepụta dị ka n'okpuru. Rịba ama (d) mkpado maka ndabere PHP ka etinyere:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Dịka ị nwere ike ịhụ n'elu, na (d) mkpado dị n'akụkụ PHP 7.2, nke ị ga-achọ ịtọgharịa ma gbanwee iji wụnye PHP 8.0 na Rocky Linux.

Ịtọgharịa ndepụta PHP dị mfe site na iwu a:

sudo dnf module list reset php

Na-esote, mee ka PHP 8.0 jiri iwu a:

sudo dnf module enable php:remi-8.0 

Mara, gị nwere ike ime PHP-7.4 site n'ịgbaso dnf modul nrụpụta iwu na iji ya dnf modul mee ka php: remi-7.4 iwu kama. ahọrọ ụdị ịchọrọ maka ngwa ahụ, nke a bụ naanị ọmụmaatụ nke ịnwe ụdị PHP kachasị ọhụrụ nke nhọrọ PHP ọ bụla ị kpebiri.

Wụnye PHP & PHP-FPM

Ọzọ, wụnye PHP na nkesa gị; dabere na ụdị nke PHP, ihe nrụpụta ga-adị iche; Otú ọ dị, iwu na-adị otu.

sudo dnf install php

Ihe atụ mmepụta:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ụdị "Y," wee pịa "Tinye igodo" ịga n'ihu na ntinye. Mara, enwere ike ịkpali gị pịnye "Y."

Nyochaa nwụnye ma lelee ụdị ma wuo:

php -v

Ihe atụ mmepụta:

PHP 8.0.11 (cli) (built: Sep 21 2021 17:07:44) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.11, Copyright (c), by Zend Technologies

Ugbu a, site na ndabara, PHP-FPM agbanyụrụ na anaghị enyere ya aka na buut. Iji mee ka boot na malite ọrụ, jiri ihe ndị a systemctl nyere iwu:

sudo systemctl enable php-fpm --now

Iji gosi na PHP-FPM na-agba ọsọ ugbu a, jiri ihe ndị a systemctl iwu:

Ihe atụ mmepụta:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Cheta, ịkwesighi iji PHP 8.0, mee nyocha ụfọdụ ma ọ bụrụ na ejighị n'aka, ma ọ bụ ka mma, jụọ na forums obodo WordPress, nke na-arụ ọrụ kacha mma ugbu a; Otú ọ dị, usoro a bụ otu ihe ahụ yana iwu iji jiri ndabara ma ọ bụ nsụgharị ọzọ dị na ndepụta dnf modul.

Ugbu a ka edobere LEMP gaba na nrụnye WordPress n'ezie.


Advertisement


Part 1. Wụnye WordPress Backend

Download WordPress

Gaa na WordPress.org download page wee gbadaa ruo mgbe ịchọtara ya "kacha ọhụrụ.zip" download njikọ. Ọ bụrụ na ị na-ebugharị na desktọpụ, ị nwere ike iji aka budata nke a ma ọ bụ jiri iwu wget budata desktọpụ gị.

wget https://wordpress.org/latest.zip

Mepụta Nhazi nchekwa maka WordPress

Ugbu a ị budatala ebe nchekwa ahụ, gaba n'ihu ịtọpụ ya ma bugharịa ya na nke gị www ndekọ.

Mepụta ndekọ aha maka WordPress:

sudo mkdir -p /var/www/html/wordpress

Wepu WordPress na ndekọ www:

sudo unzip latest.zip -d /var/www/html/

Ị ga-edozi ikike onye nwe ndekọ aha na WWW, ma ọ bụ ọzọ ị ga-enwe nsogbu na WordPress ide ikike.

Tọọ ikike chown (dị mkpa):

sudo chown -R www-data:www-data /var/www/html/wordpress/

Tọọ ikike chmod (dị mkpa):

sudo find /var/www/html/wordpress -type d -exec chmod 755 {} \;
sudo find /var/www/html/wordpress -type f -exec chmod 644 {} \;

Mepụta database maka WordPress

WordPress chọrọ nchekwa data ka ọ rụọ ọrụ ya mere ị ga-eji tinye MariaDB. Tupu ịga n'ihu, ịkwesịrị ịmepụta nchekwa data maka WordPress site na iji MariaDB. Nke mbụ, bulite console terminal wee pịnye ihe ndị a.

Weta shei MariaDB dị ka mgbọrọgwụ:

sudo mariadb -u root

Iwu ọzọ nke abụọ:

sudo mysql -u root

Ọzọ, mepụta nchekwa data. Nke a nwere ike ịbụ aha ọ bụla ịchọrọ. Maka ntuziaka, ị ga-akpọ ya "WORDPRESSDB."

Mepụta nchekwa data WordPress:

CREATE DATABASE WORDPRESSDB;

Mgbe emechara nchekwa data, ịkwesịrị ịmepụta onye ọrụ ọhụrụ maka saịtị ọhụrụ WordPress.

A na-eme nke a dị ka ihe nchebe, ya mere ọ bụla nchekwa data nwere onye ọrụ dị iche iche. Ọ bụrụ na otu aha njirimara emebiela, onye mwakpo ahụ anaghị abanye na ọdụ data weebụsaịtị ndị ọzọ.

Mepụta onye ọrụ nchekwa data WordPress:

CREATE USER 'WPUSER'@localhost IDENTIFIED BY 'PASSWORD';

Dochie WPUSER na PASSWORD na aha njirimara ma ọ bụ paswọọdụ ị chọrọ. Edetula ma mado onye ọrụ/ ngafe ndabara n'elu maka ebumnuche nchekwa.

Ugbu a kenye onye ọrụ emepụtara ọhụrụ ohere ịnweta nchekwa data webụsaịtị WordPress naanị dị ka ọ dị n'okpuru.

Kenye nchekwa data na akaụntụ onye ọrụ WordPress emepụtara:

GRANT ALL PRIVILEGES ON WORDPRESSDB.* TO WPUSER@localhost IDENTIFIED BY 'PASSWORD';

Na ntọala nhazi nchekwa data niile zuru oke, ịkwesịrị ikpochapụ ohere ndị ahụ iji mee ihe wee pụọ.

Wepu ihe ùgwù ime mgbanwe dị ndụ:

FLUSH PRIVILEGES;

Wepụ MariaDB:

EXIT;

Tọọ faịlụ nhazi WordPress

Ịkwesịrị ịtọ ntọala ụfọdụ na "WP-config-sample.php" faịlụ. N'okpuru ebe a, ị ga-ahụ ka ị ga-esi nyegharịa faịlụ nlele aha wee tinye ozi achọrọ.

Mbụ, nyegharịa faịlụ nhazi aha.

Gaa na ndekọ ndekọ WordPress:

cd /var/www/html/wordpress/

Nyegharịa faịlụ nhazi aha:

sudo mv wp-config-sample.php wp-config.php

Ugbu a, na-eji editọ ederede, weta faịlụ wp-config.php akpọgharịrị ọhụrụ. N'ihe atụ anyị, anyị ga-eji nano.

sudo nano wp-config.php

Ọzọ, ị ga-abanye aha nchekwa data, akaụntụ onye ọrụ na paswọọdụ, adreesị IP nnabata ma ọ bụrụ na ọ dị iche na localhost.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */ 
define( 'DB_NAME', 'wordpressdb' );
/* MySQL database username */ 
define( 'DB_USER', 'wpuser1' );
/* MySQL database password */
define( 'DB_PASSWORD', 'YOUR PASSWORD' );
/* MySQL hostname, change the IP here if external DB set up */ 
define( 'DB_HOST', 'localhost' );
/* Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/* The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

Mgbe ị nọ na faịlụ a, ịgbakwunye ntọala ndị ọzọ ga-eme ka WordPress gị dịkwuo mfe ijikwa, dị ka ịchekwa faịlụ ozugbo kama iji FTP na ụbara oke oke ebe nchekwa.

##Save files direct method##
 define( 'FS_METHOD', 'direct' );

##Increase memory limit, 256MB is recommended##
 define('WP_MEMORY_LIMIT', '256M');

##change Wordpress database table prefix if wanted##
 $table_prefix = 'wp_';

Tọọ igodo nnu nchekwa WordPress

Ọ ga-akacha mma ma ọ bụrụ na ị gaa na WordPress nzuzo API API iji mepụta nke gị. Enwere ike ịchọta generator nnu igodo na https://api.wordpress.org/secret-key/1.1/salt/. Dochie ahịrị ihe atụ na koodu sitere na generator.

Edepụtaghachila Ọmụmaatụ N'okpuru, Ọ BỤ naanị maka ntụaka.

define('AUTH_KEY',         '<3yfS7/>%m.Tl^8Wx-Y8-|T77WRK[p>(PtH6V]Dl69^<8|K86[_Z},+THZ25+nJG');
define('SECURE_AUTH_KEY',  'bN#Qy#ChBX#Y`PE/_0N42zxgLD|5XpU[mu.n&:t4q~hg<UP/b8+xFTly_b}f]M;!');
define('LOGGED_IN_KEY',    'owpvIO-+WLG|,1)CQl*%gP1uDp}s(jUbYQ[Wm){O(x@sJ#T}tOTP&UOfk|wYsj5$');
define('NONCE_KEY',        '8=Vh|V{D<>`CLoP0$H!Z3gEqf@])){L+6eGi`GAjV(Mu0YULL@sagx&cgb.QVCbi');
define('AUTH_SALT',        '%TX*X$GE-;|?<-^(+K1Un!_Y<hk-Ne2;&{c[-v!{q4&OiJjQon /SHcc/:MB}y#(');
define('SECURE_AUTH_SALT', '=zkDT_%}J4ivjjN+F}:A+s6e64[^uQ<qNO]TfHS>G0elz2B~7Nk.vRcL00cJoo7*');
define('LOGGED_IN_SALT',   '{$-o_ull4|qQ?f=8vP>Vvq8~v>g(2w12`h65ztPM(xo!Fr()5xrqy^k[E~TwI!xn');
define('NONCE_SALT',       'a1G(Q|X`eX$p%6>K:Cba!]/5MAqX+L<A4yU_&CI)*w+#ZB+*yK*u-|]X_9V;:++6');

Nhazi ngọngọ sava Nginx

Ugbu a, ị dịla njikere ịwụnye WordPress site na UI webụ. Agbanyeghị, ịkwesịrị ịhazi ngọngọ nkesa Nginx gị. Ntọala ndị dị n'okpuru dị ezigbo mkpa. Ọ ga-kwuru ka mesie mkpa nke "try_files $uri $uri/ /index.php?$args;" dị ka ọ na-abụkarị ihe esemokwu na nkuzi ndị ọzọ na-ahapụ njedebe ?$args hapụrụ, na-enye gị isi okwu ahụike saịtị na-abịa na REST API nke WordPress.

Nke mbụ, mepụta faịlụ nhazi ihe nkesa ọhụrụ site na iji iwu a dochie ihe atụ na aha ngalaba gị,

sudo nano /etc/nginx/sites-available/example.com.conf

N'okpuru bụ ihe atụ; ị nwere ike họrọ akụkụ; Otú ọ dị, na "ebe ~ \.php$" kwesịrị ịdị na faịlụ nhazi Nginx.

IHE: Jide n'aka na ịgbanwe www.example.com na example.com na mgbọrọgwụ ụzọ.

server {

  listen 80;
  listen [::]:80;
  server_name www.example.com example.com;

  root /var/www/html/wordpress;

  index index.php index.html index.htm index.nginx-debian.html;

  location / {
  try_files $uri $uri/ /index.php?$args;
 }

  location ~* /wp-sitemap.*\.xml {
    try_files $uri $uri/ /index.php$is_args$args;
  }

  client_max_body_size 100M;

	# Pass the php scripts to FastCGI server specified in upstream declaration.
 location ~ \.php(/|$) {
   include fastcgi.conf;
   fastcgi_pass unix:/run/php-fpm/www.sock;
   fastcgi_split_path_info ^(.+\.php)(/.*)$;
   fastcgi_param PATH_INFO $fastcgi_path_info;
   fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
   fastcgi_param DOCUMENT_ROOT $realpath_root;
   try_files $uri $uri/ /app.php$is_args$args;
   fastcgi_intercept_errors on;	
 }

 gzip on; 
 gzip_comp_level 6;
 gzip_min_length 1000;
 gzip_proxied any;
 gzip_disable "msie6";
 gzip_types
     application/atom+xml
     application/geo+json
     application/javascript
     application/x-javascript
     application/json
     application/ld+json
     application/manifest+json
     application/rdf+xml
     application/rss+xml
     application/xhtml+xml
     application/xml
     font/eot
     font/otf
     font/ttf
     image/svg+xml
     text/css
     text/javascript
     text/plain
     text/xml;

  # assets, media
  location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
      expires    90d;
      access_log off;
  }
  
  # svg, fonts
  location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
      add_header Access-Control-Allow-Origin "*";
      expires    90d;
      access_log off;
  }

  location ~ /\.ht {
      access_log off;
      log_not_found off;
      deny all;
  }
}

Mara, ọ bụrụ na ị na-eji PHP 8.0 chọta ma dochie ahịrị dị n'elu "fastcgi_pass unix:/run/php/php7.4-fpm.sock;" na "fastcgi_pass unix:/run/php/php8.0-fpm.sock;".

Na-esote, ị ga-achọ ime ka Nginx nhazi faịlụ site na "saịtị-dị." Iji mee nke a, ị ga-emepụta symlink ka "Saịtị kwadoro" dị ka ndị a.

sudo ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled/

Dị njikere iji dochie “ihe atụ. conf" na aha faịlụ nhazi gị.

Ugbu a ị nwere ike ịme ọsọ akọrọ wee malitegharịa ihe nkesa Nginx gị ma ọ bụrụ na ihe niile dị mma.

sudo nginx -t

Mgbe ịlele na ihe niile dị mma na Nginx dry run test gị, malitegharịa ọrụ Nginx.

sudo systemctl restart nginx

Nhazi PHP.ini

Iji wụnye WordPress nke ọma ma rụọ ọrụ nke ọma n'ọdịnihu, ị kwesịrị ịbawanye nhọrọ ole na ole na faịlụ nhazi php.ini.

Nke mbụ, mepee faịlụ php.ini:

sudo nano /etc/php.ini

Na-esote, ị ga-ahụ ntọala akwadoro iji rụọ ọrụ na ọtụtụ nrụnye WordPress, gbanwee ha ka ịchọrọ ka ọ dabara na ngwaike na akụrụngwa nke ihe nkesa gị.

Ị ga-achọ ịchọta ntọala na ahịrị ma gbanwee ha ka ọ bụrụ ndị a:

max_execution_time = 180 (located on line 338)
max_input_time = 90 (located on line 398)
memory_limit = 256M (located on line 409)
upload_max_filesize = 64M (located on line 846)

Nhọrọ, ụfọdụ ntọala nchekwa abawanyela, enwere ike ịwụpụ nke a:

cgi.fix_pathinfo=0 
session.use_strict_mode = 1
session.use_cookies = 1
session.cookie_secure = 1
session.use_only_cookies = 1
session.name = LCCookies (Change the name, example: POPme)
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain = example.com (example only)
session.cookie_httponly = 1
session.cookie_samesite = Strict

Ozugbo emere, CTRL + O ịzọpụta mgbe ahụ CTRL + X ịpụ na faịlụ.

N'adịghị ka nrụnye LEMP na Debian/Ubuntu na-eji (www-data) onye ọrụ, nke a abụghị ikpe maka nrụnye Rhel/Rocky Linux. Site na ndabara na Rocky Linux, a haziri ọrụ PHP-FPM ka ọ na-agba ọsọ (apache) onye ọrụ, nke ezighi ezi ebe ọ bụ na anyị na-eji Nginx, nke a kwesịrị ka edozi ya.

Nke mbụ, meghere ndị a (www.conf) nhazi faịlụ:

sudo nano /etc/php-fpm.d/www.conf

Na-esote, dochie (apache) onye ọrụ na otu na (Nginx) onye ọrụ na otu:

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ka ịchekwaa, pịa (CTRL+O) wee pụọ (CTRL+X).

Ị ga-achọ ịmalitegharị PHP ka mgbanwe ndị a na-arụ ọrụ:

sudo systemctl restart php-fpm

Mepee ngọngọ sava gị:

sudo nano /etc/nginx/sites-available/example.com

Hazie ahịrị a ka iwelie nha ahụ:

client_max_body_size 100M;

Cheta, debe max nke onye ahịa ka nke gị max size ntọala faịlụ PHP.

Na-esote, nwalee mgbanwe ndị ahụ, malitegharịa ihe nkesa Nginx gị ma ọ bụrụ na ihe niile dị mma.

sudo nginx -t

Mmepụta ihe atụ ma ọ bụrụ na ihe niile na-arụ ọrụ nke ọma:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Mgbe ịlele na ihe niile dị mma na Nginx dry run test gị, malitegharịa ọrụ Nginx.

sudo systemctl restart nginx

Advertisement


Part 2. Wụnye WordPress Frontend

Ugbu a na ntọala ndabere na nhazi niile zuru oke, ị nwere ike ịga na ngalaba gị wee malite ịwụnye.

##go to installation address##
 https://www.yoursite.com
##alternative url##
 https://www.yoursite.com/wp-admin/install.php

Ibe mbụ ị ga-ahụ bụ ịmepụta aha njirimara na paswọọdụ yana ụfọdụ nkọwa saịtị. Nke a ga-abụ akaụntụ nbanye admin gị n'ọdịnihu. Ị nwekwara ike ịgbanwe nke a ma emechaa.

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ọ bụrụ na ị na-ewu weebụsaịtị, na-enyere "na-akụda ngwa nchọta ike ka ha ghara itinye aha" na-egbochi Google ma ọ bụ Bing ma ọ bụ ihe ọ bụla ọzọ "Ezigbo search engine bot" site na ntinye aha webụsaịtị WIP. Ozugbo emechara, ị ga-eji nbanye bịa na ihuenyo ọzọ.

Otu esi etinye WordPress na LEMP (Nginx, MariaDB, na PHP) na Rocky Linux 8

Ekele, ị tinyela ụdị WordPress ọhụrụ nke ọma na Nginx site na iji nchịkọta LEMP.

Chekwaa Nginx na ka anyị zoo SSL Asambodo efu

Dị ka o kwesịrị, ị ga-achọ ịgba ọsọ Nginx gị HTTPS na-eji asambodo SSL. Ụzọ kacha mma isi mee nke a bụ iji Ka anyị zoo, ikike asambodo efu, akpaaka na mepere emepe nke ndị Otu nyocha nchekwa ịntanetị anaghị akwụ ụgwọ (ISRG).

Mbụ, wụnye EPEL ebe nchekwa na mod_ssl ngwugwu maka ngwungwu emelitere nke ọma na nchekwa.

sudo dnf install epel-release mod_ssl -y

Na-esote, wụnye ngwugwu certbot dị ka ndị a:

sudo dnf install python3-certbot-nginx -y

Ozugbo arụnyere, gbanye iwu a ka ịmalite imepụta asambodo gị:

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email you@example.com -d forums.example.com

Nke a bụ ezigbo ntọala nke gụnyere ike HTTPS 301 redirects, Strict-Transport-Security nkụnye eji isi mee, na OCSP Stapling. Naanị jide n'aka na ịhazigharịa e-mail na ngalaba aha na ihe ị chọrọ.

Ugbu a URL gị ga-abụ https://www.example.com kama HTTP://www.example.com.

Rịba ama, ọ bụrụ na ị na-eji nke ochie URL HTTP, ọ ga-akpaghị aka redirect gaa na HTTPS.

Nhọrọ, ị nwere ike ịtọ ọrụ cron iji megharịa asambodo na-akpaghị aka. Certbot na-enye edemede nke na-eme nke a na-akpaghị aka, ma ị nwere ike ibu ụzọ nwalee iji jide n'aka na ihe niile na-arụ ọrụ site na ịme ọkụ ọkụ.

sudo certbot renew --dry-run

Ọ bụrụ na ihe niile na-arụ ọrụ, mepee windo crontab gị site na iji iwu njedebe na-esote.

sudo crontab -e

Na-esote, kọwaa oge mgbe ọ ga-emeghari onwe ya. Ekwesịrị ịlele nke a kwa ụbọchị na opekempe, ma ọ bụrụ na achọrọ ka emegharịa asambodo ahụ, edemede ahụ agaghị emelite asambodo ahụ. Ọ bụrụ na ịchọrọ enyemaka na ịchọta ezigbo oge ịtọ, jiri ya crontab.guru ngwá ọrụ efu.

00 00 */1 * * /usr/sbin/certbot-auto renew

Save (CTRL+O) wee pụọ (CTRL+X), na cronjob ga-enyere aka na-akpaghị aka.


Advertisement


Okwu na mmechi

WordPress na-enye ikike dị egwu ịmepụta weebụsaịtị ngwa ngwa nwere ndebiri na plugins. Ụlọ ahịa ngwa mgbakwunye na-akwado oke nhọrọ. Agbanyeghị, iji meghee ikike nke ọtụtụ isiokwu na mgbakwunye, ha niile bụ ụgwọ akwụ ụgwọ, mana ọtụtụ dị ọnụ ala.

WordPress nnabata nke onwe bụ ihe na-atọ ụtọ. Agbanyeghị, ijide n'aka na ị na-echekwa nchekwa na imelite dị mkpa. WordPress bụ CMS kachasị lekwasịrị anya n'ụwa site n'aka ndị na-awakpo, na saịtị gị, n'ụbọchị mbụ ya na-enweghị edepụta aha ga-enyocha ya maka nrigbu, na mbọ ike ga-amalite.

Ahapụ a Comment