Centos7 Compiling and installing PHP7.2

Source: Internet
Author: User

Yum Install wget

Download PHP source package in/usr/local/src directory

wget http://cn2.php.net/distributions/php-7.2.4.tar.gz

Unzip the source package
Tar zxvf php-7.2.1.tar.gz
Install the dependent packages needed to compile PHP:
Yum Install gcc autoconf gcc-c++
Yum install libxml2 libxml2-devel OpenSSL openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel LIBP ng libpng-devel freetype freetype-devel GMP gmp-devel readline readline-devel libxslt libxslt-devel
Yum Install Systemd-devel
Yum Install Openjpeg-devel
Add PHP-FPM User
Create a group
Groupadd PHP-FPM
Create a user, do not allow login and do not create home directory

Useradd-s/sbin/nologin-g php-fpm-m php-fpm

Compile parameters:

    1. Development environment:
    2. --enable-phpdbg\
    3. --enable-dtrace\
    4. Production environment:
    5. --disable-phpdbg\
    6. --disable-dtrace\
  1. ./configure \
  2. --prefix=/usr/local/php \
  3. --with-config-file-path=/usr/local/php/etc \
  4. --with-zlib-dir \
  5. --with-freetype-dir \
  6. --enable-mbstring \
  7. --with-libxml-dir=/usr \
  8. --enable-xmlreader \
  9. --enable-xmlwriter \
  10. --enable-soap \
  11. --enable-calendar \
  12. --with-curl \
  13. --with-zlib \
  14. --with-gd \
  15. --with-pdo-sqlite \
  16. --with-pdo-mysql \
  17. --with-mysqli \
  18. --with-mysql-sock \
  19. --enable-mysqlnd \
  20. --disable-rpath \
  21. --enable-inline-optimization \
  22. --with-bz2 \
  23. --with-zlib \
  24. --enable-sockets \
  25. --enable-sysvsem \
  26. --ENABLE-SYSVSHM \
  27. --enable-pcntl \
  28. --enable-mbregex \
  29. --enable-exif \
  30. --enable-bcmath \
  31. --with-mhash \
  32. --enable-zip \
  33. --with-pcre-regex \
  34. --with-jpeg-dir=/usr \
  35. --with-png-dir=/usr \
  36. --with-openssl \
  37. --enable-ftp \
  38. --with-kerberos \
  39. --with-gettext \
  40. --with-xmlrpc \
  41. --with-xsl \
  42. --enable-fpm \
  43. --with-fpm-user=php-fpm \
  44. --with-fpm-group=php-fpm \
  45. --with-fpm-systemd \
  46. --disable-fileinfo

To perform the compilation:

Make && make install

Php-ini:

There are configuration files in the source package:

Php.ini-development Test Development environment

Php.ini-production production Environment

Copy one to the specified directory (depending on your situation, you can compare the differences between the two files):

CP Php.ini-production/usr/local/php/etc/php.ini

PHP-FPM copy a new PHP-FPM configuration file:

Cd/usr/local/php/etc

CP Php-fpm.conf.default php-fpm.conf

Vim php-fpm.conf

Configuration error log:

Error_log =/usr/local/php/var/php-fpm.log

To configure the PID file:

PID =/usr/local/php/var/run/php-fpm.pid

Save exit

Cd/usr/local/php/etc/php-fpm.d

CP Www.conf.default www.conf

Manage PHP-FPM configuration:

cd/usr/local/src/php-7.2.4

CP./sapi/fpm/php-fpm.service to/usr/lib/systemd/system/

Configure Boot PHP-FPM:

Systemctl Enable PHP-FPM

Start PHP-FPM:

Systemctl Start PHP-FPM

View Status:

Systemctl Status PHP-FPM

To add an environment variable:

Vim/etc/profile

Append at end:

Export path= $PATH: '/usr/local/php/bin/'

Save exit.

Source/etc/profile

Test:

Php-v

See the following to show that it has been successful.

If you need to differentiate between the web and CLI environments, you can copy the/usr/local/php/etc/php.ini and rename it to Php-cli.ini

Cp/usr/local/php/etc/php.ini/usr/local/php/etc/php-cli.ini

You need to adjust the configuration to make adjustments in the respective configuration files.

Centos7 Compiling and installing PHP7.2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.