PHP5FromSource

Differences between revisions 7 and 10 (spanning 3 versions)
Revision 7 as of 2005-11-22 21:00:42
Size: 7246
Editor: 200
Comment: corrects a bug compilling php5 with support for mysql and mysqli simultaneous.
Revision 10 as of 2008-08-06 16:14:11
Size: 1168
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
'''Note:''' There are currently three PHP5 pages on the wiki, this one, ["PHP5Installation"] and ["PHP5Installation2"]. If you're able to edit them down to just one page, please do! Remember to add redirects from the two pages you black, though - don't just delete those pages. Download the PHP source from http://php.net. It will be in compressed format, so decompress it using the related utility for whichever compression format you choose to download.
Line 3: Line 3:
PHP4 does not require any special assembly or compiling; see ["ApacheMySQLPHP"] for PHP4 instructions. From the root of the decompressed folder, type the command below and append whatever additional parameters are needed to configure the installation to your liking.
Line 5: Line 5:
Tested in Hoary and Breezy.

== Prerequisites ==

=== You must download PHP5 (of course ;) ===
Line 11: Line 6:
wget http://www.php.net/get/php-5.0.4.tar.bz2/from/ie.php.net/mirror
tar jxf php-5.0.4.tar.bz2
cd php-5.0.4/
}}}
 
=== You must install packages : ===
{{{
sudo apt-get install make g++ flex bison build-essential zlib1g-dev
}}}

=== You must have a webserver : ===
(apache2-prefork is better because it is thread safe)
{{{
sudo apt-get install apache2-mpm-prefork apache2-prefork-dev
}}}
(you can install with apache2-mpm-worker, but you need to delete the --with-tsrm-pthreads)

(you also can install Apache 1 (no problem with thread there)

=== You need a Mysql Database I Think : ===
(not necessary, but recommended)

Choose between 4.0 and 4.1

__Mysql 4.0__
{{{
sudo apt-get install libmysqlclient12-dev mysql-server
}}}
'''OR'''

__Mysql 4.1__
{{{
sudo apt-get install libmysqlclient14-dev mysql-server-4.1
}}}

=== You need development libraries ===
We will install PHP with a lot of options (mcrypt, mhash, bz2, xml, tidy...)
{{{
sudo apt-get install libmcrypt-dev libmhash-dev libxslt1-dev libtidy-dev libbz2-dev libxml2-dev libssl-dev
./configure
Line 53: Line 10:
If you install GD (it is in my configuration below) Any issues at this point should be the result of not having needed packages installed for any additional configurations you specified earlier. Install packages and repeat this process as necessary until the process completes successfully.

Now type:
Line 55: Line 15:
sudo apt-get install libpng12-dev libjpeg62-dev libxpm-dev libfreetype6-dev freetype2 freetype2-dev make
Line 58: Line 18:
You have two options at this point:
Line 59: Line 20:
Enable the multiverse repository to have the msttcorefonts (Useful for TrueType fonts with GD).
The symbolic links is to Jpgraph to work without changing the configuration.
1) This is the recommended method, as it allows for easy uninstallation. Make sure the checkinstall package is installed, then type:
Line 62: Line 23:
sudo apt-get install msttcorefonts
ln -sfn /usr/share/fonts/truetype/msttcorefonts/ /usr/X11R6/lib/X11/fonts/truetype
sudo checkinstall
Line 66: Line 26:
2) Type:
Line 67: Line 28:
== Compilation optimisation ==

You can speed up PHP with processor optimisation (optional)

If you have a different processor, change the CHOST, CFLAGS, CXXFLAGS.

If you don't know what it is, this 3 lines are optional, so don't do it !

 * Athlon-tbird XP (AMD)
Line 77: Line 29:
export CHOST="i686-pc-linux-gnu"
export CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer -msse -mmmx -mfpmath=sse"
export CXXFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer -msse -mmmx -mfpmath=sse"
sudo make install
Line 82: Line 32:
 * Pentium 4 (Intel) Once this is done, type this:
Line 84: Line 35:
export CHOST="i686-pc-linux-gnu"
export CFLAGS="-march=pentium4 -mcpu=pentium4 -O3 -pipe -fomit-frame-pointer -msse -mmmx -mfpmath=sse"
export CXXFLAGS="-march=pentium4 -mcpu=pentium4 -O3 -pipe -fomit-frame-pointer -msse -mmmx -mfpmath=sse"
ln -s /usr/local/bin/php /usr/bin/php
Line 89: Line 38:
== Configuration ==
This is a full configuration.

Do it in the PHP5 folder.

You can add/delete some of the options if you don't need it.

It is a strict PHP (no short tags, safe mode, no magic quotes etc...), but you can change it if you prefer or if some scripts doesn't work.

If you use Apache 1, change the {{{--with-apxs2=/usr/bin/apxs2}}} with {{{--with-apxs=/usr/bin/apxs}}}

If you have only Mysql 4.0, delete the {{{--with-mysqli=/usr/bin/mysql_config}}}
It is only with Mysql 4.1 !

You should point {{{--with-mysql}}} to the base directory of your mysql and {{{--with-mysqli}}} to the {{{mysql_config}}} file. Keep this in mind especially when you install php with support to a Mysql that you compilled yourself.
Not doing this will result in an error similar to the following.
Line 107: Line 41:
./configure \
--quiet \
--disable-cli \
--disable-cgi \
--disable-all \
--disable-rpath \
--disable-debug \
--disable-path-info-check \
--disable-magic-quotes \
--disable-posix \
--disable-short-tags \
--disable-ipv6 \
--disable-static \
--disable-pcntl \
--without-pear \
--with-apxs2=/usr/bin/apxs2 \
--with-mysql=/usr \
--with-mysqli=/usr/bin/mysql_config \
--with-zlib \
--with-bz2 \
--with-dbx \
--with-ctype \
--with-openssl \
--with-pcre-regex \
--with-gettext \
--with-mcrypt \
--with-mhash \
--with-iconv \
--with-sqlite \
--with-sqlite-utf8 \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-xpm-dir \
--with-ttf \
--with-xsl \
--with-tsrm-pthreads \
--with-tidy \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-safe-mode \
--enable-calendar \
--enable-mbstring \
--enable-spl \
--enable-ftp \
--enable-bcmath \
--enable-sockets \
--enable-dom \
--enable-xml \
--enable-soap \
--enable-libxml \
--enable-session \
--enable-simplexml \
--enable-memory-limit
bash: /usr/bin/php: No such file or directory
Line 164: Line 44:
'''ATTENTION'''

If you want to use both the old mysql and the new mysqli interface, load the Makefile into your editor and search for the line beginning with EXTRA_LIBS; it includes -lmysqlclient twice; remove the second instance. Do this before running the 'make' command or you'll get compilation errors.

{{{
make -s \
&& sudo make install \
&& sudo /etc/init.d/apache2 stop \
&& sudo /etc/init.d/apache2 start
}}}


The installation had automatically add PHP5 module to Apache Configuration


=== Testing ===
{{{
sudo echo "<?php phpinfo(); ?>" > /var/www/phpinfo.php
mozilla-firefox http://localhost/phpinfo.php
}}}

=== Comments ===

From AdrianFisher Sun May 22 13:21:42 +0100 2005
From: Adrian Fisher
Date: Sun, 22 May 2005 13:21:42 +0100
Subject: Error messages and problems
Message-ID: <20050522132142+0100@https://www.ubuntulinux.org>

These are the messages I get when I run the configuration script. It comes up after the PHP license box so I have been unable to finish the installation :(

rm: cannot remove `.libs/libphp5.la': Permission denied
rm: cannot remove `.libs/libphp5.la': Permission denied
rm: cannot remove `.libs/libphp5.lai': Permission denied
rm: cannot remove `.libs/libphp5.so': Permission denied
rm: cannot remove `.libs/libphp5.la': Permission denied
rm: cannot remove `.libs/libphp5.lai': Permission denied
rm: cannot remove `.libs/libphp5.so': Permission denied
/usr/bin/ld: cannot open output file .libs/libphp5.so: Permission denied
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1

I also typed in http://localhost and it brings up a directory on-screen by the name of "apache2-default" and I am unable to use the lines from the testing section as when I try to create the file as mentioned in the first line I get the error message

"bash: /var/www/phpinfo.php: Permission denied".

Any help would be appreciated, thanks in advance.

From CarlosVogel Thu May 26 19:18:17 +0100 2005
From: Carlos Vogel
Date: Thu, 26 May 2005 19:18:17 +0100
Subject: Error in make
Message-ID: <20050526191817+0100@https://www.ubuntulinux.org>

The installation does not work to me.

when executing make, it happens the following error:

user@ubuntu:/php-5.0.4$ make -s
php-5.0.4/ext/sqlite/libsqlite/src/parse.y:19.1-13: directiva no válida: `%token_prefix'
php-5.0.4/ext/sqlite/libsqlite/src/parse.y:19.15-17: syntax error, unexpected "identifier"
make: *** [php-5.0.4/ext/sqlite/libsqlite/src/parse.c] Error 1

Help me please.

thanks.

CategoryDocumentation CategoryCleanup
Once this is done, you should be able to use PHP normally.

Download the PHP source from http://php.net. It will be in compressed format, so decompress it using the related utility for whichever compression format you choose to download.

From the root of the decompressed folder, type the command below and append whatever additional parameters are needed to configure the installation to your liking.

./configure

Any issues at this point should be the result of not having needed packages installed for any additional configurations you specified earlier. Install packages and repeat this process as necessary until the process completes successfully.

Now type:

make

You have two options at this point:

1) This is the recommended method, as it allows for easy uninstallation. Make sure the checkinstall package is installed, then type:

sudo checkinstall

2) Type:

sudo make install

Once this is done, type this:

ln -s /usr/local/bin/php /usr/bin/php

Not doing this will result in an error similar to the following.

bash: /usr/bin/php: No such file or directory

Once this is done, you should be able to use PHP normally.