Detailed description of php5.6.30 compilation and installation in linux

Source: Internet
Author: User
Tags php cli
After php5.6.30 fails to be compiled and installed for the first time, the installation is successful for the second time. I. Compile and install php5.6.30

Installation environment:

# cat /etc/redhat-release CentOS release 6.8 (Final)
# /application/nginx/sbin/nginx -vnginx version: nginx/1.6.3

Download the php5.6.30 installation package

wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2

Extract

tar -xjf php-5.6.30.tar.bz2

Install the required dependency package

# rpm -qa zlib-devel libxm12-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel libpng-devel gd-devel libcurl-devel libxslt-devel# yum install zlib-devel libxm12-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel libpng-devel gd-devel libcurl-devel libxslt-devel -y

Install libiconv Library

wget tar zxf libiconv-1.14.tar.gz cd libiconv-1.14./configure --prefix=/usr/local/libiconvmakemake install

Start installing php

[Root @ darius php-5.6.30] #. /configure -- prefix =/application/php5.6.30 -- with-mysql = mysqlnd -- with-mysqli = mysqlnd -- with-pdo-mysql = mysqlnd -- with-iconv-dir =/usr/local /libiconv -- with-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-libxml-dir =/usr -- enable-xml -- disable- rpath -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- with-curl -- enable-mbregex -- enable-fpm -- enable-mbstring -- with-mcrypt -- with-gd -- enable-gd-native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- enable-short-tags -- enable-static -- with-xsl -- with-fpm-user = nginx -- with-fpm-group = nginx -- enable-ftp -- without-pear -- disable- phar # because the local machine does not have a pear package, so select to temporarily skip (-- without-pear -- disable-phar), and wait for php installation before completing go-pear

Make compilation

[root@darius php-5.6.30]# make.........Build complete.Don't forget to run 'make test'. [root@darius php-5.6.30]# make test

Some problems were reported in the results of make test. I ignored it and continued to install it.

Run make install

[root@darius php-5.6.30]# make installInstalling shared extensions:     /application/php5.6.30/lib/php/extensions/no-debug-non-zts-20131226/Installing PHP CLI binary:        /application/php5.6.30/bin/Installing PHP CLI man page:      /application/php5.6.30/php/man/man1/Installing PHP FPM binary:        /application/php5.6.30/sbin/Installing PHP FPM config:        /application/php5.6.30/etc/Installing PHP FPM man page:      /application/php5.6.30/php/man/man8/Installing PHP FPM status page:   /application/php5.6.30/php/php/fpm/Installing PHP CGI binary:        /application/php5.6.30/bin/Installing PHP CGI man page:      /application/php5.6.30/php/man/man1/Installing build environment:     /application/php5.6.30/lib/php/build/Installing header files:           /application/php5.6.30/include/php/Installing helper programs:       /application/php5.6.30/bin/  program: phpize  program: php-configInstalling man pages:             /application/php5.6.30/php/man/man1/  page: phpize.1  page: php-config.1Installing PDO headers:           /application/php5.6.30/include/php/ext/pdo/

2. configure php

Cp php. ini-production/usr/local/php/etc/php. ini # Copy the php configuration file to the installation directory rm-rf/etc/php. ini # Delete the built-in configuration file ln-s/usr/local/php/etc/php. ini/etc/php. ini # add soft links to the/etc directory cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf # copy the template file to the php-fpm configuration file ln -s/usr/local/php/etc/php-fpm.conf # add soft connection to/etc directory

Modify php-fpm.conf

Pid = run/php-fpm.pid # Remove the semicolon above

Modify php-ini.conf

Find: disable_functions =

To:

disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

# List functions that can be disabled by PHP. if some programs need this function, they can be deleted and disabled.

Locate:; date. timezone =

To:

Date. timezone = PRC # set the time zone

Find: expose_php = On

To:

Expose_php = Off # Disable Display of php version information

Find: short_open_tag = Off

To:

Short_open_tag = ON # php short labels supported

Note: The short_open_tag must be enabled. you can use the PHP segment label after it is enabled :(). At the same time, you can use this function only when this function is enabled.

Find opcache. enable = 0

Change

Opcache. enable = 1 # php supports opcode caching

Find:; opcache. enable_cli = 1 # php supports opcode caching

To:

opcache.enable_cli=0

Add the following in the last line:

Zend_extension = opcache. so # enable the opcode cache function

: Wq # save and exit

Configure nginx. conf

Location ~ \. Php $ {root html/bbs; # root directory fastcgi_pass 127.0.0.1: 9000; fastcgi_index index. php; fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name; include fastcgi_params ;}

Create a test file:

[root@darius bbs]# cat index.php 
 [root@darius bbs]# cat index.html bbs.html[root@darius bbs]# pwd/application/nginx/html/bbs

Start php-fpm, restart nginx, and test the result.

/application/php/sbin/php-fpm -c /application/php/etc/php.ini -y /application/php/etc/php-fpm.conf
/application/nginx/sbin/nginx -s reload

The above is a detailed description of the php5.6.30 process (text) compiled and installed in linux. For more information, see other related articles in the first PHP community!

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.