Page 1 of 1

Install PHP 5.6.20 and 7.0.5

Posted: Wed Apr 27, 2016 3:16 pm
by cah

Code: Select all

./configure --with-apxs2=/usr/local/apache2/bin/apxs CFLAGS=-std=gnu99 --without-iconv
make
Some bugs in PHP source and make couldn't proceed. Added a comment in bug# 71619 (https://bugs.php.net/bug.php?id=71619&thanks=3).

Code: Select all

# /bin/sh /work/applications/php-5.6.20/libtool --silent --preserve-dup-deps --mode=compile cc  -Imain/ -I/work/applications/php-5.6.20/main/ -DPHP_ATOM_INC -I/work/applications/php-5.6.20/include -I/work/applications/php-5.6.20/main -I/work/applications/php-5.6.20 -I/work/applications/php-5.6.20/ext/date/lib -I/work/applications/php-5.6.20/ext/ereg/regex -I/usr/include/libxml2 -I/work/applications/php-5.6.20/ext/sqlite3/libsqlite -I/work/applications/php-5.6.20/TSRM -I/work/applications/php-5.6.20/Zend  -D_POSIX_PTHREAD_SEMANTICS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT  -I/usr/local/include -std=gnu99 -DZTS  -c /work/applications/php-5.6.20/main/php_open_temporary_file.c -o main/php_open_temporary_file.lo 
/work/applications/php-5.6.20/main/php_open_temporary_file.c:187: error: thread-local storage not supported for this target
make: *** [main/php_open_temporary_file.lo] Error 1
Found out why it was failing.
It was because there was a "cc" (gcc 3.4.6) in /usr/local/bin. "configure" for some reason picked up cc in /usr/local/bin instead of gcc in /usr/bin (/usr/bin is the 1st in $PATH though).
I had to rename both cc and gcc in /usr/local/bin to gcc_3.4.6 to avoid the confusion.

After making the change, gcc started working. However, there are undefined symbols found during compilation.

Code: Select all

Undefined                       first referenced
 symbol                             in file
libiconv_close                      /var/tmp//cc_5a4JM.o
libiconv_open                       /var/tmp//cc_5a4JM.o
I read it on the internet, someone tried to install libiconv in a non-standard location (default is /usr/local) and include iconv in configure line in PHP.

libiconv

Code: Select all

# cd /work/applications/libiconv-1.14/
# ./configure --prefix=/usr/local/iconv
# make
# make install
The proven working configure line is:

Code: Select all

./configure --with-apxs2=/usr/local/apache2/bin/apxs CFLAGS=-std=gnu99 --with-mysql --with-mysqli --with-iconv=/usr/local/iconv
NOTICE: PHP 7.0.5 does NOT have "--with-mysql" feature.

Code: Select all

./configure --with-apxs2=/usr/local/apache2/bin/apxs CFLAGS=-std=gnu99 --with-mysqli --with-iconv=/usr/local/iconv
The above undefined symbols disappeared!
Following commands to complete the compilation and installation of PHP.

Code: Select all

# make
make test
make install
Follow the steps below to complete PHP installation.

Code: Select all

cp php.ini-development /usr/local/lib/php.ini

Edit your httpd.conf to load the PHP module. The path on the right hand side of the LoadModule statement must point to the path of the PHP module on your system. The make install from above may have already added this for you, but be sure to check.

For PHP 7:

Code: Select all

LoadModule php7_module modules/libphp7.so
For PHP 5:

Code: Select all

LoadModule php5_module modules/libphp5.so
Tell Apache to parse certain extensions as PHP. For example, let's have Apache parse .php files as PHP. Instead of only using the Apache AddType directive, we want to avoid potentially dangerous uploads and created files such as exploit.php.jpg from being executed as PHP. Using this example, you could have any extension(s) parse as PHP by simply adding them. We'll add .php to demonstrate.

Code: Select all

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>
Or, if we wanted to allow .php, .php2, .php3, .php4, .php5, .php6, and .phtml files to be executed as PHP, but nothing else, we'd use this:

Code: Select all

<FilesMatch "\.ph(p[2-6]?|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
And to allow .phps files to be handled by the php source filter, and displayed as syntax-highlighted source code, use this:

Code: Select all

<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>
mod_rewrite may be used To allow any arbitrary .php file to be displayed as syntax-highlighted source code, without having to rename or copy it to a .phps file:

Code: Select all

RewriteEngine On
RewriteRule (.*\.php)s$ $1 [H=application/x-httpd-php-source]
The php source filter should not be enabled on production systems, where it may expose confidential or otherwise sensitive information embedded in source code.

Both versions compiled successfully. However, phpBB 3.1.x does NOT work with PHP 7 (code differences). Some say phpBB version 3.2.x may start supporting PHP 7. Therefore, the environment stays with PHP 5.6.20 for now.

NOTICE: Apache does not like both php versions to be included. If both php5 and php7 modules are loaded, it will crash with a core file. Keep one module at any given time in httpd.conf.

Code: Select all

LoadModule php5_module        modules/libphp5.so
#LoadModule php7_module        modules/libphp7.so
...
    AddHandler php5-script .php
    #AddHandler php7-script .php