jueves, 12 de julio de 2018
How to install PHP (7 or 7.2) on Ubuntu
Install PHP 7.2 on Ubuntu
PHP 7.2 stable version has been released. Use the following set of commands to enable PPA for PHP 7.2 in your Ubuntu system and install it. You can use this version for production use also.
sudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install -y php7.2
Now use the following command to check installed php version on your system.
php -v
PHP 7.2.7-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jun 22 2018 08:44:50) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.7-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Install PHP 7.1 on Ubuntu
Use the following set of commands to add PPA for PHP 7 in your Ubuntu system and install PHP 7.1 version.
sudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install -y php7.1
Now use the following command to check installed php version on your system.
php -v
PHP 7.1.18-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jun 11 2018 14:22:30) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.1.18-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Install PHP 7.0 on Ubuntu
Use the following set of commands to add PPA for PHP 7 in your Ubuntu system and install PHP 7.0 version.
sudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install -y php7.0
Now use the following command to check installed php version on your system.
php -v
PHP 7.0.30-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May 2 2018 12:43:14) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.30-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
Install PHP 7 Modules
You may also need to install modules based on your application requirements. Use the following command to search available PHP 7 modules in the package repository.
sudo apt-cache search php7*
php-all-dev - package depending on all supported PHP development packages php7.0 - server-side, HTML-embedded scripting language (metapackage) php7.0-cgi - server-side, HTML-embedded scripting language (CGI binary) php7.0-cli - command-line interpreter for the PHP scripting language php7.0-common - documentation, examples and common module for PHP php7.0-curl - CURL module for PHP php7.0-dev - Files for PHP7.0 module development php7.0-gd - GD module for PHP php7.0-gmp - GMP module for PHP ... ... ... php7.1-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP php7.1-xmlrpc - XMLRPC-EPI module for PHP php7.1-zip - Zip module for PHP php7.1-opcache - Zend OpCache module for PHP php7.1 - server-side, HTML-embedded scripting language (metapackage) php7.1-xsl - XSL module for PHP (dummy) ... ... php7.2-bcmath - Bcmath module for PHP php7.2-bz2 - bzip2 module for PHP php7.2-cgi - server-side, HTML-embedded scripting language (CGI binary) php7.2-cli - command-line interpreter for the PHP scripting language php7.2-common - documentation, examples and common module for PHP php7.2-curl - CURL module for PHP php7.2-dba - DBA module for PHP
You can install the required PHP modules on your system as below command. Make sure to install packages for correct PHP version by specifying the version with the package name. Without defining package version, it will install the latest package.
Install PHP 7.0 modules
You may need some additional packages and PHP modules in order for PHP to work with your applications. You can install the most commonly needed modules with:
apt-get install php-pear php7.0-dev php7.0-zip php7.0-curl php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-xml libapache2-mod-php7.0
Install PHP 7.2 modules
You may need some additional packages and PHP modules in order for PHP to work with your applications. You can install the most commonly needed modules with:
apt-get install php-pear php7.2-dev php7.2-zip php7.2-curl php7.2-gd php7.2-mysql php7.2-mcrypt php7.2-xml libapache2-mod-php7.2
How to change the PHP version you’re using
If you have multiple PHP versions installed on your Ubuntu server, you can change what version is the default one.
To set PHP 7.0 as the default, run:
update-alternatives --set php /usr/bin/php7.0
To set PHP 7.2 as the default, run:
update-alternatives --set php /usr/bin/php7.2
If you’re following our LAMP tutorials and you’re using Apache, you can configure Apache to use PHP 7.2 with the following command:
a2enmod php7.2
And then restart Apache for the changes to take effect:
systemctl restart apache2
Speed up PHP by using an opcode cache
You can improve the performance of your PHP by using a caching method. We’ll use APCu, but there are other alternatives available.
If you have the ‘php-pear’ module installed (we included it in our instructions above), you can install APCu with the following command:
pecl install apcu
There are also other ways you can install APCu, including using a package.
To start using APCu, you should run the following command for PHP 7.2:
echo "extension=apcu.so" | tee -a /etc/php/7.2/mods-available/cache.ini
And the following command for PHP 7.0:
echo "extension=apcu.so" | tee -a /etc/php/7.0/mods-available/cache.ini
If you’re following our LAMP tutorials and you’re using Apache, create a symlink for the file you’ve just created.
For PHP 7.2:
ln -s /etc/php/7.2/mods-available/cache.ini /etc/php/7.2/apache2/conf.d/30-cache.ini
For PHP 7.0:
ln -s /etc/php/7.0/mods-available/cache.ini /etc/php/7.0/apache2/conf.d/30-cache.ini
And finally, reload Apache for the changes to take effect:
systemctl restart apache2
Suscribirse a:
Enviar comentarios
(
Atom
)
Sígueme en las Redes Sociales
Donaciones
Datos personales
Entradas populares
-
En este apartado vamos a explicar como ejercutar archivos PHP a través del terminal de Ubuntu. Lo primero que tendríamos que hacer es inst...
-
En este blog voy a comentar un tema que se utilizan en casi todas las páginas web que existen, y es el tema de la paginación. La paginaci...
-
Este post trata de la integración de la librería PHPExcel en Codeigniter, aunque se podría aplicar a cualquier librería, como por ejemplo mP...
-
Ejemplo para añadir o sumar un número determinado de hora/s, minuto/s, segundo/s a una fecha en php. Con la función strtotime se puede ...
-
Este tema es uno de los temas primordiales sobre el framework Codeigniter, ya que en alguna ocación nos hemos visto obligados a recoger dato...
© Espacio Daycry - Espacio de programación 2013 . Powered by Bootstrap , Blogger templates and RWD Testing Tool
It was a nice post. I would like you to see my blog post on the same topic here https://decodeweb.in/php/how-do-i-install-php-in-my-computer/
ResponderEliminarPlease give suggestions too.