Skip to main content

How to Installation PHP5 in Apache2 in the Raspbian?

How To Installation PHP5 In Apache2 In The Raspbian?

How to installation PHP5 in Apache2 in the Raspbian?

Introduction

If you want to develop an interactive web site in Apache2, you should use PHP for development. These days, PHP 5.6 has been published. You should install it. Right now, Let me show how to install PHP5 in Apache2 and check it correctly for you.

Equipment

Operation System: Raspbian (NOOBS v1.3.10)
Web Site version: apache2_2.4.10-8
PHP version: PHP 5.6

Usage

1.. To install PHP5 and PHP5's apache2 module

1.1. To install PHP5.
pi@raspberrypi:/etc/apache2$ sudo su
root@raspberrypi:/etc/apache2# apt-get install php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
 libatk-wrapper-java libatk-wrapper-java-jni libauthen-sasl-perl
 libbit-vector-perl libcarp-clan-perl libclass-accessor-perl
 libclass-data-inheritable-perl libclass-method-modifiers-perl
 libcommon-sense-perl libcrypt-openssl-bignum-perl libcrypt-openssl-rsa-perl
 libdata-random-perl libdate-calc-perl libdate-calc-xs-perl
 libdigest-hmac-perl libencode-locale-perl libextutils-depends-perl
 libextutils-pkgconfig-perl libfile-basedir-perl libfile-listing-perl
 libfile-which-perl libfont-afm-perl libgconf2-4 libgd-perl
 libgnome2-canvas-perl libgnome2-gconf-perl libgnome2-perl libgnome2-vfs-perl
 libgnome2-wnck-perl libgoo-canvas-perl libgoocanvas-common libgoocanvas3
 libgtk2-imageview-perl libgtk2-unique-perl libgtkimageview0
 libhtml-form-perl libhtml-format-perl libhtml-parser-perl
 libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl
 libhttp-daemon-perl libhttp-date-perl libhttp-message-perl
 libhttp-negotiate-perl libhttp-server-simple-perl libio-html-perl
 libio-socket-ssl-perl libjpeg-progs libjpeg9 libjson-perl libjson-xs-perl
 liblwp-mediatypes-perl libmailtools-perl libmouse-perl libnet-http-perl
 libnet-smtp-ssl-perl libnet-ssleay-perl libpath-class-perl
 libproc-processtable-perl libproc-simple-perl libsort-naturally-perl
 libsub-name-perl libtie-ixhash-perl libunique-1.0-0 liburi-perl
 libwww-robotrules-perl libxml-libxml-perl libxml-namespacesupport-perl
 libxml-sax-base-perl libxml-sax-perl libxml-simple-perl
 libxml-xpathengine-perl perlmagick tzdata-java
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
 php5
0 upgraded, 1 newly installed, 0 to remove and 109 not upgraded.
Need to get 0 B/1,308 B of archives.
After this operation, 29.7 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
 php5
Install these packages without verification? [y/N] Y
Selecting previously unselected package php5.
(Reading database ... 96489 files and directories currently installed.)
Preparing to unpack .../php5/php5_5.6.2+dfsg-1_all.deb ...
Unpacking php5 (5.6.2+dfsg-1) ...
Setting up php5 (5.6.2+dfsg-1) …

1.2. To install libapache2-mod-php5
root@raspberrypi:/etc/apache2/mods-enabled# apt-get install libapache2-mod-php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libatk-wrapper-java libatk-wrapper-java-jni libauthen-sasl-perl
libbit-vector-perl libcarp-clan-perl libclass-accessor-perl
libclass-data-inheritable-perl libclass-method-modifiers-perl
libcommon-sense-perl libcrypt-openssl-bignum-perl libcrypt-openssl-rsa-perl
libdata-random-perl libdate-calc-perl libdate-calc-xs-perl
libdigest-hmac-perl libencode-locale-perl libextutils-depends-perl
libextutils-pkgconfig-perl libfile-basedir-perl libfile-listing-perl
libfile-which-perl libfont-afm-perl libgconf2-4 libgd-perl
libgnome2-canvas-perl libgnome2-gconf-perl libgnome2-perl libgnome2-vfs-perl
libgnome2-wnck-perl libgoo-canvas-perl libgoocanvas-common libgoocanvas3
libgtk2-imageview-perl libgtk2-unique-perl libgtkimageview0
libhtml-form-perl libhtml-format-perl libhtml-parser-perl
libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl
libhttp-daemon-perl libhttp-date-perl libhttp-message-perl
libhttp-negotiate-perl libhttp-server-simple-perl libio-html-perl
libio-socket-ssl-perl libjpeg-progs libjpeg9 libjson-perl libjson-xs-perl
liblwp-mediatypes-perl libmailtools-perl libmouse-perl libnet-http-perl
libnet-smtp-ssl-perl libnet-ssleay-perl libpath-class-perl
libproc-processtable-perl libproc-simple-perl libsort-naturally-perl
libsub-name-perl libtie-ixhash-perl libunique-1.0-0 liburi-perl
libwww-robotrules-perl libxml-libxml-perl libxml-namespacesupport-perl
libxml-sax-base-perl libxml-sax-perl libxml-simple-perl
libxml-xpathengine-perl perlmagick tzdata-java
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
libapache2-mod-php5
0 upgraded, 1 newly installed, 0 to remove and 109 not upgraded.
Need to get 0 B/1,857 kB of archives.
After this operation, 8,193 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
libapache2-mod-php5
Install these packages without verification? [y/N] Y
Selecting previously unselected package libapache2-mod-php5.
(Reading database ... 96493 files and directories currently installed.)
Preparing to unpack .../libapache2-mod-php5_5.6.2+dfsg-1_armhf.deb ...
Unpacking libapache2-mod-php5 (5.6.2+dfsg-1) ...
Setting up libapache2-mod-php5 (5.6.2+dfsg-1) ...

Creating config file /etc/php5/apache2/php.ini with new version
php5_invoke: Enable module mysql for apache2 SAPI
php5_invoke: Enable module gd for apache2 SAPI
php5_invoke: Enable module json for apache2 SAPI
php5_invoke: Enable module readline for apache2 SAPI
php5_invoke: Enable module xcache for apache2 SAPI
php5_invoke: Enable module mysqli for apache2 SAPI
php5_invoke: Enable module pdo_mysql for apache2 SAPI
php5_invoke: Enable module opcache for apache2 SAPI
php5_invoke: Enable module pdo for apache2 SAPI
php5_invoke: Enable module mcrypt for apache2 SAPI
Module mpm_event disabled.
Enabling module mpm_prefork.
apache2_switch_mpm Switch to prefork
[....] Restarting web server: apache2AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
. ok
apache2_invoke: Enable module php5
[....] Restarting web server: apache2AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
. ok

1.3. To check PHP5 module
root@raspberrypi:/etc/apache2/mods-enabled# ls
access_compat.load authz_user.load filter.load  php5.load
alias.conf   autoindex.conf  mime.conf  setenvif.conf
alias.load   autoindex.load  mime.load  setenvif.load
auth_basic.load  deflate.conf  mpm_prefork.conf status.conf
authn_core.load  deflate.load  mpm_prefork.load status.load
authn_file.load  dir.conf  negotiation.conf
authz_core.load  dir.load  negotiation.load
authz_host.load  env.load  php5.conf

1.4. Writing a test page for verification PHP5.
We need to make sure PHP5 of installation completely. So we can create a text file called "index.html", grant the permissions to read and write. The file is just writing a line: "<?php phpinfo(); ?>" (without the double quotation marks). Open your browser and then go to the hyperlink “http://localhost”. If the PHP5 is correct, you should see a description of PHP5 configuration.

Text File Name: index.html
<?php phpinfo(); ?>

Exception

If you find out the PHP5 module that is not in the '/etc/apache2/mods-available', you could execute this command-line, as below.

$ sudo a2enmod php5

If the command-line response a massage is 'Module php5 already enabled', that means PHP5 module already loading. If it is to get an error message, you should reinstall libapache2-mod-php5.

Acknowledge

Thank you (Apache2, PHP, Raspbian) very much for this great tool.

Popular posts from this blog

Python 日期與時間的處理

Visual Basic 6.0 (VB6) 程式語言案例學習 (10. 條碼列印程式)

寫作:波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

Python 日期與時間的處理

Image

Visual Basic 6.0 (VB6) 程式語言案例學習 (10. 條碼列印程式)

Image

寫作:波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

Image

數位影像處理:最佳化處理策略之快速消除扭曲演算法

Image

用10種程式語言做影像二值化(Image binarization)

Visual Basic 6.0 (VB6) 程式語言案例學習 (04. 人事考勤管理系統)

Image

Visual Basic 6.0 (VB6) 程式語言案例學習 (07. 收據列印程式)

Image

Visual Basic .Net (VB.Net) 程式語言案例學習 (06. 題庫測驗系統)

Image

Visual Basic .Net (VB.Net) 程式語言案例學習 (03. 場地預約系統)

Image

Visual Basic 6.0 (VB6) 程式語言案例學習 (11. 生產線拍照程式)

Image