Home  >  Article  >  Backend Development  >  Install php7 from source code

Install php7 from source code

不言
不言Original
2018-05-07 11:17:113656browse

This article mainly introduces the source code installation of php7, which has certain reference value. Now I share it with everyone. Friends in need can refer to it

Source code installation of php7

1. Download php source code package

  • Click download to download the latest version of php

2. Compile and install

  1. Unzip

  • ##tar -vjxf php-7.2.5.tar.bz2

  • configure

    • ./configure --prefix=yourpath

    • You may need to install:

    • yum install gcc

    • ##yum install libxml2-devel

    make
  • make install
  • Execute
  • yourpath/bin/php -m

    , if it works Seeing the php extension indicates that the installation is successful

  • 3. Simplify the php execution command

      ##vim ~/bash_profile
    • Add a line:
    • alias php=yourpath/bin/php
    • ##source ~/bash_profile
    • 4. Some pitfalls you may encounter

    Installing php requires you to install gcc and autoconfig

    1. Copy the php.ini-development of the source code directory to yourpath/etc

    2. Then rename php.ini-development to php.ini

    3. php -i | grep php.ini
    4. , you can see that php.ini is placed in yourpath/lib directory by default
    5. So put php.ini Go to yourpath/lib

    6. 5. Install openssl for php through phpize without recompiling php

    php source code path:

    /opt/download/php-7.2.5
    • Installation path:

      /opt/soft/php
    • php.ini path:

      /opt/soft/php/lib
    • ##Enter the openssl extension directory
    1. cd /opt/download/php-7.2.5/ext/openssl
    • Run phpize

  • /opt/soft/php/bin/phpize
    • If Cannot find appears config.m4. If an error is reported,

  • cp config0.m4 config.m4
    • Execute installation

  • ./configure --with-openssl --with-php-config=/usr/local/php7/bin/php-config
    • make && make install

    • ##After the installation is complete, you will be prompted to generate it in a certain directory. so file, my generation location is

  • ##/opt/soft/php/lib/php/extensions/no-debug-non-zts-20170718/

    • Open php.ini and add the following two lines

  • extension_dir = "/opt/ soft/php/lib/php/extensions/no-debug-non-zts-20170718/"

    • ##extension=openssl.so

    • Restart php

      6. Install composer
  • Download composer.phar to In the project

    1. curl -sS https://getcomposer.org/installer | php
    • If you place composer.phar in the system's PATH directory, you can access composer.phar globally

    • ##mv composer.phar /usr/local/ bin/composer
    • Related recommendations:
    • Redis source code analysis

    The above is the detailed content of Install php7 from source code. For more information, please follow other related articles on the PHP Chinese website!

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn