Otu esi etinye PHP 8.0 na Ubuntu 20.04 LTS Focal Fossa

PHP bụ otu n'ime asụsụ mmemme ihe nkesa na-ewu ewu na nke a na-ejikarị eme ihe ruo taa n'ahịa. Dabere na ọnụ ọgụgụ webụsaịtị PHP, na 2021, a ga-eji ya 79.1% nke niile mara weebụsaịtị dị ka W3Tech, na mbipute 7.0 usoro na-eme ka nnukwu na 65.6% òkè ahịa. Ọtụtụ CMS na-ewu ewu na frameworks dị ka WordPress, Magento, na Laravel mmepe gụnyere ọtụtụ PHP frameworks.

Ntọhapụ PHP kacha ọhụrụ ruo taa bụ usoro 8. PHP 8 bụ mmelite dị mkpa nke asụsụ PHP. Ọ nwere ọtụtụ atụmatụ na nkwalite ọhụrụ, gụnyere arụmụka akpọrọ aha, ụdị otu, njiri mara, nkwalite ihe nrụpụta, nkwupụta egwuregwu, onye ọrụ nchekwa efu, JIT, nkwalite n'ụdị sistemu, njikwa njehie na nkwụsi ike.

Otu esi etinye PHP 8.0 na Ubuntu 20.04 LTS Focal Fossa

Kedu ihe bụ PHP?

PHP "Acronym recursive maka PHP: Hypertext Preprocessor” bụ asụsụ edemede izugbe na-emepe emepe nke dabara adaba maka mmepe webụ ma nwee ike itinye ya na HTML. Ihe dị iche na PHP na Javascript nke ndị ahịa bụ na a na-eme koodu ahụ na ihe nkesa, na-emepụta HTML, wee zigara onye ahịa ahụ. Onye ahịa ahụ ga-enweta nsonaazụ nke iji edemede ahụ eme ihe mana ọ gaghị ama koodu dị n'okpuru. Ị nwere ike hazie sava weebụ gị ka ọ hazie faịlụ HTML gị niile na PHP, mgbe ahụ ọ nweghị ụzọ ndị ọrụ nwere ike isi gwa ihe ị nwere n'aka gị.

Onye ndu anyị ga-etinye PHP 8 on Ubuntu 20.04 LTS Focal nwere nhọrọ ngwanrọ ngwa weebụ Apache na Nginx.


Advertisement


Prerequisites

  • OS akwadoro: Ubuntu 20.04
  • Akaụntụ onye ọrụ: Akaụntụ onye ọrụ nwere sudo or mgbọrọgwụ ohere.

Melite Sistemụ Ọrụ

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

sudo apt update && sudo apt upgrade -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@ubuntu ~]$ sudo whoami
root

Ka ịtọlite ​​akaụntụ sudo dị adị ma ọ bụ ọhụrụ, gaa na nkuzi anyị na na-agbakwunye onye ọrụ na Sudoers na Ubuntu.

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

su

Bubata Ondřej Surý PHP PPA

Ubuntu na-akwado PHP 7.4 ugbu a. Agbanyeghị, ha nọ n'azụ na ụdị kwụsiri ike kachasị ọhụrụ na usoro 7.4 ma enweghị PHP 8 agbakwunyere na ebe nchekwa gọọmentị ha. Ị ga-achọ ịwụnye PPA gọọmentị site na Ondřej Surý, onye na-emepụta ihe na PHP na Debian, ma na-edobe ngwugwu Ubuntu na Debian. A na-emelite ebe nchekwa Ondřej kwa ọnwa yana ụdị kwụsiri ike kachasị ọhụrụ na PHP 7.4 na 8.

Na-esote, wụnye ihe achọrọ na Ondřej Surý PPA.

sudo apt install software-properties-common && sudo add-apt-repository ppa:ondrej/php -y

Ị ga-enweta ozi nwere nhọrọ ịpụ ma ọ bụ kụọ tinye, wee pịa tinye igodo n'ihi na nke a bụ ebe nchekwa nchekwa ama ama. Site ugbu a gaa n'ihu, mmelite PHP gị niile ga-esi na ebe nchekwa a, ma ị nwere ike ịga n'ihu ịwụnye PHP 8.0.

Ozugbo emechara, ọ bụ ezigbo echiche ịmeghachi ebe nchekwa APT gị ka PPA nwere ike iweta nkwalite ndị ọzọ na ndabere ndị dị adị.

sudo apt update

Na-esote, kwalite ngwungwu ọ bụla chọrọ ya.

sudo apt upgrade -y

Advertisement


Wụnye PHP 8.0 na Nhọrọ Apache

Ọ bụrụ na ị na-agba ọsọ Ihe nkesa HTTP Apache, ị nwere ike Gbaa PHP dị ka modul Apache or PHP-FPM.

Wụnye modul Apache

Iji tinye PHP 8 dị ka modul Apache, tinye iwu a.

sudo apt update && sudo apt install php8.0 libapache2-mod-php8.0

Ozugbo echichi mechara, malitegharịa ihe nkesa Apache gị maka ibunye modul PHP ọhụrụ.

sudo systemctl restart apache2

Wụnye Apache na PHP-FPM

PHP-FPM (acronym nke FastCGI Process Manager) bụ PHP ọzọ na-ewu ewu (Ihe nhazi Hypertext) FastCGI mmejuputa.

Iji tinye iwu PHP-FPM.

sudo apt update && sudo apt install php8.0-fpm libapache2-mod-fcgid

Mara, na ndabara, PHP-FPM adịghị enyere Apache aka. Ị ga-emerịrị ya site n'iwu a.

sudo a2enmod proxy_fcgi setenvif && sudo a2enconf php8.0-fpm

N'ikpeazụ, malitegharịa Apache.

systemctl restart apache2

Chọpụta na PHP-FPM na-arụ ọrụ:

sudo systemctl status php8.0-fpm

Ihe atụ mmepụta:

Otu esi etinye PHP 8.0 na Ubuntu 20.04 LTS Focal Fossa

Wụnye PHP 8.0 na nhọrọ Nginx

Nginx enweghị nhazi PHP nke ala dịka ụfọdụ sava weebụ ndị ọzọ dị ka Apache. Ị ga-achọ ịwụnye PHP-FPM "onye njikwa usoro fastCGI" ijikwa faịlụ PHP.

Mbụ, lelee maka mmelite na sistemụ gị wee wụnye PHP-FPM, na-etinye ngwungwu PHP nke achọrọ. Gbaa iwu ndị a wee kụọ "Y" mgbe kpaliri.

sudo apt install php8.0-fpm php8.0-cli -y

Ozugbo etinyere ya, a ga-amalite ọrụ PHP-FPM na-akpaghị aka, ma ị nwere ike ịlele ọkwa iji hụ na ọ na-agba ọsọ.

sudo systemctl status php8.0-fpm
Otu esi etinye PHP 8.0 na Ubuntu 20.04 LTS Focal Fossa

Ị ga-achọ idezi ngọngọ nkesa Nginx gị wee gbakwunye ihe atụ n'okpuru maka Nginx iji hazie faịlụ PHP.

N'okpuru ebe a, ọmụmaatụ maka ihe nkesa niile na-edozi faịlụ PHP nke chọrọ ebe ~ .php$ gbakwunyere.

server {
 # … some other code
 location ~ .php$ {
   include snippets/fastcgi-php.conf;
   fastcgi_pass unix:/run/php/php8.0-fpm.sock;
 }

Nwalee Nginx iji jide n'aka na ị nweghị mmejọ na mgbanwe ndị e mere na koodu dị n'elu; tinye ihe ndia.

sudo nginx -t

Ihe atụ mmepụta:

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

Malitegharịa ọrụ Nginx maka nrụnye ka ọ zuru oke.

sudo systemctl restart nginx

Advertisement


Okwu na mmechi

PHP 8 bụ nkwalite karịa 7.4, yana ngwa ngwa ihe na-atọ ụtọ n'etiti ọtụtụ atụmatụ. Agbanyeghị, ị ga-amarịrị na anaghị ewere ya dị ka “ngwa ngwa tozuru oke” ma e jiri ya tụnyere PHP 7.4. Ị nwere ike ịhụ na ọtụtụ ngwanrọ ọkacha mmasị gị dị ka WordPress ma ọ bụ Plugins/Themes maka ngwa CMS nwere ike ịgbagha.

Mee ụfọdụ nyocha, kwadebe, ma tinye 7.4 ma dị njikere iji dochie anya ma ọ bụrụ na ihe ọ bụla na-ezighị ezi mgbe ị na-eme mgbanwe ahụ, dịka 7.4 ka na-arụsi ọrụ ike na ngwugwu na-agbanye n'otu oge yana ngwugwu 8.

Ahapụ a Comment