Raspberry Pi 3 Installing PHP 7
2018-01-26 14:59
561 查看
Installing PHP 7
While the Raspberry Pi has heaps of literature and technology revolving around JavaScript, Python, and other programming languages; PHP has consumed a lot of my time these days. A year ago, I would have snubbed the idea of using PHP in lieu of JavaScript asmy go to language but I’m now seeing a lot of influences, if not mergers between the two languages: PHP has obtained a beautiful dependency/package manager (composer/packagist) that is not unlike what’s available for JavaScript via NodeJS. Programming libraries
and projects such as ReactPHP mirror their JavaScript equivalent and now we’ve seen an incredible speed boost via the release of PHP 7. According to APIPlug.com, PHP 7 has been found to be a
lot faster than its predecessor (I’m still waiting for their PHP vs NodeJS speed comparison). What better way to compliment our new Raspberry Pi 3’s quad core capabilities than with the cutting edge performance found in PHP 7? So let’s get started installing
the cutting edge PHP 7 on the new Raspberry Pi 3.
To install PHP 7, we’ll need to gain access to the testing branch of Raspberry Pi’s Raspbian OS (aka under the codename: “stretch”). Start by editing the sources.list file used by apt-get by typing the following on the command line:
sudo nano /etc/apt/sources.list
The nano editor will open and you should be able to append the following line to the file, followed by pressing ctrl+x to exit and ‘y’ to save changes and press enter to confirm.
deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi
However, this will cause all updates and installs to come from “stretch” which isn’t considered stable. To avoid this, create a preferences file that will tell apt-get to obtain all packages from the current “jessie” release of Raspian first and fallback to
“stretch” to accessing the missing PHP 7 components:
sudo nano /etc/apt/preferences
Again, the nano editor will open and you can paste the following content to prioritize where packages come from. Pressing ctrl+x exit and ‘y’ to save changes and enter to confirm.
Package: * Pin: release n=jessie Pin-Priority: 600
Next, run update to download the latest package lists and get information on the newest versions of packages.
sudo apt-get update
Lastly, we can install PHP 7 with the following command (press ‘Y’ when prompted).
sudo apt-get install -t stretch php7.0
You can now check that PHP is install and it’s version by running:
php -v
You have the latest PHP 7 installed and running on Raspberry Pi!
测试PHP页面在Apache中能否被正常解析
sudo nano /var/www/html/phpinfo.php
<?php phpinfo(); ?>
如果无法正常显示,尝试安装
sudo apt-get install php7.0 libapache2-mod-php7.0 -y
相关文章推荐
- Installing PHP and Zend Framework on Ubuntu
- CentOS - Installing Apache and PHP5
- 樹梅派 Raspberry Pi 安裝 NGINX 與 PHP 網頁伺服器(PHP-FPM)
- Installing the PHP/MongoDB extension on Mac OSX 10.8
- Simple Tutorial for installing Apache, PHP, MySQL and phpMyAdmin on Ubuntu
- Installing PostgreSQL 9.4 And phpPgAdmin In CentOS 7/6.5/6.4
- Installing Memcached for PHP 5.3 on Windows 7
- Installing PHP and the Oracle Instant Client for Linux and Windows For PHP 5.5, OCI8 2.0 and Oracle
- Raspberry Pi: Installing TightVNC
- Installing MSSQL Module for PHP on Mac OS X
- Installing Apache, PHP, and MySQL on Mac OS X
- Ultimate Guide To Installing Nginx, MySQL, PHP5, PHP-FPM In CentOS 6.5
- Installing PHP5.4 on Centos 5.8
- Installing nginx and php-fpm on Mac OSX 10.8 using ports
- PHP - Manual手册 - Function Reference函数参考 - Session Extensions会话扩展 - Session Handling会话操作 - Installing/Configuring安装/配置 - Runtime
- Installing Imagick for PHP 7(WAMP)
- 树莓派(raspberry pi) Installing ROS Indigo on Raspberry Pi
- Raspberry Pi 搭建 LAMP, Linux, Apache, MySQL, PHP web server
- Installing the PHP "memcached" Extension on OS X 10.9 Mavericks / 10.10 Yosemite / 10.11 El Capitan
- Raspberry Pi: INSTALLING OPERATING SYSTEM IMAGES ON MAC OS