Isiqondiso sokufaka i-PHP se-Ubuntu Server

Abathuthukisi bezinhlelo zokusebenza zewebhu bangase babe nobunzima bokufaka ulimi lwe-PHP script ku-Ubuntu Server. Lokhu kungenxa yezici eziningi. Kodwa usebenzisa lo mhlahlandlela, wonke umuntu angazigwema amaphutha ngesikhathi sokufakwa.

Faka i-PHP ku-Ubuntu Server

Ukufaka ulimi lwe-PHP ku-Ubuntu Server kungenziwa ngezindlela ezehlukene - konke kuxhomeke kunguqulo yayo kanye nenqubo yesistimu yokusebenza uqobo. Futhi umehluko omkhulu ukhona kumaqembu ngokwawo, okuzodinga ukwenza.

Kumele futhi uqaphele ukuthi iphakheji le-PHP liqukethe izingxenye eziningana, uma zifiswa, zingafakwa ngokuhlukana komunye nomunye.

Indlela 1: Ukufakwa Okujwayelekile

Ukufaka okujwayelekile kuhilela ukusebenzisa inguqulo yakamuva yephakheji. Uhlelo lokusebenza ngalunye Ubuntu Server luhlukile:

  • 12.04 LTS (ecacile) - 5.3;
  • 14.04 LTS (Trusty) - 5.5;
  • Okthoba 15 (Wily) - 5.6;
  • 16.04 LTS (Xenial) - 7.0.

Zonke amaphakheji asakazwa nge-repository esemthethweni yesistimu yokusebenza, ngakho ngeke udinga ukuxhuma umuntu wesithathu. Kodwa ukufakwa kwephakheji eligcwele kwenziwa ngezinguquko ezimbili futhi kuxhomeke kunguqulo ye-OS. Ngakho, ukufaka i-PHP ku-Ubuntu Server 16.04, sebenzisa lo myalo:

sudo apt-get install php

Futhi ngezihumusho zangaphambili:

sudo apt-get install php5

Uma ungadingi zonke izingxenye zephakheji le-PHP ohlelweni, ungawafaka ngokwahlukana. Indlela yokwenza lokhu nokuthi yimiphi imiyalo yalokhu kudinga ukwenza, izochazwa ngezansi.

I-apache ye-Apache HTTP Yeseva

Ukufaka umthamo we-PHP we-Apache ku-Ubuntu Server 16.04, udinga ukuqhuba umyalo olandelayo:

sudo apt-get ukufaka i-libapache2-mod-php

Kuzinguqulo zangaphambili ze-OS:

sudo apt-get ukufaka i-libapache2-mod-php5

Uzocelwa iphasiwedi, ngemuva kokufaka okumele unikeze imvume yokufaka. Ukuze wenze lokhu, faka incwadi "D" noma "Y" (kuye ngokuthi indawo yangasese ye-Ubuntu Server) bese uchofoza Ngena.

Kuhlala kuphela ukulinda ukuqedelwa kwephakheji yokulanda nokufaka.

I-FPM

Ukufaka i-module ye-FPM kusihumusho se-system 16.04, yenza lokhu okulandelayo:

sudo apt-get install php-fpm

Ezinguqulo zangaphambili:

sudo uthole-get install php5-fpm

Kulesi simo, ukufakwa kuzoqala ngokuzenzakalelayo, ngokushesha ngemuva kokufaka iphasiwedi engaphezulu.

CLI

I-CLI iyadingeka kubathuthukisi abahlanganyela ekwakheni izinhlelo ze-console ku-PHP. Ukuze ungene kulolu limi lohlelo lokuhlela, ku-Ubuntu 16.04 udinga ukukhipha umyalo:

sudo apt-get install php-cli

Ezinguqulo zangaphambili:

sudo apt-get ukufaka php5-cli

Izandiso ze-PHP

Ukuze usebenzise yonke imisebenzi ekhona ye-PHP, kuyadingeka ukufaka inani lezandiso zezinhlelo ezisetshenzisiwe. Manje imiyalo ethandwa kakhulu yokwenza ukufakwa okunjalo izonikezwa.

Qaphela: okulandelayo kuzohlinzekwa isandiso ngasinye ngemilayezo emibili, lapho kuqala khona i-Ubuntu Server 16.04, futhi okwesibili kunguzinguqulo zangaphambili ze-OS.

  1. Isandiso se-GD:

    sudo apt-get install php-gd
    sudo uthole-get install php5-gd

  2. Isandiso se-Mcrypt:

    sudo apt-get install php-mcrypt
    sudo apt-get install php5-mcrypt

  3. Isandiso se-MySQL:

    sudo apt-get install php-mysql
    sudo apt-get install php5-mysql

Bheka futhi: Umhlahlandlela wokufaka i-MySQL ku-Ubuntu

Indlela 2: Faka ezinye izethulo

Kuthiwa ngenhla ukuthi iphakheji le-PHP elihambelanayo lizofakwa ku-version ngayinye ye-Ubuntu Server. Kodwa lokhu akukwenqabeli ukuthi kungenzeka ukufaka kwangaphambili noma, ngokuphambene nalokho, inguqulo kamuva yelimi lohlelo.

  1. Okokuqala udinga ukususa zonke izingxenye ze-PHP ezazifakwe ngaphambilini ohlelweni. Ukwenza lokhu ku-Ubuntu 16.04 ugijima imiyalo emibili:

    sudo apt-get ukususa libapache2-mod-php php-fpm php-cli php-gd php-mcrypt php-mysql
    I-sudo ikwazi ukuthola i-autoremove

    Kuzinguqulo zangaphambili ze-OS:

    sudo-thola ukususa i-libapache2-mod-php5 php5-fpm php5-cli php5-gd php5-mcrypt php5-mysql
    I-sudo ikwazi ukuthola i-autoremove

  2. Manje udinga ukungeza i-PPA kuhlu lwamakhompiyutha, equkethe amaphakheji azo zonke izinguqulo ze-PHP:

    I-sudo engeza-apt-repository ppa: ondrej / php
    sudo apt-get update

  3. Kuleli phuzu, ungafaka iphakheji ephelele ye-PHP. Ukwenza lokhu, eqenjini uqobo, cacisa inguqulo yayo, isibonelo, "5.6":

    sudo apt-get install php5.6

Uma ungadingi iphakethe eliphelele, ungafaka amamojula ngokwehlukana ngokwenza imiyalo edingekayo ngokukhethayo:

sudo uthole-get install libapache2-mod-php5.6
sudo uthole-get install php5.6-fpm
sudo apt-get install php5.6-cli
sudo apt-get install php-gd
sudo apt-get install php5.6-mbstring
sudo apt-get install php5.6-mcrypt
sudo uthole-get install php5.6-mysql
sudo apt-get install php5.6-xml

Isiphetho

Ekuphetheni, singakusho lokho, nokuba nolwazi oluyisisekelo lokusebenza kukhompyutha, umsebenzisi angakwazi ukufaka kalula kokubili iphakethe le-PHP eliyinhloko nazo zonke izingxenye zalo ezengeziwe. Into esemqoka ukwazi imilayezo oyidingayo ukugijima ku-Ubuntu Server.