PHP7.1 installation path and redis extension installation on Ubuntu

1. The default path to install php using sudo apt-get install php7.1 on Ubuntu16.04 is as follows:

  a. php executable commands: /usr/bin/php7.1 and /usr/bin/php

  b. You need to install sudo apt install php7.1-dev to have /usr/bin/phpize, and /usr/bin/php-config. It will be used later when installing the extension.

  c. .so file path: /usr/lib/php/20160303, this can be seen from phpinfo()

  d. The *.ini configuration file directory of php: There are three directories under /etc/php/7.1/

  

   The mods-available directory stores the ini configuration of various loadable php extensions. After installing the redis extension later, add the redis.ini file here

   The cli/conf.d directory stores the extensions loaded by php in the command line mode. The file names are: 20-redis.ini

   The apache2/conf.d directory stores the extensions that have been loaded in web mode. The file names are such as: 10-pdo.ini. You can see the paths of various ini files loaded from phpinfo().

   The n-###.ini in the cli/conf.d and apache2/conf.d directories do not need to be created, they are directly obtained from the mods-available soft link. Numbers in filenames indicate priority

2. Install the redis extension for php:

  a. Official website address http://pecl.php.net/package/redis, right-click on redis-4.0.1.tgz to copy the link address

  

  b. Use wget http://pecl.php.net/get/redis-4.0.1.tgz in ubuntu to download to the current directory

  c. tar -zxvf redis-4.0.1.tgz extract to the current directory

  d. cd redis-4.0.1

  e. Execute phpize (if you do not have this command, please see item b in the first section)

  f. ./configure --with-php-config=/usr/bin/php-config

  g. make

  h. make install

  At this point, the redis.so file has been automatically added to the /usr/lib/php/20160303 directory

  i. Create a redis.ini file in the /etc/php/7.1/mods-available directory and write a line of extension=redis.so

  j. Create a soft link sudo ln -s /etc/php/7.1/mods-available/redis.ini /etc/php/7.1/cli/conf.d/20-redis.ini , at this time /etc/php/7.1 There are 20-redis.ini files in the /cli/conf.d directory

  k. Create a soft link sudo ln -s /etc/php/7.1/mods-available/redis.ini /etc/php/7.1/apache2/conf.d/20-redis.ini, this time /etc/php/7.1 There is a 20-redis.ini file in the /apache2/conf.d directory

  l. Restart apache: sudo /etc/init.d/apache2 restart

  m. At this point, refresh the phpinfo page to see that the redis extension has been loaded

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324794393&siteId=291194637