Otu esi etinye WordPress na Ubuntu 20.04 Nginx MariaDB PHP7.4

WordPress bụ usoro njikwa ọdịnaya kachasị nke edere na PHP, jikọtara ya na MySQL ma ọ bụ nchekwa data MariaDB. WordPress na-eji 64.9%, dị ka W3Tech si kwuo. WordPress na-abịa na nsụgharị abụọ: isi mmalite mepere emepe 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.

Ntuziaka ahụ ga-ekwu maka ịwụnye ụdị WordPress.org nke nwere onwe ya na Nginx, MariaDB 10.3+, na PHP 7.4+ (LEMP) na Ubuntu 20.04 LTS.

Prerequisites

  • Ubuntu 20.04 OS (20.10 na 21.04 nwere ike iji)
  • Melite ngwungwu sistemụ ụbọchị
  • Nweta mgbọrọgwụ ma ọ bụ ikike sudo.
  • Awụnyere ngwugwu LEMP (Nginx, MariaDB 10.3+ na PHP7.4+)
  • Wepu ya na Wget ngwugwu arụnyere.

Melite sistemụ Ubuntu gị:

sudo apt update && sudo apt upgrade -y

Wụnye unzip na wget chọrọ:

sudo apt install unzip wget

Wụnye ngwugwu PHP chọrọ:

sudo apt install php-imagick php7.4-fpm php7.4-mbstring php7.4-bcmath php7.4-xml php7.4-mysql php7.4-common php7.4-gd php7.4-json php7.4-cli php7.4-curl php7.4-zip php7.4-gd

Advertisement


Download WordPress

Gaa na WordPress.org download page wee gbadaa ruo mgbe ịchọtara "kacha ọhụrụ.zip” download njikọ. Ị nwere ike iji aka budata nke a ma ọ bụrụ na ị na-akwado na desktọpụ ma ọ bụ jiri wget iwu budata ọdụ desktọpụ CTRL + ALT + T.

Nbudata njedebe:

wget https://wordpress.org/latest.zip
budata wordpress wee wụnye na nginx na ubuntu

Mepụta Nhazi nchekwa maka WordPress

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

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/wordpress/

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

Tọọ ikike chown:

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

Advertisement


Mepụta database maka WordPress

Tupu ịga n'ihu, ịkwesịrị ịmepụta nchekwa data maka WordPress site na iji MariaDB. Nke mbụ, bulite ihe njikwa ọnụ CLTR+ALT+T 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 'wpuser1'@localhost IDENTIFIED BY 'password1';

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 wpuser1@localhost IDENTIFIED BY 'password1';

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

Ghichaa ihe ùgwù ime 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, ịgbakwụnye ụfọdụ ntọala ga-eme ka WordPress gị dị mfe ijikwa, dị ka ịchekwa faịlụ ozugbo kama iji FTP na oke oke ebe nchekwa mụbara.

##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_';

##set cache enabled, this if you intend to use WordPress add-ons##
 define('WP_CACHE', true);

Advertisement


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',         '3Bvek7XZW6j_61C-18tMS&7=SYPyF#cl%zxA$s)^Ox<w8eiLyBu4~p:{Y?u$3$');
define('SECURE_AUTH_KEY',  '&Uc|]gsVp@sv:$CaFUf-5`uNOhFIo>>3Xt3-bUJi=P}EXgL*~YF;2d(URRSmn<,@');
define('LOGGED_IN_KEY',    'NPBT-rd1;D,|fi+MCd!zaX-1ploOT}e! L{6ya-W|r.H(sT/ja&8C2rs=]-.8%');
 define('NONCE_KEY',        'I8d[0k&Q Q6K9h>8u+TvD`X^k4=dZZQpy+kXMZ8,u^z*F|Vxrqw0ZE{G+HzjrBVg');
define('AUTH_SALT',        'yz%>r)>WbnCJa?.y&qk<)U&0rm8>t');
 define('LOGGED_IN_SALT',   'z-h/xg=VDXcemo9@yPXE.Yx3oWbEez@:<|N,&u}^,Qi6Bp&q8h+7X:3}VE$H1E'); define('NONCE_SALT',       'QGa-J8n =QxlybzS#ela=]LapL5QYhvIJ`A$-Rivj{Y+m=b#! r]-]H2|#,');

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. Ụfọdụ ntuziaka anaghị emesi mkpa ọ dị “try_files $ uri $ uri / /index.php?$args;"Ha na-ahapụkarị njedebe ?$args hapụrụ, na-enye gị isi okwu ahụike saịtị na-abịa na REST API nke WordPress.

Debe ntọala ndị a n'usoro dịka o kwere mee na ngọngọ nkesa gị.

location / {
### First attempt to serve request as file, then ###
### as directory, then fall back to index.php ###
 try_files $uri $uri/ /index.php?$args;
 }

### Pass the PHP scripts to PHP-FPM listening on 127.0.0.1:9000 ###
 location ~ .php$ {
  try_files $uri =404;
  fastcgi_split_path_info ^(.+.php)(/.+)$;
  fastcgi_pass unix:/run/php/php7.4-fpm.sock;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  fastcgi_index index.php;
  include fastcgi_params;
  fastcgi_intercept_errors on; 

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

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

Advertisement


Nhazi PHP.ini

Tupu ịkwaga na akụkụ nrụnye UI webụ, ị kwesịrị ịhazi PHP gị maka ojiji kacha mma maka WordPress. Ntọala ndị a bụ ntụzịaka karịa. Ị nwere ike ịba ụba, belata ka ọ dị gị mma.

Mbụ, weta php.ini gị. Rịba ama na ọnọdụ gị nwere ike ịdị iche dabere na nọmba ụdị PHP ị nwere.

sudo nano /etc/php/7.4/fpm/php.ini

Ugbu a, faịlụ mgbasa ozi WordPress nwere ike ịdị oke mkpa. Ihe ndabara nwere ike ịdị oke ala. Ị nwere ike ịbawanye nke a ka ọ bụrụ ihe ị chere na oke faịlụ gị ga-abụ. Chọta ahịrị ndị a n'okpuru wee gbanwee ka mkpa gị dị.

##increase upload max size##
 upload_max_filesize = 10MB

##increase post max size##
 post_max_size = 10MB

Ugbu a malitegharịa sava PHP-FPM gị.

sudo systemctl restart php7.4-fpm

Ntọala PHP nke ị meziri bụ maka azụ azụ PHP. Ị ga-achọkwa ịgbanwe ngọngọ ihe nkesa Nginx iji nye ohere maka nnukwu anụ ahụ. Emere nke a site na imeghe ngọngọ nkesa gị na ịgbakwunye ahịrị ndị a.

Mepee ngọngọ sava gị:

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

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

client_max_body_size 10M;

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

Ugbu a malitegharịa ihe nkesa Nginx.

sudo systemctl restart nginx

Wụnye WordPress

Ugbu a na nhazi na nhazi azụ azụ niile zuru ezu, ị nwere ike ugbu a gaa 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.

wordpress nginx ubuntu ka esi etinye admin melite

Ọ bụrụ na ị na-ewu weebụsaịtị, na-enyere "na-akụda ngwa nchọta ike site na ntinye aha” na-egbochi Google ma ọ bụ Bing ịdepụta weebụsaịtị WIP. Ozugbo emechara, ị ga-eji nbanye bịa na ihuenyo ọzọ.

nbanye nbanye

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


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