Jumat, 02 November 2018

How to install php 5.4 from source on centos 6

  Tidak ada komentar
Install epel release
[[email protected] ~]# yum install epel-release
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.biz.net.id
 * extras: centos.biz.net.id
 * updates: centos.biz.net.id
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:6-8 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
 Package                              Arch                           Version                     Repository                      Size
======================================================================================================================================
Installing:
 epel-release                         noarch                         6-8                         extras                          14 k

Transaction Summary
======================================================================================================================================
Install       1 Package(s)

Total download size: 14 k
Installed size: 22 k
Is this ok [y/N]: y
Downloading Packages:
epel-release-6-8.noarch.rpm                                                                                    |  14 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : epel-release-6-8.noarch                                                                                            1/1
  Verifying  : epel-release-6-8.noarch                                                                                            1/1

Installed:
  epel-release.noarch 0:6-8

Complete!
[[email protected] ~]#
Install some needed library
[[email protected] ~]# sudo yum install -y autoconf libtool re2c bison libxml2-devel bzip2-devel libcurl-devel libpng-devel libicu-devel gcc-c++ libmcrypt-devel libwebp-devel libjpeg-devel openssl-devel
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.biz.net.id
 * extras: centos.biz.net.id
 * updates: centos.biz.net.id
Package autoconf-2.63-5.1.el6.noarch already installed and latest version
Package libtool-2.2.6-15.5.el6.x86_64 already installed and latest version
Package bison-2.4.1-5.el6.x86_64 already installed and latest version
Package libxml2-devel-2.7.6-21.el6_8.1.x86_64 already installed and latest version
Package bzip2-devel-1.0.5-7.el6_0.x86_64 already installed and latest version
Package 2:libpng-devel-1.2.49-2.el6_7.x86_64 already installed and latest version
Package openssl-devel-1.0.1e-57.el6.x86_64 already installed and latest version
..
..
Installed:
  libicu-devel.x86_64 0:4.2.1-14.el6              libjpeg-turbo-devel.x86_64 0:1.2.1-3.el6_5
  libmcrypt-devel.x86_64 0:2.5.8-9.el6            libwebp-devel.x86_64 0:0.4.3-3.el6            re2c.x86_64 0:0.13.5-1.el6
  
Updated:
  gcc-c++.x86_64 0:4.4.7-23.el6                   libcurl-devel.x86_64 0:7.19.7-53.el6_9

Dependency Updated:
  cpp.x86_64 0:4.4.7-23.el6                       curl.x86_64 0:7.19.7-53.el6_9              gcc.x86_64 0:4.4.7-23.el6
  gcc-gfortran.x86_64 0:4.4.7-23.el6              libcurl.x86_64 0:7.19.7-53.el6_9           libgcc.x86_64 0:4.4.7-23.el6
  libgfortran.x86_64 0:4.4.7-23.el6               libgomp.x86_64 0:4.4.7-23.el6              libstdc++.x86_64 0:4.4.7-23.el6
  libstdc++-devel.x86_64 0:4.4.7-23.el6           libwebp.x86_64 0:0.4.3-3.el6
  libmcrypt.x86_64 0:2.5.8-9.el6 
  
Complete!
[[email protected] ~]#


Installed:
  libmcrypt-devel.x86_64 0:2.5.8-9.el6            libwebp-devel.x86_64 0:0.4.3-3.el6            re2c.x86_64 0:0.13.5-1.el6

Dependency Installed:
  libmcrypt.x86_64 0:2.5.8-9.el6                  libwebp.x86_64 0:0.4.3-3.el6

Complete!
[[email protected] ~]#
Download php from official website
[[email protected] ~]# wget http://id1.php.net/distributions/php-5.4.45.tar.gz
--2018-11-02 17:27:39--  http://id1.php.net/distributions/php-5.4.45.tar.gz
Connecting to 192.168.71.17:9898... connected.
Proxy request sent, awaiting response... 200 OK
Length: 15879453 (15M) [application/x-gzip]
Saving to: “php-5.4.45.tar.gz”

100%[============================================================================================>] 15,879,453  5.41M/s   in 2.8s

2018-11-02 17:27:43 (5.41 MB/s) - “php-5.4.45.tar.gz” saved [15879453/15879453]

[[email protected] ~]# ls
anaconda-ks.cfg   apr-util-1.6.1.tar.gz  httpd-2.4.37.tar.gz  install.log.syslog
apr-1.6.5.tar.gz  httpd-2.4.37           install.log          php-5.4.45.tar.gz
[[email protected] ~]# 
Extract php source
[[email protected] ~]# tar xzf php-5.4.45.tar.gz
[[email protected] ~]# ls
anaconda-ks.cfg   apr-util-1.6.1.tar.gz  httpd-2.4.37.tar.gz  install.log.syslog  php-5.4.45.tar.gz
apr-1.6.5.tar.gz  httpd-2.4.37           install.log          php-5.4.45
[[email protected] ~]#

Change working directory to php extracted folder
[[email protected] ~]# cd php-5.4.45
[[email protected] php-5.4.45]# ls
acinclude.m4      generated_lists  mkinstalldirs             README.NEW-OUTPUT-API             scripts
aclocal.m4        genfiles         netware                   README.PARAMETER_PARSING_API      server-tests-config.php
build             header           NEWS                      README.PHP4-TO-PHP5-THIN-CHANGES  server-tests.php
buildconf         INSTALL          pear                      README.REDIST.BINS                snapshot
buildconf.bat     install-sh       php5.spec.in              README.RELEASE_PROCESS            stamp-h.in
CODING_STANDARDS  LICENSE          php.gif                   README.SELF-CONTAINED-EXTENSIONS  stub.c
config.guess      ltmain.sh        php.ini-development       README.STREAMS                    svnclean.bat
config.sub        main             php.ini-production        README.SUBMITTING_PATCH           tests
configure         makedist         README.EXTENSIONS         README.TESTING                    TSRM
configure.in      Makefile.frag    README.EXT_SKEL           README.TESTING2                   UPGRADING
CREDITS           Makefile.gcov    README.GIT-RULES          README.UNIX-BUILD-SYSTEM          UPGRADING.INTERNALS
ext               Makefile.global  README.input_filter       README.WIN32-BUILD-SYSTEM         vcsclean
EXTENSIONS        makerpm          README.MAILINGLIST_RULES  run-tests.php                     win32
footer            missing          README.namespaces         sapi                              Zend
[[email protected] php-5.4.45]# ./buildconf
You should not run buildconf in a release package.
use buildconf --force to override this check.
[[email protected] php-5.4.45]# ./buildconf --force
Forcing buildconf
Removing configure caches
buildconf: checking installation...
buildconf: autoconf version 2.63 (ok)
[[email protected] php-5.4.45]#
Execute Configure help to show the configure option and documentation
[[email protected] php-5.4.45]# ./configure help
configure: WARNING: you should use --build, --host, --target
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking build system type... Invalid configuration `help': machine `help' not recognized
configure: error: /bin/sh ./config.sub help failed
[[email protected] php-5.4.45]# ./configure --help
`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Find out where is apxs binary locate, you need this to compile libphp5.so, you don't necessary to find it or enable apsx on php if you use php-fpm instead 
[[email protected] php-5.4.45]# locate apxs
/root/httpd-2.4.37/docs/man/apxs.1
/root/httpd-2.4.37/docs/man/tr/apxs.1
/root/httpd-2.4.37/docs/manual/programs/apxs.html
/root/httpd-2.4.37/docs/manual/programs/apxs.html.en
/root/httpd-2.4.37/docs/manual/programs/apxs.html.fr.utf8
/root/httpd-2.4.37/docs/manual/programs/apxs.html.ko.euc-kr
/root/httpd-2.4.37/docs/manual/programs/apxs.html.tr.utf8
/root/httpd-2.4.37/docs/manual/programs/apxs.xml
/root/httpd-2.4.37/docs/manual/programs/apxs.xml.fr
/root/httpd-2.4.37/docs/manual/programs/apxs.xml.ko
/root/httpd-2.4.37/docs/manual/programs/apxs.xml.meta
/root/httpd-2.4.37/docs/manual/programs/apxs.xml.tr
/root/httpd-2.4.37/support/apxs
/root/httpd-2.4.37/support/apxs.in
/usr/local/apache2/bin/apxs
/usr/local/apache2/man/man1/apxs.1
/usr/local/apache2/manual/programs/apxs.html
/usr/local/apache2/manual/programs/apxs.html.en
/usr/local/apache2/manual/programs/apxs.html.fr.utf8
/usr/local/apache2/manual/programs/apxs.html.ko.euc-kr
/usr/local/apache2/manual/programs/apxs.html.tr.utf8
/usr/local/apache2/manual/programs/apxs.xml
/usr/local/apache2/manual/programs/apxs.xml.fr
/usr/local/apache2/manual/programs/apxs.xml.ko
/usr/local/apache2/manual/programs/apxs.xml.meta
/usr/local/apache2/manual/programs/apxs.xml.tr
[[email protected] php-5.4.45]#
Configure the php
[[email protected] php-5.4.45]# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --enable-sysvshm  --enable-sysvsem  --enable-sysvmsg --enable-shmop --disable-short-tags --with-openssl --with-pcre-regex --with-zlib --enable-bcmath --with-gettext --with-mcrypt --with-bz2 --enable-calendar --with-curl --enable-exif --with-gd --enable-intl --enable-mbstring --with-mysqli --enable-pcntl --with-pdo-mysql --enable-soap --enable-sockets --with-xmlrpc --enable-zip --with-jpeg-dir --with-png-dir --enable-wddx --enable-ftp --with-mhash
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
..
..
Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
[[email protected] php-5.4.45]#
Running make to compile the php

[[email protected] php-5.4.45]# make
/bin/sh /root/php-5.4.45/libtool --silent --preserve-dup-deps --mode=compile cc  -Iext/standard/ -I/root/php-5.4.45/ext/standard/ -DPHP_ATOM_INC -I/root/php-5.4.45/include -I/root/php-5.4.45/main -I/root/php-5.4.45 -I/root/php-5.4.45/ext/date/lib -I/root/php-5.4.45/ext/ereg/regex -I/usr/include/libxml2 -I/root/php-5.4.45/ext/mbstring/oniguruma -I/root/php-5.4.45/ext/mbstring/libmbfl -I/root/php-5.4.45/ext/mbstring/libmbfl/mbfl -I/root/php-5.4.45/ext/sqlite3/libsqlite -I/root/php-5.4.45/TSRM -I/root/php-5.4.45/Zend    -I/usr/include -g -O2 -fvisibility=hidden  -c /root/php-5.4.45/ext/standard/info.c -o ext/standard/info.lo
/bin/sh /root/php-5.4.45/libtool --silent --preserve-dup-deps --mode=compile cc  -I/usr/local/apache2/include  -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/usr/local/apache2/include   -I/usr/local/apache2/include  -Isapi/apache2handler/ -I/root/php-5.4.45/sapi/apache2handler/ -DPHP_ATOM_INC -I/root/php-5.4.45/include -I/root/php-5.4.45/main -I/root/php-5.4.45 -I/root/php-5.4.45/ext/date/lib -I/root/php-5.4.45/ext/ereg/regex -I/usr/include/libxml2 -I/root/php-5.4.45/ext/mbstring/oniguruma -I/root/php-5.4.45/ext/mbstring/libmbfl -I/root/php-5.4.45/ext/mbstring/libmbfl/mbfl -I/root/php-5.4.45/ext/sqlite3/libsqlite -I/root/php-5.4.45/TSRM -I/root/php-5.4.45/Zend    -I/usr/include -g -O2 -fvisibility=hidden   -c /root/php-5.4.45/sapi/apache2handler/mod_php5.c -o sapi/apache2handler/mod_php5.lo
/bin/sh /root/php-5.4.45/libtool --silent --preserve-dup-deps --mode=compile cc  -I/usr/local/apache2/include  -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/usr/local/apache2/include   -I/usr/local/apache2/include  -Isapi/apache2handler/ -I/root/php-5.4.45/sapi/apache2handler/ -DPHP_ATOM_INC -I/root/php-5.4.45/include -I/root/php-5.4.45/main -I/root/php-5.4.45 -I/root/php-5.4.45/ext/date/lib -I/root/php-5.4.45/ext/ereg/regex -I/usr/include/libxml2 -I/root/php-5.4.45/ext/mbstring/oniguruma -I/root/php-5.4.45/ext/mbstring/libmbfl 
..
..
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
directorytreeiterator.inc
pharcommand.inc
invertedregexiterator.inc
directorygraphiterator.inc
phar.inc

Build complete.
Don't forget to run 'make test'.

[[email protected] php-5.4.45]#
Install the php
[[email protected] php-5.4.45]# make install
Installing PHP SAPI module:       apache2handler
/usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apache2/build/libtool' libphp5.la /usr/local/apache2/modules
/usr/local/apache2/build/libtool --mode=install install libphp5.la /usr/local/apache2/modules/
libtool: install: install .libs/libphp5.so /usr/local/apache2/modules/libphp5.so
libtool: install: install .libs/libphp5.lai /usr/local/apache2/modules/libphp5.la
libtool: install: warning: remember to run `libtool --finish /root/php-5.4.45/libs'
chmod 755 /usr/local/apache2/modules/libphp5.so
[activating module `php5' in /usr/local/apache2/conf/httpd.conf]
Installing PHP CLI binary:        /usr/local/php5/bin/
Installing PHP CLI man page:      /usr/local/php5/php/man/man1/
Installing PHP CGI binary:        /usr/local/php5/bin/
Installing PHP CGI man page:      /usr/local/php5/php/man/man1/
Installing build environment:     /usr/local/php5/lib/php/build/
Installing header files:          /usr/local/php5/include/php/
Installing helper programs:       /usr/local/php5/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php5/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php5/lib/php/
[PEAR] Archive_Tar    - already installed: 1.3.12
[PEAR] Console_Getopt - already installed: 1.3.1
[PEAR] Structures_Graph- already installed: 1.0.4
[PEAR] XML_Util       - already installed: 1.2.3
[PEAR] PEAR           - already installed: 1.9.5
Wrote PEAR system config file at: /usr/local/php5/etc/pear.conf
You may want to add: /usr/local/php5/lib/php to your php.ini include_path
/root/php-5.4.45/build/shtool install -c ext/phar/phar.phar /usr/local/php5/bin
ln -s -f /usr/local/php5/bin/phar.phar /usr/local/php5/bin/phar
Installing PDO headers:          /usr/local/php5/include/php/ext/pdo/
[[email protected] php-5.4.45]#
Symlink the php to sbin directory
[[email protected] php-5.4.45]# ln -s /usr/local/php5/bin/php /sbin/php
[[email protected] php-5.4.45]# ls -l /sbin/php
lrwxrwxrwx. 1 root root 23 Nov  2 18:08 /sbin/php -> /usr/local/php5/bin/php
[[email protected] php-5.4.45]# php -v
PHP 5.4.45 (cli) (built: Nov  2 2018 17:57:18)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
[[email protected] php-5.4.45]#
[[email protected] php-5.4.45]#
Find out where is the php.ini configuration directory
[[email protected] php-5.4.45]# php -i | grep "Configuration"
Configuration File (php.ini) Path => /usr/local/php5/lib
Loaded Configuration File => (none)
Configuration
[[email protected] php-5.4.45]# php -i | grep "Scan "
Scan this dir for additional .ini files => (none)
[[email protected] php-5.4.45]#
Copy the php.ini template to php configuration directory
[[email protected] php-5.4.45]# cp php.ini-production /usr/local/php5/lib/php.ini
[[email protected] php-5.4.45]#
[[email protected] php-5.4.45]# service httpd restart
Shutting down httpd:                                       [  OK  ]
Starting httpd: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
                                                           [  OK  ]
[[email protected] php-5.4.45]# php -i | grep "Configuration"
Configuration File (php.ini) Path => /usr/local/php5/lib
Loaded Configuration File => /usr/local/php5/lib/php.ini
Configuration
PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0
[[email protected] php-5.4.45]#

Open the php.ini configuration file
[[email protected] php-5.4.45]# vi /usr/local/php5/lib/php.ini
[[email protected] php-5.4.45]#
Check the libphp5.so module, this need for integration with apache web server except you use php-fpm instead
[[email protected] php-5.4.45]# ls /usr/local/apache2/modules/libphp5.so
/usr/local/apache2/modules/libphp5.so
[[email protected] php-5.4.45]#
Setup the date time zone with your time zone like following figure
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
date.timezone = Asia/Jakarta
Restart the apache service again
[[email protected] php-5.4.45]# service httpd restart
Shutting down httpd:                                       [  OK  ]
Starting httpd: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
                                                           [  OK  ]
[[email protected] php-5.4.45]# php -i | grep "Configuration"
Configuration File (php.ini) Path => /usr/local/php5/lib
Loaded Configuration File => /usr/local/php5/lib/php.ini
Configuration
[[email protected] php-5.4.45]#




Tidak ada komentar :

Posting Komentar