1. Install the Dependent Software Library:
Yum install-y libxml2 libxml2-devel libtool* curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-d Evel
2. Download the PHP7 source package for compilation and installation
[email protected] opt]# wget http://cn2.php.net/distributions/php-7.0.14.tar.gz
[Email protected] opt]# Tar XF php-7.0.14.tar.gz
[Email protected] opt]# CD php-7.0.14
[Email protected] opt]#/configure--prefix=/usr/local/php-7.0.14--enable-fpm--enable-opcache-- With-config-file-path=/usr/local/php-7.0.14/etc--with-mysql=mysqlnd--with-mysqli=mysqlnd--with-pdo-mysql= Mysqlnd--enable-static--enable-sockets--enable-wddx--enable-zip--enable-calendar--enable-bcmath--enable-soap-- With-zlib--with-iconv--with-freetype-dir--with-gd--with-jpeg-dir--with-xmlrpc--enable-mbstring--with-sqlite3-- With-curl--enable-ftp--with-mcrypt--with-openssl--disable-safe-mode--with-gettext
3. configuration file PHP.ini
[PHP]engine = on #是否启用php解析引擎Short_open_tag = on #是否使用简介标志precision = #浮点数中显示有效数字的位数output_buffering = 4096 #输出缓冲区的大小zlib.output_compression = Off #是否开启zlib输出压缩Implicit_flush = Off #unserialize_callback_func = #serialize_precision = disable_functions = # disable_classes = #zend.enable_gc = on #激活循环引用收集器. expose_php = on #max_execution_time = #程序执行最大时间, the default is 30s,0 means there is no time limit, set 300s here, you can customize the settings max_input_time = memory_limit = 128M error_reporting = E_all Display_errors = Off display_startup_errors = on PHP has errors and is prompted, and is logged in the Event Viewer. If set to Display_startup_errors = Off, there will be no prompt log_errors = on log_errors_max_len = 1024x768 error_log=/data/log/php/error_php7.log setting error log file save path ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = on track_errors = on html_errors = on variables_order =" GPCs " This directive describes the order in which PHP registers get, POST, Cookie, environment and built-in variables (each using G, P, C, E and S, typically using Egpcs or GPC). Register using left-to-right order, new values overwrite old values Request_order = "GP" register_argc_argv = Off Auto_globals_jit = on post_max_size = 16M auto_prepend_f ile = Auto_append_file = Default_mimetype = "text/html" default_charset = "UTF-8"Doc_root =User_dir =ENABLE_DL = Off file_uploads = on upload_max_filesize = 2M max_file_uploads = allow_url_fopen = on allow_url_include = Off default_socket_timeout = cgi.fix_pathinfo= 1 [CLI Server]Cli_server.color = on[Date]Date.timezone = Asia/shanghai Set region time [Pdo_mysql]pdo_mysql.cache_size = pdo_mysql.default_socket= default socket time [Phar][mail function] Mail featureSMTP = localhost smtp_port = Mail.add_x_header = on whether the largest header is open [SQL]Sql.safe_mode = Off for each connection function for a different database, refer to the corresponding manual page for the default values. [ODBC]odbc.allow_persistent = onodbc.check_persistent = onodbc.max_persistent =-1odbc.max_links =-1ODBC.DEFAULTLRL = 4096Odbc.defaultbinmode = 1[Interbase]ibase.allow_persistent = 1ibase.max_persistent =-1ibase.max_links =-1Ibase.timestampformat = "%y-%m-%d%h:%m:%s"Ibase.dateformat = "%y-%m-%d"Ibase.timeformat = "%h:%m:%s"[mysqli]Mysqli.max_persistent =-1Mysqli.allow_persistent = OnMysqli.max_links =-1mysqli.cache_size = 2000Mysqli.default_port = 3306Mysqli.default_socket =Mysqli.default_host = Mysqli.default_user = MYSQLI.DEFAULT_PW = mysqli.reconnect = Off [MYSQLND] mysqlnd.collect_statistics = onmysqlnd.collect_memory_statistics = on[PostgreSQL]pgsql.allow_persistent = on pgsql.auto_reset_persistent = Off pgsql.max_persistent = 1 pgsql.max_links =-1 pgsql.ignore_notice = 0 pgsql.log_notice = 0 [Bcmath]Bcmath.scale = 0[Session]Session.save_handler = files session.use_strict_mode = 0 session.use_cookies = 1 session.use_only_cookies = 1 session.name = phpsessid session.auto_start = 0 s Ession.cookie_lifetime = 0 session.cookie_path =/ session.cookie_domain = valid domain name of the cookie session.cookie_httponly = session.serialize_handler = php session.gc_probability = 1 session.gc_ divisor = +session.gc_maxlifetime = 1440Session.referer_check =Session.cache_limiter = NoCacheSession.cache_expire =session.use_trans_sid = 0session.hash_function = 0Session.hash_bits_per_character = 5url_rewriter.tags = "A=href,area=href,frame=src,input=src,form=fakeentry"[Assertion]zend.assertions = 1[Tidy]tidy.clean_output = Off[SOAP]soap.wsdl_cache_enabled=1soap.wsdl_cache_dir= "/tmp"soap.wsdl_cache_ttl=86400Soap.wsdl_cache_limit = 5[SYSVSHM][LDAP]ldap.max_links =-1
4. Process Service configuration file php-fpm, introducing PHP-FPM to the configuration in the www.conf file[email protected] etc]# cat/usr/local/php-7.0.14/etc/php-fpm.confinclude=/usr/local/php-7.0.14/etc/php-fpm.d/*.conf[email protected] etc]# vim/usr/local/php-7.0.14/etc/php-fpm.d/www.conf[Global] globally definedlog_level = Notice error level. The available levels are: alert (must be processed immediately), error (Error condition), warning (warning condition), notice (general important information), debug (debug Info). Default: Noti CE. error_log=/data/log/php/error_php-fpm7.log error log file save path [www] defines the pool of wwwuser = account for www start process Group = www Start process groupslisten = 127.0.0.1:9999 FPM Listener Port, which is the address of PHP processing in Nginx pm = Dynamicpm mode, divided into static|dynamic two kindsPm.max_children = Maximum number of child processes pm.start_servers = number of processes at startup pm.min_spare_servers = The minimum number of idle processes is guaranteed, and if the idle process is less than this value, a new child process is created pm.max_spare_servers = The maximum number of idle processes is guaranteed, and if the idle process is greater than this value, this is cleaned up
5. Copy the Service control script PHP-FPM to the System Services script directory:cp/opt/php-7.0.14/sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm7 && chmod 755/etc/init.d/php-fpm7set PHP7 on start:chkconfig--add php-fpm7chkconfig php-fpm7 onStart PHP:Service PHP-FPM7 Start
CentOS Compiler Installation PHP7