Javatpoint Logo
Javatpoint Logo

How to install PHP7 in Ubuntu 16.04?

Introduction

PHP is a server side scripting language that is used to create dynamic web applications.

Originally, it was developed by Rasmus Lerdorf (Danish-Canadian programmer) in 1993 and published in 1995. The reference implementation of PHP is now generated by the PHP Group. Originally, PHP was stand for Personal Home Page, but now it is short for the recursive initialism PHP: Hypertext Preprocessor.

Usually, PHP code is prepared via a PHP interpreter on a web server implemented as a daemon, a module, or a CGI (Common Gateway Interface) executable. Over the web server, the outcome of the executed and interpreted PHP code, including generated binary or HTML image data, would become the part or whole of the HTTP response.

  • Several web template systems, web frameworks, and web content management systems are available, which can be occupied to facilitate or orchestrate that response generation.
  • PHP can additionally be used for several programming operations external to the web context, including robotic drone control and individual graphical applications.
  • Also, PHP code can be run from the command line directly.
  • The typical PHP interpreter is free software published upon the PHP license and powered by Zend Engine.
  • PHP has been extensively shipped and can be set up on almost every web server on a range of platforms and operating systems.
  • The PHP language was derived without a specified standard or formal specification until 2014, and the actual implementation acted as a de facto standard.
  • Work has continued to make a formal PHP specification since 2014.

Brief History of PHP

The development of PHP started in 1993 when Rasmus Lerdorf wrote many CGI (Common Gateway Interface) programs in the C language, which he used to manage his personal homepage. Rasmus Lerdorf extended them to implement with web forms and to connect with databases. This implementation was called PHP/FI or "Forms Interpreter/Personal Home Page".

PHP/FI could be utilized to create common dynamic web applications. Initially, Rasmus Lerdorf introduced the PHP/Fi release as "PHP Tools (Personal Home Page Tools) version 1.0" on 8 June 1995 to develop the code and enhance bug reporting. This version already had the common functionality that PHP contains today. It contained the feature to embed HTML, Form handling, and Perl-like variables. The syntax simulated that of Perl, although it was more limited, simpler, and more consistent.

  • PHP 4 and 3: Andi Gutmans and Zeev Suraski re-specified the parser in 1997 and structured the PHP 3 base, modifying the name of the language to the PHP: Hypertext Preprocessor recursive acronym. After that, PHP 3 public testing started, and the official release came in June 1998. Then, Gutmans and Suraski initiated a fresh core rewrite of PHP, generating the Zend Engine in 1999. PHP 4 was published on 22 May 2000. This branch had collected version 4.4.9 by August 2008.
  • PHP 5: PHP 5 was published on 1 July 2004. It added new aspects, including object-oriented programming improved support, several performance improvements, and PDO (PHP Data Objects) extension (which specifies a consistent and lightweight interface to access databases).
    PHP 5 became a single release under development in 2008. Late static binding had not been available from older PHP versions and was included in the 5.3 version. Several open-source high-profile projects ceased for supporting PHP 4 from 5 February 2008 due to the GoPHP5 initiative, given by the PHP consortium developers advertising the transition to PHP 5 from PHP 4.
  • Unicode and PHP 6: PHP got mixed reviews because of the lacking support for native Unicode on the core language level. A project led by Andrei Zmeivski was started to get native support for Unicode throughout PHP in 2005 by inserting the ICU (International Components for Unicode) library and internally characterizing text strings as UTF-16.
    • Since it would cause bigger modifications both to the user code and the language internals, it was decided to publish it as the 6.0 language version and other bigger aspects in development.
    • Although, the developer shortage who understood the essential modifications and performance issues coming from conversion from and to UTF-16, which is hardly utilized in a web context, caused delays within the project.
    • The 5.3 version of PHP was made in 2009, with several non-Unicode aspects back-ported through PHP 6, namespaces notably.
    • In its current form, the project was officially discarded in March 2010, and the 5.4 version of PHP was planned to include almost every remaining non-Unicode aspect from PHP 6, including closure and traits re-binding.
  • PHP 7: During 2015 and 2014, a new bigger PHP version was released, i.e., PHP 7. The counting of this version included the debate among developers. Many book titles and articles referenced the names of PHP 6, which might have led to confusion when a new edition was to reutilize the name, while the Unicode experiments of PHP 6 had never been published. The PHP 7 title was selected after a vote.

Implementations of PHP

The only full PHP implementation is the actual, simply called PHP. It's the most generally used and powered via the Zend Engine. Sometimes, it's unofficially known as "Zend PHP" to authorize it from other implementations. The PHP source code is compiled by the Zend Engine on-the-fly within the internal format it can run, so it acts as an interpreter. Also, it is the PHP "reference implementation" because PHP doesn't include formal specifications, and thus the Zend PHP semantics specify the PHP semantics. It is hard to compete with implementations to provide complete compatibility because of the nuanced and complex PHP semantics.

  • The single-request-per-script-execution model of PHP, and the concept that the Zend Engine is the interpreter, cause inefficiency.
  • Several products have been improved to aid in improving PHP performance.
  • To accelerate execution time and not need to compile the source code of PHP every time a web page is used, PHP scripts can be set up in the internal format of the PHP engine by utilizing an opcode cache, which operates by caching the PHP script's compiled form in shared memory to stop the overhead of compiling and parsing the code whenever the script executes.
  • Send Opcache, an opcode cache, has been created in PHP since the 5.5 version.
  • Many other implementations have been improved, although Zend PHP is the most famous implementation. A few of these support JIT compilation or are compilers, so they provide performance features at the amount lacking complete PHP compatibility.

Different implementations include the below:

  • HHVM or HipHop Virtual Machine: HHVM was improved at Facebook, and it can be used as an open source. It can transform PHP code into high-level bytecodes, which is further dynamically converted into x86-64 machine code during runtime by a JIT (just-in-time) compiler, providing up to 6x performance improvements.
    • HipHop: HipHop was improved at Facebook, and it can be used as an open source. It can convert the PHP scripts into C++ code and, after that, compiles the final code, decreasing the server load by up to 50%. Facebook detracted it because of multiple causes in early 2013, such as deployment difficulties and insufficient support for the entire PHP language, such as eval() and create_function
  • PeachPie: PeachPie is a 2nd generation compiler to .NET CIL (Common Intermediate Language) bytecode, established on the Roslyn platform, Phalanger's successor, sharing many architectural components.
  • Parrot: Parrot is a virtual machine created to efficiently execute dynamic languages; the cross-translator, i.e., Pipp, converts the source code of PHP into the Parrot intermediate representation, which is further converted into the bytecode of Parrot and run by the virtual machine.
  • Phalanger: It compiles PHP to .NET CIL bytecode, PeachPie's predecessor.
  • Quercus: It compiles PHP to Java bytecode.

Uses of PHP

Especially, PHP is compatible with server-side web development, where PHP generally executes on the web server. In a requested file, the PHP code is run by the PHP runtime. Also, it can be used for client-side GUI and command-line scripting applications. PHP can be set up on almost every web server, various platforms and operating systems, and can be used with several RDBMS (relational database management systems).

  • Almost every web hosting provider supports PHP use via their clients.
  • It's freely available, and the PHP Group offers the entire source code to users to create, customize, and develop for their use.
  • Now, PHP mainly focuses on server-side scripting, and it's the same as other server-side languages that offer dynamic content through a web server to any client, including mod_perl, Sun Microsystem's JavaServer Pages, and Microsoft's NET, originally developed to build dynamic web pages.
  • Also, PHP has brought the development of several software frameworks that offer a design structure and building blocks to develop RAD (rapid application development). A few of these are Laminas, Phalcon, Yii Framework, Laravel, Codelgniter, Symfony, CakePHP, and PRADO, providing features the same as other web frameworks.
  • In the web industry, the LAMP architecture became famous as a way of expanding web applications.

Commonly, PHP is used as a P in this array with MySQL, Apache, and Linux. However, this P may refer to Perl, Python, or some combination of the three. The same packages, MAMP and WAMP, are also present for macOS and Windows, along with the initial letter being short for the related operating system. Both Apache and PHP are offered as the components macOS base install; end-users of these packages explore an easier installation method that can more easily be kept updated.

Installation of PHP

In this tutorial, we are installing and configuring PHP7 so that we can develop PHP based web applications.

This process includes the following steps.

1) Check PHP is available


Software Php 1

It shows that PHP is not installed.

2) Install PHP

Now, install it using following command. It will install PHP latest version by default.


Software Php 2

3) Verify PHP

Use the following command to check PHP version. It will show PHP version details only when it is installed.


Software Php 3

Now, it shows PHP version. It means we have installed PHP successfully.


Extra Info

To test, PHP is working properly. We can execute it over the browser using apache server.

Create a file first.php inside the /var/www/html directory that contains the following code.

// first.php

Now, execute this file using localhost/first.php over the browser. It will produce the following output to the browser.

Software Php 4





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA