Detailed steps for compiling and installing php5.6.5 in CentOS6.5 (64-bit) system

Source: Internet
Author: User
Tags curl fpm ftp gettext install php mcrypt openssl


1. Download the relevant installation package

Download php

Http://cn2.php.net/distributions/php-5.6.5.tar.gz

Download libmcrypt (php extension)

Http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

Download yasm (php extension)

Http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

Download t1lib (php extension)
Ftp://sunsite.unc.edu/pub/Linux/libs/graphics/t1lib-5.1.2.tar.gz

Download the gd Library installation package

Https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz

Download libvpx (required by the gd Library)

Http://anduin.linuxfromscratch.org/sources/other/libvpx-v1.3.0.tar.xz

Or

Https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2

Download tiff (gd library required)

Http://download.osgeo.org/libtiff/tiff-4.0.3.tar.gz

Download libpng (gd library required)

Http://downloads.sourceforge.net/libpng/libpng-1.6.16.tar.xz

Download freetype (gd library required)

Http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.4.tar.gz

Download unzip src (gd library required)

Http://www.ijg.org/files/jpegsrc.v9a.tar.gz

II. Install the compilation tool and library file (use the yum command for installation)

Yum install-y zlib-devel fontconfig-devel libXpm * libtool * libxml2 libxml2-devel curl-devel

We recommend that you install all


Yum install-y apr * autoconf automake bison bzip2 bzip2 * cloog-ppl compat * cpp
Yum install-y curl-devel fontconfig-devel freetype *
Yum install-y freetype-devel gcc-c ++ gtk +-devel gd gettext-devel
Yum install-y glibc kernel-headers keyutils-libs-devel krb5-devel
Yum install-y libcom_err-devel libpng * libpng-devel libjpeg * libsepol-devel
Yum install-y libselinux-devel libstdc ++-devel libtool * libgomp libxml2 libxml2-devel libXpm * libX *
Yum install-y libtiff * make mpfr ncurses * ntp openssl nasm *
Yum install-y openssl-devel patch pcre-devel perl php-common php-gd
Yum install-y policycoreutils ppl telnet t1lib t1lib * wget zlib-devel
3. Start installation

1. Install yasm

Cd/home
 
Tar zxvf yasm-1.3.0.tar.gz
 
Cd yasm-1.3.0
 
./Configure
 
Make & make install
 

2. Install libmcrypt

Cd/home
 
Tar zxvf libmcrypt-2.5.8.tar.gz
 
Cd libmcrypt-2.5.8
 
./Configure
 
Make & make install
 

3. Install libvpx

Cd/home
 
Xz-d libvpx-v1.3.0.tar.xz
Tar-xvf libvpx-v1.3.0.tar
 
Cd libvpx-v1.3.0
 
./Configure -- prefix =/usr/local/libvpx -- enable-shared -- enable-vp9
 
Make & make install
 

4. Install tiff

Cd/home
 
Tar zxvf tiff-4.0.3.tar.gz
 
Cd tiff-4.0.3
 
./Configure -- prefix =/usr/local/tiff -- enable-shared
 
Make & make install
 

5. Install libpng


Cd/home
 
Xz-d libpng-1.6.16.tar.xz
 
Tar-xvf libpng-1.6.16.tar
 
Cd libpng-1.6.16
 
./Configure -- prefix =/usr/local/libpng -- enable-shared
 
Make & make install
 

6. Install freetype

Cd/home
 
Tar zxvf freetype-2.5.4.tar.gz
 
Cd freetype-2.5.4
 
./Configure -- prefix =/usr/local/freetype -- enable-shared -- without-png
 
Make & make install
 

7. Install jpeg


Cd/home
 
Tar zxvf restart src.v9a.tar.gz
 
Cd jpeg-9a
 
./Configure -- prefix =/usr/local/jpeg -- enable-shared
 
Make & make install
 

8. Install libgd

Cd/home
 
Tar zxvf libgd-2.1.0.tar.gz
 
Cd libgd-2.1.0
 
./Configure \
-- Prefix =/usr/local/libgd \
-- Enable-shared \
-- With-jpeg =/usr/local/jpeg \
-- With-png =/usr/local/libpng \
-- With-freetype =/usr/local/freetype \
-- With-fontconfig =/usr/local/freetype \
-- With-xpm =/usr /\
-- With-tiff =/usr/local/tiff \
-- With-vpx =/usr/local/libvpx
 
Make & make install
 

9. Install t1lib


Cd/home
 
Tar zxvf t1lib-5.1.2.tar.gz
 
Cd t1lib-5.1.2
 
./Configure -- prefix =/usr/local/t1lib -- enable-shared
 
Make without_doc
 
Make install
 

10. Install php

Note: If the system is 64-bit, run the following two commands. Otherwise, an error will occur when installing php (the 32-bit system does not need to be executed)

\ Cp-frp/usr/lib64/libltdl. so */usr/lib/
 
\ Cp-frp/usr/lib64/libXpm. so */usr/lib/
 
Cd/home
 
Tar-zvxf php-5.6.5.tar.gz
 
Cd php-5.6.5
 
Export LD_LIBRARY_PATH =/usr/local/libgd/lib
 

# Check the path for each installation. Here,-with-mysql-sock =/tmp/mysqld. Some sock are-with-mysql-sock =/tmp/mysql. sock.

./Configure \
-- Prefix =/usr/local/php \
-- With-config-file-path =/usr/local/php/etc \
-- With-mysql =/usr/local/mysql \
-- With-mysqli =/usr/local/mysql/bin/mysql_config \
-- With-mysql-sock =/tmp/mysqld. sock \
-- With-pdo-mysql =/usr/local/mysql \
-- With-gd -- with-png-dir =/usr/local/libpng \
-- With-jpeg-dir =/usr/local/jpeg \
-- With-freetype-dir =/usr/local/freetype \
-- With-xpm-dir =/usr /\
-- With-vpx-dir =/usr/local/libvpx /\
-- With-zlib-dir =/usr/local/zlib \
-- With-t1lib =/usr/local/t1lib \
-- With-iconv \
-- Enable-libxml \
-- Enable-xml \
-- Enable-bcmath \
-- Enable-shmop \
-- Enable-sysvsem \
-- Enable-inline-optimization \
-- Enable-opcache \
-- Enable-mbregex \
-- Enable-fpm \
-- Enable-mbstring \
-- Enable-ftp \
-- Enable-gd-native-ttf \
-- With-openssl \
-- Enable-pcntl \
-- Enable-sockets \
-- With-xmlrpc \
-- Enable-zip \
-- Enable-soap \
-- Without-pear \
-- With-gettext \
-- Enable-session \
-- With-mcrypt \
-- With-curl \
-- Enable-ctype
 
Make & make install

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 of the system
 
Ln-s/usr/local/php/etc/php. ini/etc/php. ini # Add a soft link to the/etc directory
 
Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf # copy the template file for php-fpm configuration file
 
Ln-s/usr/local/php/etc/php-fpm.conf # add soft connection to/etc directory
 
Vi/usr/local/php/etc/php-fpm.conf # Edit
 
User = www # set the php-fpm runtime account to www
 
Group = www # set the php-fpm running group to www
 
Pid = run/php-fpm.pid # Remove the semicolon above
 
: Wq! # Save and exit

Set the startup of php-fpm

 

Cp/home/php-5.6.5/sapi/fpm/init. d. php-fpm/etc/rc. d/init. d/php-fpm # Copy php-fpm to Startup directory
 
Chmod + x/etc/rc. d/init. d/php-fpm # Add execution permission
 
Chkconfig php-fpm on # set startup
 

 

Vi/usr/local/php/etc/php. ini # Edit the configuration file

Find: disable_functions =

Changed to disable_functions = passthru, exec, system, chroot, scandir, chgrp, chown, shell_exec, proc_open, proc_get_status, ini_alter, ini_alter, rewrite, dl, openlog, syslog, readlink, symlink, delimiter, dll, popen, disk_free_space, checkdnsrr, checkdnsrr, getservbyname, getservbyport, delimiter, posix_ctermid, delimiter, delimiter, posix_getegid, delimiter, posix_getgrnam, posix_getgroups, upper, lower, lower, posix_getpid, lower, posix_getpwnam, lower, lower, posix_getsid, posix_getuid, lower, posix_kill, posix_mkfifo, lower, 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 =

Change to: date. timezone = PRC # set the time zone

Find: expose_php = On

Change to: expose_php = Off # Disable Display of php version information

Find: short_open_tag = Off

Changed to: short_open_tag = ON # php short labels supported

Note: The short_open_tag must be enabled. PHP segment labels can be used after it is enabled: <? ?> ). At the same time, only this feature can be used <? = To replace <? Echo. Some open-source systems use short Tags. If they are not enabled, an error is returned.

Find opcache. enable = 0

Changed to opcache. enable = 1 # php supports opcode caching

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

Changed to: opcache. enable_cli = 0

Add zend_extension = opcache. so # In the last line to enable the opcode cache function.

: Wq! # Save and exit

11. Configure nginx to support php

Vi/usr/local/nginx/conf/nginx. conf

Modify the configuration file/usr/local/nginx/conf/nginx. conf as follows:

User www; # remove comments from the first line of user and change the Nginx runtime group to www; the group configuration must be the same as the user in the/usr/local/php/etc/php-fpm.conf, otherwise, an error occurred while running php.

Index index.html index.htm index. php; # Add index. php

Shell

# Pass the PHP scripts to FastCGI server listening on Fig: 9000
 
#
 
Location ~ \. Php $ {
 
Root html;
 
Fastcgi_pass 127.0.0.1: 9000;
 
Fastcgi_index index. php;
 
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
 
Include fastcgi_params;
 
}
 

# Cancel the location comment of the FastCGI server. Change the parameter of the fastcgi_param row to $ document_root $ fastcgi_script_name, or use the absolute path.

/Etc/init. d/nginx restart # restart nginx

Service php-fpm start # start php-fpm

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.