Umhlahlandlela wokufakwa kwe-PHP ku-Ubuntu Server

Pin
Send
Share
Send

Abathuthukisi be-Web application bangaba nobunzima bokufaka ulimi lokubhala lwe-PHP ku-Ubuntu Server. Lokhu kungenxa yezizathu eziningi. Kodwa ngokusebenzisa lo mhlahlandlela, wonke umuntu uzokwazi ukugwema amaphutha ngesikhathi sokufakwa.

Ukufaka i-PHP ku-Ubuntu Server

Ukufaka ulimi lwe-PHP ku-Ubuntu Server kungenziwa ngezindlela ezihlukile - konke kuya ngohlobo lwayo nenguqulo yohlelo lokusebenza uqobo. Futhi umehluko omkhulu ulele emaqenjini uqobo, azodinga ukwenziwa.

Kuyaqapheleka futhi ukuthi iphakethe le-PHP lifaka izinto eziningana, uma zifunwa, ezifakiwe ngokuhlukile komunye nomunye.

Indlela yoku-1: Ukufakwa okujwayelekile

Ukufakwa okujwayelekile kubandakanya ukusebenzisa inguqulo yakamuva yephakheji. Kuhlelo ngalunye olusebenzayo lwe-Ubuntu Server, yehlukile:

  • I-12.04 LTS (Isichotho) - 5.3;
  • I-14.04 LTS (iTrusty) - 5.5;
  • 15.10 (Wily) - 5.6;
  • I-16.04 LTS (Xenial) - 7.0.

Wonke amaphakheji asatshalaliswa ngokugcinwa okusemthethweni kohlelo lokusebenza, ngakho-ke awudingi ukuxhuma umuntu wesithathu. Kepha ukufakwa kwephakeji egcwele kwenziwa ngezinhlobo ezimbili futhi kuya ngohlobo lwe-OS. Ngakho-ke, ukufaka i-PHP ku-Ubuntu Server 16.04, sebenzisa lo myalo:

sudo apt-get ukufaka php

Futhi ngohlobo lwangaphambilini:

sudo apt-get ukufaka php5

Uma ungazidingi zonke izingxenye zephakeji ye-PHP ohlelweni, ungazifaka ngokuhlukile. Ungakwenza kanjani lokhu nokuthi yini imiyalo yokwenza lokhu kufanele ichazwe ngezansi.

Imodyuli ye-Apache HTTP Server

Ukufaka imodyuli ye-PHP ye-Apache ku-Ubuntu Server 16.04, udinga ukusebenzisa umyalo olandelayo:

sudo apt-get put libapache2-mod-php

Ezinguqulweni zangaphambilini ze-OS:

sudo apt-get put libapache2-mod-php5

Uzocelwa iphasiwedi, ngemuva kokufaka lapho kufanele unikeze imvume yokuyifaka. Ukuze wenze lokhu, faka incwadi D noma "Y" (kuya ngokuya kwendawo ye-Ubuntu Server) bese uqhafaza Ngena.

Okusele nje ukulinda ukulanda nokufakwa kwephakeji ukuqeda.

I-FPM

Ukufaka i-FPM kunguqulo yokusebenza kwesistimu 16.04, yenza okulandelayo:

sudo apt-get ukufaka php-fpm

Ezinguqulweni zangaphambili:

sudo apt-get ukufaka php5-fpm

Kulokhu, ukufakwa kuzoqala ngokuzenzakalelayo, ngokushesha ngemuva kokufaka iphasiwedi ye-superuser.

I-CLI

I-CLI iyadingeka konjiniyela abakha izinhlelo zekhonsoli ku-PHP. Ukuze usebenzise lolu limi lohlelo kulo, ku-Ubuntu 16.04 udinga ukusebenzisa umyalo:

sudo apt-get ukufaka i-php-tle

Ezinguqulweni zangaphambili:

sudo apt-get ukufaka php5-khungu

Izandiso ze-PHP

Ukuze usebenzise yonke imisebenzi ekhona ye-PHP, kufanelekile ukufaka izandiso eziningi zezinhlelo ezisetshenzisiwe. Manje imiyalo ethandwa kakhulu yokufakwa okunjalo izokwethulwa.

Qaphela: ngezansi, kuzonikezwa imiyalo emibili ekunwetshisweni ngakunye, lapho owokuqala ungowe-Ubuntu Server 16.04, kanti owesibili ungowezihumusho zangaphambilini ze-OS.

  1. Isandiso se-GD:

    sudo apt-get ukufaka i-php-gd
    sudo apt-get ukufaka php5-gd

  2. Isandiso seMcrypt:

    sudo apt-get ufake php-mcrypt
    sudo apt-get ufake php5-mcrypt

  3. Isandiso se-MySQL:

    sudo apt-get ukufaka i-php-mysql
    sudo apt-get ukufaka php5-mysql

Bheka futhi: Umhlahlandlela wokufakwa kwe-MySQL ku-Ubuntu

Indlela 2: Faka Ezinye Izindima

Kwathiwa ngaphezulu ukuthi ohlotsheni ngalunye lwe-Ubuntu Server kuzofakwa iphakethe elihambisanayo le-PHP. Kepha lokhu akukubeki phansi amandla okufaka uhlobo lwangaphambilini noma, ngakolunye uhlangothi, inguqulo yakamuva yolimi lohlelo.

  1. Okokuqala udinga ukususa zonke izinto ze-PHP ezazifakwe phambilini kohlelo. Ukuze wenze lokhu, ku-Ubuntu 16.04, sebenzisa imiyalo emibili:

    sudo apt-get ukususa libapache2-mod-php php-fpm php-g php-mcrypt php-mysql
    sudo apt-Get autoremove

    Ezinguqulweni zangaphambilini ze-OS:

    sudo apt-get ukususa libapache2-mod-php5 php5-fpm php5-khungu php5-gd php5-mcrypt php5-mysql
    sudo apt-Get autoremove

  2. Manje udinga ukwengeza i-PPA ohlwini lwezindawo zokugcina, eziqukethe amaphakheji wazo zonke izinhlobo ze-PHP:

    pudo senge-apt-repository ppa: ondrej / php
    ukuvuselelwa kwesudo

  3. Ngalesi sikhathi, ungafaka iphakethe eligcwele le-PHP. Ukuze wenze lokhu, chaza uhlobo kumyalo uqobo, ngokwesibonelo "5.6":

    sudo apt-get ukufaka php5.6

Uma ungadingi iphakheji ephelele, ungafaka amamojula ngokuhlukile ngokukhetha imiyalo edingekayo:

sudo apt-get put libapache2-mod-php5.6
sudo apt-get ukufaka php5.6-fpm
sudo apt-get ukufaka php5.6-с
sudo apt-get ukufaka i-php-gd
sudo apt-get ukufaka php5.6-mbstring
sudo apt-get ukufaka php5.6-mcrypt
sudo apt-get ukufaka php5.6-mysql
sudo apt-get ukufaka php5.6-xml

Isiphetho

Ekuphetheni, singasho ukuthi, ngisho nokuba nolwazi oluyisisekelo ngokusebenza ekhompyutheni, umsebenzisi angakwazi ukufaka kalula iphakheji eyinhloko ye-PHP nazo zonke izinto zayo ezengeziwe. Into esemqoka ukwazi imiyalo edinga ukuqhutshwa ku-Ubuntu Server.

Pin
Send
Share
Send