"Tool Installation"-centos Source installation php5.6

Source: Internet
Author: User
Tags bz2 fpm gettext gz file openssl pack php source code sqlite

The server is installed with the 6.3 version of CentOS, the default PHP version is 5.3, the version is too low, so that the latest open source framework does not work, want to run the latest open source framework must upgrade the PHP version, but the server has a lot of old systems running, if forced to upgrade PHP so the old system will have some compatibility errors, than such as: MySQL and mysqli, System customization function changes and so on, so want to be compatible with the old and new systems the best way is to add a high version of the PHP environment, namely: the same Linux system to mount multiple versions of PHP. Next, discuss how to install php5.6 using the source code.


First, PHP installation

Download the PHP source code package

[Root@web1 dede]# wget http://cn2.php.net/distributions/php-5.6.0.tar.xz [root@web1 dede]# xz-d-Php-5.6.0.tar.xz
[Root@web1 dede]# tar xvf php-5.6.0.tar
[Root@web1 dede]# CD php-5.6.0

1.1 Installing dependent componentsThe dependencies that need to be installed are listed below, and if the system already has these dependencies, you can skip over some of the installation items, and you can also look for configure dependencies and install them one by one during the process.

Gcc
Bison
Bison-devel
Zlib-devel
Libmcrypt-devel
MCrypt
Mhash-devel
Openssl-devel
Libxml2-devel
Libcurl-devel
Bzip2-devel
Readline-devel
Libedit-devel
Sqlite-devel

The installation method is as follows:

[Root@web1 dede]# yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-de Vel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel
Note: After installation is not necessarily able to use, because the PHP version of the above need to rely on the package version is not the same, according to the error code generated during the configure process to determine the installation of the dependent package version.
1.2 Creating WWW userswww user is php5.6 default management user, create this system user, otherwise will complain when starting, prompt does not have PHP user, add method as follows:
[Root@web1 dede]# groupadd www
[root@web1 dede]# useradd-g www-s/sbin/nologin-m www
1.3 Compile Installation

[Root@web1 php5.6.0]#./configure \
--prefix=/usr/local/php56 \
--with-config-file-path=/usr/local/php56/ etc \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared
\ Enable-opcache \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
-- ENABLE-SOAP \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
-- Enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
-- Enable-zip \
--with-bz2 \
--with-readline

Description of installed parameters:
"" "" Installation Path ""
--prefix=/usr/local/php56 \ "" "
php.ini Profile Path" ""
--with-config-file-path=/usr/local/php56 /ETC \ "" "
Optimization Options" "
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
enable-shared \ "" "to
enable Opcache, default to Zendoptimizer+ (Zendopcache)" ""
--enable-opcache \ "" "
FPM
" "" " ENABLE-FPM \
--with-fpm-user=www \--with-fpm-group=www \ "" "MySQL" ""
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \ "" "" "
internationalization and character encoding support" "
--with-gettext \
- enable-mbstring \
--with-iconv \ "" "
Encryption Extension" "
--with-mcrypt \
--with-mhash \
--with-openssl \ "
Math extension" "
--enable-bcmath \" "
Web service, SOAP relies on Libxml" "
--enable-soap \
- With-libxml-dir \ "" "" "" "
process, signal and memory" "
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg
\ Enable-sysvsem \
--enable-sysvshm \ "" "
Socket & Curl" ""
--enable-sockets \
--with-curl \ ""
Compress and Archive ""
--with-zlib \
--enable-zip \--with-bz2 \ ""
GNU Readline command line Accelerator binding "" "
-- With-readline

Note: The dependent package should also install the dependent package itself and the development version of the dependency pack, for example: Zlib and Zlib-devel. Some problems may occur during the configuration process, mainly because the dependency pack does not have a Development board installed, or if the installed Dependency pack version is too low, use the./configure--help View for more compilation parameters.

1.4 Compile Installation

[Root@web1 php5.6.0]# make
[root@web1 php5.6.0]# make install
There are also many problems in the compilation process, resulting in conflicts between the Configure configuration items and the development environment, as well as resolving conflicts based on conflicting content and configure Help.
If you want to reinstall:

[Root@web1 php5.6.0]# make clean
[root@web1 php5.6.0]# make clean all

[Root@web1 php5.6.0]#./configure
...] [Root@web1 php5.6.0]# make
[root@web1 php5.6.0]# make install


1.5 Configure PHP configuration php.ini file:

[Root@web1 php5.6.0]# CP Php.ini-development/usr/local/php56/etc/php.ini

Configuration: php-fpm.conf

[Root@web1 php5.6.0]# cp/usr/local/php56/etc/php-fpm.conf.default/usr/local/php56/etc/php-fpm.conf
[ ROOT@WEB1 php5.6.0]# cp sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm56
[root@web1 php5.6.0]# chmod Php-fpm56
Start PHP-FPM
[Root@web1 php5.6.0]# Service Php-fpm56 start

PHP-FPM Available Parameters Start|stop|force-quit|restart|reload|status


Second, linux configuration instructions


The role of/configure is to detect system configurations and generate makefile files so that you can compile and install programs using make and make install.


2.1 Configure

This step is typically used to generate Makefile, preparing for the next step of compiling, you can control the installation by adding parameters to the configure, such as code:./CONFIGURE–PREFIX=/USR means the software is installed under/usr, The execution file is installed in/usr/bin (rather than the default/usr/local/bin), and the resource file is installed in/usr/share (instead of the default/usr/local/share). At the same time, some software configuration files can be set by specifying –sys-config= parameters. Some software can also be combined with –with, –enable, –without, –disable and other parameters to control the compilation, you can by allowing./configure–help See detailed instructions help.
2.2 make

This step is compiled, and most of the source code packages are compiled this step (of course some perl or Python software needs to invoke Perl or Python to compile). If error occurs during make, you should write down the error code (note Not only the last line), and then you can submit bugreport to the developer (typically with a submit address in INSTALL), or your system will have fewer dependent libraries, which requires you to study the error code carefully.
2.3 Make install

This command is installed (some software, of course, needs to run make check or made test to do some testing), and this step generally requires you to have root permissions (because you want to write files to the system).
Linux users may know that when installing an application under Linux, they typically run script configure, then compile the source with make, and finally run make-clean to delete some temporary files in the run made install. With the above three automated tools, you can generate configure scripts. Run the Configure script, you can generate the makefile file, and then you can run making, make install, and making clean.
Configure is a shell script that automatically sets the source program to match the characteristics of UNIX systems on a variety of platforms, and produces the appropriate makefile files or C header files (header file) based on the system parameters and the environment. Make it easy for the source program to be compiled and connected on these different platforms.
At this point, you can run the Configure script and run the Configure script to produce a makefile file that conforms to the GNU specification:

$./configure
At this point, you can run make for compilation, install it at run make install, and finally run made clean to delete temporary files.
$
Make $ do install           (Note: Run this with sufficient permissions)
$

The makefile files produced by the Configure have several preset goals to use, several of which are important briefly as follows:
Make all: produces the target we set, the executable file in this example. Only make is OK, then the source code is compiled and then connected, and the executable file is generated.
Make clean: Clears the compiled executable and target file (object FILE,*.O).

Make Distclean: In addition to the removal of executable files and target files, the configure generated by the makefile also cleared away.
Make install: Installs the program into the system. If the original code compiles correctly and the results are correct, the program can be installed to the system preset executable file storage path. If you use Bin_programs macros, the program will be installed to the/usr/local/bin directory.
Make Dist: Wraps the program and related files into a compressed file for publication. After execution, a file with the name package-version.tar.gz is generated under the directory. The two variables of PACKAGE and VERSION are defined according to the Am_init_automake (package,version) in the configure.in file. In this example, a test-1.0.tar.gz file is generated.
Make Distcheck: is similar to make dist, but it is normal to add a compressed file after checking the wrapper. This goal in addition to the program and related files packaged into tar.gz files, but also automatically untie the compressed file, the implementation of configure, and make all of the action, confirm the compilation is correct, will display this tar.gz file for release. This check is very useful, check the package, basically to any one with the GNU development environment-to recompile.

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.