Compiling and installing PHP7

Source: Internet
Author: User
Tags ldap mysql query pear phpinfo zts openldap

1. Prepare the PHP installation environment

1.1. Completely uninstall the old version of PHP

Rpm-qa |grepphprpm-E php-fpm-5.3.3- A. el6.x86_64rpm-E php-pdo-5.3.3- A. el6.x86_64rpm-E php-pear-1.9.4-4. el6.noarchrpm-E php-cli-5.3.3- A. el6.x86_64rpm-E php-5.3.3- A. el6.x86_64rpm-E php-xml-5.3.3- A. el6.x86_64rpm-E php-gd-5.3.3- A. el6.x86_64rpm-E php-common-5.3.3- A. el6.x86_64


1.2, compile and install Pcre, zlib, OpenSSL, curl, Libmcrypt, bzip2, OpenLDAP, ICU and other dependent on the latest version

Where LDAP needs to rely on Openssl-devel

Curl

./configure--prefix=/opt/curl-7.50.1 --with-NGHTTP2--with-ssl=/opt/openssl-1.0.2h/ --enable-IMAP--enable-stmp--enable-POP3--enable-http--enable-FTP --enable-file --enable-LDAP--enable-Ldaps--enable-IPv6--enable-LIBGCC Make Make Install

BZIP2:

 make-F  makefile-libbz2_somake doinstall

ICU4C:

./Configure--enable-Strict--enable-64bit-Libs--enable-shared--enable-Static--enable-auto-Cleanup--enable-Draft--enable-renaming--enable-Tracing--enable-Plugins--disable-Dyload--enable-rpath--enable-weak-Threads--enable-Extras--enable-Icuio--enable-Layout--enable-Layoutex Make Make Install


2. Install PHP

2.1. Configure PHP

./configure--prefix=/opt/php7/ --with-pcre-regex=/opt/pcre-8.39/ --with-pcre-dir=/opt/pcre-8.39/ --with-openssl-dir=/opt/openssl-1.0.2h/ --with-openssl=/opt/openssl-1.0.2h/ --with-zlib-dir=/opt/zlib-1.2.8/ --with-zlib=/opt/zlib-1.2.8/ --with-curl=/opt/curl-7.50.1/ --with-mcrypt=/opt/libmcrypt-2.5.7/ --with-bz2--with-ldap=/opt/openldap-2.4. -/ --with-GD--with-pdo-mysql=Shared,mysqlnd--with-freetype-dir --with-jpeg-dir --with-png-dir --with-GetText--with-iconv-dir --with-Kerberos--with-libxml-dir --with-Mhash--with-zlib-dir --without-pdo-SQLite--with-Pear--with-Xmlrpc--with-XSL--enable-Opcache--enable-Soap--enable-Sockets--enable-Sysvsem--enable-XML--enable-Bcmath--enable-Libxml--enable-inline-optimization--enable-Mbregex--enable-Zip --enable-FTP --enable-FPM--enable-mbstring--enable-gd-native-TTF--enable-gd-jis-Conv--enable-Calendar--enable-FPM--enable-Pcntl--enable-Shmop--enable-EXIF--enable-Pcntl--enable-WDDX--enable-Intl--enable-libgcc

Partial configuration parameter Description: http://php.net/manual/zh/configure.about.php

Due to a large number of features modified since the 5.3 release, adding and removing many core configurations, specific content can be consulted through configure--HELP

When the configuration is complete, it is visible


2.2. Installation

 Make  Make Test  Make Install

When the compilation is complete, it is visible

When the test is complete, it is visible

In different system environments, the number of bugs is not the same, failed is unavoidable. As the version is perfected, the theoretical failed will become less, but the core group is more likely to create bugs in new features and patches


3. Configure the operating environment

3.1. configuration file location

 CP /opt/php7/etc/php-fpm.d/ Www.conf.default/opt/php7/etc/php-fpm.d/www.conf  CP /opt/php7/etc/php-fpm.conf.default/opt/php7/etc/php-fpm.conf  CP /root/php-7.0 . Span style= "color: #800080;" >10 /php.ini-development/opt/php7/lib/php.ini  CP /root/php-7.0 . 10 /php.ini-development/opt/php7/lib/php.ini- development  CP /root/php-7.0 . 10 /php.ini-production/opt/php7/lib/php.ini-production  


3.2. Configure PHP.ini to open PDO and Opcache

Join in the php.ini

extension=/opt/php7/lib/php/extensions/no-debug-non-zts-20151012/pdo_mysql.sozend_extension=/opt/php7/lib/php/extensions/no-debug-non-zts-20151012/opcache.soopcache.enable=1opcache.memory_consumption= -Opcache.interned_strings_buffer=8Opcache.max_accelerated_files=4000Opcache.max_wasted_percentage=TenOPCACHE.USE_CWD=0Opcache.validate_timestamps=1Opcache.revalidate_freq= -opcache.save_comments=0opcache.load_comments=0Opcache.fast_shutdown=1Opcache.optimization_level=0xFFFFFFFFOpcache.inherited_hack=1Opcache.force_restart_timeout= -Opcache.error_log=Opcache_error_logopcache.log_verbosity_level=1

Opcache Configuration Description: http://php.net/manual/zh/book.opcache.php


3.3, configure php-fpm.conf, open status query

Echo " [www] ">>/opt/php7/etc/php-fpm.confecho"Pm.status_path =/phpfpm_status  ">>/opt/php7/etc/php-fpm.conf


3.4. Configure Nginx

Add below location/{} code block in/opt/nginx-1.10.1/conf/nginx.conf

Location ~* \.php$ {        root            /www;        Fastcgi_index   index.php;        Fastcgi_pass    127.0. 0.1:9000;        Include         Fastcgi_params;        Fastcgi_param   script_filename $document _root$fastcgi_script_name;        Fastcgi_param   script_name     /phpfpm_status {        fastcgi_pass    127.0.  0.1:9000;        Include         Fastcgi_params;        Fastcgi_param   script_filename $fastcgi _script_name;}


3.5. Add PHP-FPM to boot entry

Echo " /OPT/PHP7/SBIN/PHP-FPM ">>/etc/rc.local


3.5, start PHP-FPM, restart Nginx

/opt/php7/sbin/php-fpm/opt/nginx-1.10. 1/sbin/nginx-s Reload


3.6. Testing

Add the phpinfo.php file to the/www directory

phpinfo.php:

<? PHP Echo Phpinfo ();? >

Status Detailed:

POOL:PHP-FPM pool name, generally should be www
Process manage: Management of processes, PHP-FPM support three management methods, respectively static,dynamic and OnDemand, generally dynamic
Start time:php-fpm start time, either restart or reload will update the time here
Start SINCE:PHP-FPM the elapsed time since it was started, the default is seconds.
Accepted Conn: Number of connections currently received
Listen queue: The number of requests waiting for a connection in the queue, if this number is not 0, it is better to increase the number of FPM in the process
Max Listen queue: The maximum number of pending connection requests in the queue since FPM started
Listen queue Len: The size of socket queues waiting for a connection
Idle processes: Number of idle processes
Active processes: Number of active processes
Total processes: Number of processes
Max Active Processes: The maximum number of active processes since FPM started, and if this value is less than the current Max_children, you can lower this value
Max children reached: When PM tries to start more processes, it does not start more processes because of the max_children limit. If this value is not 0, then the number of FPM processes can be increased appropriately
Slow requests: The number of slow requests, generally if this value is not 0, then there may be slow PHP process, generally a bad MySQL query is the biggest culprit.
PID: Process PID, can kill this process alone.
State: Status of the current process (idle, Running, ...)
Start time: The date the process started
Start since: Current process run time
Requests: How many requests are processed by the current process
Request Duration: Requested length (subtle)
Request method: Requesting methods (GET, POST, ...)
Request URI: Requesting URI
Content Length: Request contents (POST only)
User: Users (php_auth_user) (or '-' if not set)
script:php script (or '-' if not set)
Last Request CPU: CPU usage is the final one.
Last request memorythe: Memory used on previous request

Resources:

http://php.net/manual/zh/install.php

Https://typecodes.com/web/centos7compilephp7.html

Compiling and installing PHP7

Related Article

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.