Php make install directory

Установка PHP из исходников

Порой необходимо поставить версию PHP “морально устаревшую”. К сожалению попадаются такие проекты, которые не хотят переписывать сайты и готовы существовать на старом ПО. Статья именно про такой случай.

Шаг 1. Подготовка среды

Установим инструменты для сборки

yum install wget
yum groupinstall «Development Tools»

Шаг 2. Загружаем исходники

(В примере рассматривается вариант с версией 5.3.28, но процесс сборки ничем не отличается и для других версий, за редким исключением)

Скачиваем необходимую версию PHP с сайта разработчика

wget http://fr2.php.net/distributions/php-5.3.28.tar.gz
tar -xvf php-5.3.28.tar.gz
cd php-5.3.28

Шаг 3. Производим конфигурацию

Конфигурация производится с включением/отключением необходимых модулей, поэтому следует заранее подготовиться.
Указываем опцию —with-config-file-path=/etc , чтобы файл конфигурации был в папке /etc , а не в /usr/local/lib , как идет по умолчанию в Unix системах.

Начинаем процесс конфигурации

(В случае получения ошибок в процессе конфигурации, информацию по их исправлению можно найти дальше в статье )

./configure \
—prefix=/usr/local \
—with-layout=PHP \
—with-pear \
—with-apxs2 \
enable-calendar \
enable-bcmath \
—with-gmp \
enable-exif \
—with-mcrypt \
—with-mhash \
—with-zlib \
—with-bz2 \
enable-zip \
enable-ftp \
enable-mbstring \
—with-iconv \
enable-intl \
—with-icu-dir=/usr \
—with-gettext \
—with-pspell \
enable-sockets \
—with-openssl \
—with-curl \
—with-curlwrappers \
—with-gd \
enable-gd-native-ttf \
—with-libdir=lib64 \
—with-jpeg-dir=/usr \
—with-png-dir=/usr \
—with-zlib-dir=/usr \
—with-xpm-dir=/usr \
—with-vpx-dir=/usr \
—with-freetype-dir=/usr \
—with-t1lib=/usr \
—with-libxml-dir=/usr \
—with-mysql=mysqlnd \
—with-mysqli=mysqlnd \
—with-pdo-mysql=mysqlnd \
—with-config-file-path=/etc \
enable-exif \
enable-shmop \
enable-wddx \
enable-soap \
—with-xmlrpc \
—with-xsl \
—with-tidy=/usr \
—with-readline \
enable-pcntl \
enable-sysvshm \
enable-sysvmsg \
enable-shmop \

Читайте также:  Import time datetime python

При успешной конфигурации вывод будет приблизительно следующим:

Generating files
updating cache ./config.cache
creating ./config.status
creating php5.spec
creating main/build-defs.h
creating scripts/phpize
creating scripts/man1/phpize.1
creating scripts/php-config
creating scripts/man1/php-config.1
creating sapi/cli/php.1
creating main/php_config.h
creating main/internal_functions.c
creating main/internal_functions_cli.c
+———————————————————————+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+———————————————————————+

Thank you for using PHP.

Notice: Following unknown configure options were used:

—with-vpx-dir=/usr

Check ‘./configure —help’ for available options

Производим сборку

Вывод при успешной сборке будет приблизительно следующий:

Installing PHP SAPI module: apache2handler
/usr/lib64/httpd/build/instdso.sh SH_LIBTOOL=‘/usr/lib64/apr-1/build/libtool’ libphp5.la /usr/lib64/httpd/modules
/usr/lib64/apr-1/build/libtool —mode=install cp libphp5.la /usr/lib64/httpd/modules/
libtool: install: cp .libs/libphp5.so /usr/lib64/httpd/modules/libphp5.so
libtool: install: cp .libs/libphp5.lai /usr/lib64/httpd/modules/libphp5.la
libtool: install: warning: remember to run `libtool —finish /tmp/php-5.3.28/libs
chmod 755 /usr/lib64/httpd/modules/libphp5.so
[activating module `php5′ in /etc/httpd/conf/httpd.conf]
Installing PHP CLI binary: /usr/local/bin/
Installing PHP CLI man page: /usr/local/man/man1/
Installing build environment: /usr/local/lib/php/build/
Installing header files: /usr/local/include/php/
Installing helper programs: /usr/local/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/lib/php/
[PEAR] Archive_Tar — installed: 1.3.11
[PEAR] Console_Getopt — installed: 1.3.1
warning: pear/PEAR requires package «pear/Structures_Graph» (recommended version 1.0.4)
warning: pear/PEAR requires package «pear/XML_Util» (recommended version 1.2.1)
[PEAR] PEAR — installed: 1.9.4
Wrote PEAR system config file at: /usr/local/etc/pear.conf
You may want to add: /usr/local/lib/php to your php.ini include_path
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util — installed: 1.2.1
/tmp/php-5.3.28/build/shtool install -c ext/phar/phar.phar /usr/local/bin
ln -s -f /usr/local/bin/phar.phar /usr/local/bin/phar
Installing PDO headers: /usr/local/include/php/ext/pdo/
[[email protected] php-5.3.28]# php -v
PHP 5.3.28 (cli) (built: May 28 2015 23:29:01)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

Читайте также:  Java graphics2d draw point

Распространенные ошибки при компилировании

Ошибка #1

Sorry, I cannot run apxs. Possible reasons follow:

1. Perl is not installed
2. apxs was not found. Try to pass the path using —with-apxs2=/path/to/apxs
3. Apache was not built using —enable-so (the apxs usage page is displayed)

The output of apxs follows:
./configure: line 6372: apxs: command not found
configure: error: Aborting

Решение #1

Ошибка #2

checking libxml2 install dir. /usr
checking for xml2-config path.
configure: error: xml2-config not found. Please check your libxml2 installation.

Решение #2

yum install libxml2 libxml2-devel

Ошибка #3

checking for pkg-config. /usr/bin/pkg-config
configure: error: Cannot find OpenSSL‘s

Решение #3

yum install openssl openssl-devel

Ошибка #4

checking for BZip2 support. yes
checking for BZip2 in default path. not found
configure: error: Please reinstall the BZip2 distribution

Решение #4

yum install bzip2 bzip2-devel

Ошибка #5

checking for cURL in default path. not found
configure: error: Please reinstall the libcurl distribution —
easy.h should be in /include/curl/

Решение #5

yum install curl curl-devel

Ошибка #6

configure: error: jpeglib.h not found.

Решение #6

yum install libjpeg libjpeg-devel

Ошибка #7

configure: error: png.h not found.

Решение #7

yum install libpng libpng-devel

Ошибка #8

configure: error: libXpm.(a|so) not found.

Решение #8

Ошибка #9

configure: error: freetype.h not found.

Решение #9

yum install freetype-devel

Ошибка #10

configure: error: Your t1lib distribution is not installed correctly. Please reinstall it.

Решение #10

Ошибка #11

checking for GNU MP support. yes
configure: error: Unable to locate gmp.h

Решение #11

Ошибка #12

checking for location of ICU headers and libraries. not found
configure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.

Читайте также:  Java degrees to radians

Решение #12

Ошибка #13

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

Решение #13

yum install libmcrypt libmcrypt-devel

Ошибка #14

configure: error: Cannot find pspell

Решение #14

Ошибка #15

configure: error: Please reinstall readline — I cannot find readline.h

Решение #15

yum install readline-devel

Ошибка #16

checking for TIDY support. yes
configure: error: Cannot find libtidy

Решение #16

yum install libtidy libtidy-devel

Ошибка #17

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

Решение #17

Источник

Оцените статью