- Установка PHP из исходников
- Шаг 1. Подготовка среды
- Шаг 2. Загружаем исходники
- Шаг 3. Производим конфигурацию
- Распространенные ошибки при компилировании
- Ошибка #1
- Решение #1
- Ошибка #2
- Решение #2
- Ошибка #3
- Решение #3
- Ошибка #4
- Решение #4
- Ошибка #5
- Решение #5
- Ошибка #6
- Решение #6
- Ошибка #7
- Решение #7
- Ошибка #8
- Решение #8
- Ошибка #9
- Решение #9
- Ошибка #10
- Решение #10
- Ошибка #11
- Решение #11
- Ошибка #12
- Решение #12
- Ошибка #13
- Решение #13
- Ошибка #14
- Решение #14
- Ошибка #15
- Решение #15
- Ошибка #16
- Решение #16
- Ошибка #17
- Решение #17
- Saved searches
- Use saved searches to filter your results more quickly
- License
- php/php-src
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
Установка 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 \
При успешной конфигурации вывод будет приблизительно следующим:
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
Распространенные ошибки при компилировании
Ошибка #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.
Решение #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
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
License
php/php-src
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
* PHP-8.2: Fix GH-11716: cli server crashes on SIGINT when compiled with ZEND_RC_DEBUG=1
Git stats
Files
Failed to load latest commit information.
README.md
PHP is a popular general-purpose scripting language that is especially suited to web development. Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world. PHP is distributed under the PHP License v3.01.
The PHP manual is available at php.net/docs.
Prebuilt packages and binaries
Prebuilt packages and binaries can be used to get up and running fast with PHP.
For Windows, the PHP binaries can be obtained from windows.php.net. After extracting the archive the *.exe files are ready to use.
For other systems, see the installation chapter.
For a minimal PHP build from Git, you will need autoconf, bison, and re2c. For a default build, you will additionally need libxml2 and libsqlite3.
On Ubuntu, you can install these using:
sudo apt install -y pkg-config build-essential autoconf bison re2c \ libxml2-dev libsqlite3-dev
On Fedora, you can install these using:
sudo dnf install re2c bison autoconf make libtool ccache libxml2-devel sqlite-devel
Configure your build. —enable-debug is recommended for development, see ./configure —help for a full list of options.
# For development ./configure --enable-debug # For production ./configure
Build PHP. To speed up the build, specify the maximum number of jobs using -j :
The number of jobs should usually match the number of available cores, which can be determined using nproc .
PHP ships with an extensive test suite, the command make test is used after successful compilation of the sources to run this test suite.
It is possible to run tests using multiple cores by setting -jN in TEST_PHP_ARGS :
make TEST_PHP_ARGS=-j4 test
Shall run make test with a maximum of 4 concurrent jobs: Generally the maximum number of jobs should not exceed the number of cores available.
The qa.php.net site provides more detailed info about testing and quality assurance.
Installing PHP built from source
After a successful build (and test), PHP may be installed with:
Depending on your permissions and prefix, make install may need super user permissions.
Extensions provide additional functionality on top of PHP. PHP consists of many essential bundled extensions. Additional extensions can be found in the PHP Extension Community Library — PECL.
The PHP source code is located in the Git repository at github.com/php/php-src. Contributions are most welcome by forking the repository and sending a pull request.
Discussions are done on GitHub, but depending on the topic can also be relayed to the official PHP developer mailing list internals@lists.php.net.
New features require an RFC and must be accepted by the developers. See Request for comments — RFC and Voting on PHP features for more information on the process.
Bug fixes don’t require an RFC. If the bug has a GitHub issue, reference it in the commit message using GH-NNNNNN . Use #NNNNNN for tickets in the old bugs.php.net bug tracker.
Fix GH-7815: php_uname doesn't recognise latest Windows versions Fix #55371: get_magic_quotes_gpc() throws deprecation warning
See Git workflow for details on how pull requests are merged.
Guidelines for contributors
See further documents in the repository for more information on how to contribute:
For the list of people who’ve put work into PHP, please see the PHP credits page.