centos7 安裝php7

How to Install PHP 7 on CentOS 7 (Red Hat/Fedora family)

PHP 7 brings such profound improvements that the lucky 7 as a version number seems more than justified. The upgrade is easy, painless, and takes just a couple of quick steps. Here is how to do it.

#PHP 7.0.1 released, RPMs already available in #remirepo 4 #fedora #rhel & #centos via…

CLICK TO TWEET

ADVANCE WARNING: RedHat intends to transition theRHEL/Fedorafamily from the popular package?manageryumto its next iteration,DNF(dnf), short fordandified yum. It supportsRPM,libsolv, andhawkeylibraries. DNF (which inherited some qualities from both yum and aptitude) has been released forFedorawithuser and admin guidesalready up to date, so feel free to get acquainted with it. Use it the way you would work with yum.Iforwhenthis change may?impactCentOSorAmazon Linuxisn’t clear yet.?You can enable DNF in Fedora 18 and later, then install the binary using good old-fashioned yum; for other distributions you have tocompile DNF from source.

To get your hands on a working installation of PHP 7, you can use either the old yum or dnf (when in doubt, consult thecommand reference).

In Remi’s RPM repository, PHP RPMs have been renamed php70 in order to allow installation alongside the default PHP of your CentOS/RHEL/Fedora (if there is one on your system). The?FPM service (php70-php-fpm) listens on the default port 9000 so it may need adjusting should another version of PHP be already running.

Follow these steps to install PHP 7 on CentOS with php-fpm, the server API or SAPI of choice for NGINX, using the Remi repository, on?x86_64.?You must be?root?(sudo su, otherwise prepend the relevant commands withsudoto execute them as root).

Step 1. Get yourself the REMI?repo

Install the Remi repository (#remirepo for #fedora, #rhel and #centos) with these commands (you must be?root, see the paragraph above):

wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm

sudo rpm -Uvh remi-release-7*.rpm

Step 2. Install PHP 7

Install PHP 7 from the remi repository:

yum --enablerepo=remi-php70 install php70-php

Step 3. Install PHP?extensions

Install PHP modules using?the remi repository (the example is a recommended configuration):

yum --enablerepo=remi-php70 install php70-php-pear php70-php-bcmath php70-php-pecl-jsond-devel php70-php-mysqlnd php70-php-gd php70-php-common php70-php-fpm php70-php-intl php70-php-cli php70-php php70-php-xml php70-php-opcache php70-php-pecl-apcu php70-php-pecl-jsond php70-php-pdo php70-php-gmp php70-php-process php70-php-pecl-imagick php70-php-devel php70-php-mbstring php70-php-mcrypt

To find out which other extensions are available, use search with?yum:

yum search php70

Speaking of extensions: ereg, mssql, sybase_ct and?mysql have been removed from PHP.

In order to enable the remi repository only during software installation (that is: only when you need it), use the–enablerepo=remioption with yum. For example like this:

sudo yum --enablerepo=remi install php-tcpdf

To update your already installed packages using the Remi repository, you would?enter this command:

yum --enablerepo=remi update remi-release

Step 4. Start PHP

To start PHP (once) use this command:

service php70-php-fpm start

or

systemctl start php70-php-fpm

Step 5.?Enable automatic launch of PHP 7 on system startup

Enable automatic launch of the PHP interpreter on system startup on CentOS 7/Red Hat/Fedora, use this command:

systemctl enable php70-php-fpm

The?output of this command should resemble this line:

ln -s '/usr/lib/systemd/system/php70-php-fpm.service' '/etc/systemd/system/multi-user.target.wants/php70-php-fpm.service'

You can?verify the current status of PHP 7 using this command:

systemctl status php70-php-fpm

[root@ip-16-0-0-170 centos]# systemctl status php70-php-fpm

php70-php-fpm.service - The PHP FastCGI Process Manager

Loaded: loaded (/usr/lib/systemd/system/php70-php-fpm.service; enabled)

Active: active (running) since Thu 2015-12-10 05:29:25 UTC; 2s ago

Main PID: 2102 (php-fpm)

Status: "Ready to handle connections"

CGroup: /system.slice/php70-php-fpm.service

├─2102 php-fpm: master process (/etc/opt/remi/php70/php-fpm.conf)

├─2103 php-fpm: pool www

├─2104 php-fpm: pool www

├─2105 php-fpm: pool www

├─2106 php-fpm: pool www

└─2107 php-fpm: pool www

Dec 10 05:29:25 ip-12-3-4-170.ec2.internal systemd[1]: Started The PHP FastCGI Process Manager.

This output also shows you that php-fpm pools, while running, have not been configured yet.

If you also want to set up?MySQL/MariaDB,?you may want to read this post:High-Stakes, High-Security LEMP Setup: Nginx with MariaDB/MySQL, and PHP 7.x on CentOS 7 (RHEL/Fedora) with SELinux

Subscribe to our newsletter and we will keep you up to date.

來(lái)源:https://www.cloudinsidr.com/content/how-to-install-php-7-on-centos-7-red-hat-rhel-7-fedora/

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末呼盆,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子常遂,更是在濱河造成了極大的恐慌,老刑警劉巖克胳,帶你破解...
    沈念sama閱讀 211,042評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件漠另,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡笆搓,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 89,996評(píng)論 2 384
  • 文/潘曉璐 我一進(jìn)店門(mén)肤频,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)算墨,“玉大人,你說(shuō)我怎么就攤上這事净嘀⊥诓兀” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 156,674評(píng)論 0 345
  • 文/不壞的土叔 我叫張陵膜眠,是天一觀的道長(zhǎng)宵膨。 經(jīng)常有香客問(wèn)我,道長(zhǎng)柄驻,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,340評(píng)論 1 283
  • 正文 為了忘掉前任抑钟,我火速辦了婚禮野哭,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘拨黔。我一直安慰自己,他們只是感情好贺待,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,404評(píng)論 5 384
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著秃臣,像睡著了一般哪工。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上雁比,一...
    開(kāi)封第一講書(shū)人閱讀 49,749評(píng)論 1 289
  • 那天偎捎,我揣著相機(jī)與錄音,去河邊找鬼鸭限。 笑死两踏,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的赡麦。 我是一名探鬼主播帕识,決...
    沈念sama閱讀 38,902評(píng)論 3 405
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼肮疗!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起们衙,我...
    開(kāi)封第一講書(shū)人閱讀 37,662評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤碱呼,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后忆蚀,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,110評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡男旗,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,451評(píng)論 2 325
  • 正文 我和宋清朗相戀三年桃焕,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片让网。...
    茶點(diǎn)故事閱讀 38,577評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡师痕,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出胰坟,到底是詐尸還是另有隱情,我是刑警寧澤竞滓,帶...
    沈念sama閱讀 34,258評(píng)論 4 328
  • 正文 年R本政府宣布吹缔,位于F島的核電站,受9級(jí)特大地震影響茶没,放射性物質(zhì)發(fā)生泄漏晚碾。R本人自食惡果不足惜抓半,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,848評(píng)論 3 312
  • 文/蒙蒙 一笛求、第九天 我趴在偏房一處隱蔽的房頂上張望糕簿。 院中可真熱鬧,春花似錦冶伞、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,726評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)隆嗅。三九已至,卻和暖如春泡躯,著一層夾襖步出監(jiān)牢的瞬間丽焊,已是汗流浹背较剃。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 31,952評(píng)論 1 264
  • 我被黑心中介騙來(lái)泰國(guó)打工写穴, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留雌贱,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,271評(píng)論 2 360
  • 正文 我出身青樓馋没,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親篷朵。 傳聞我的和親對(duì)象是個(gè)殘疾皇子搬瑰,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,452評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容