I assume you've installed the apache webserver and mysql, because php, apache, mysql is an integral and inseparable.
1. Download PHP
Download php from the official website here, looking for a stable version, in which case I'm using version 5.2.6, then open a terminal and type the following line
moved to /usr/local/src
#bzip2-d php-5.2.6.tar.bz2
#tar xvf php-5.2.6.tar
2. Install PHP
see all the configuration by typing. / configure - help or type the following line
#cd php-5.2.6
#./configure --help
php in the example below will be compiled and installed in the default location is / usr / local / lib with the configuration of apache and mysql support
#./configure - with-apxs2= /usr/local/apache2/bin/apxs - with-mysql
#make
#make install
#cp php.ini-dist /usr/local/lib/php.ini
3. Configure httpd.conf for PHP
change the file in /usr/local/apache2/conf/httpd.conf and add the following line
SetHandler application / x-httpd-php
</ FilesMatch>
The next load module php5_module, see example below
LoadModule php5_module modules/libphp5.so
then restart your apache webserver
# /usr/local/bin/apache2/apachectl restart
4. Check the PHP installation
create a file named test.php in /usr/localapache2/htdocs, see example below
#nano test.php
go to localhost/test.php and binggo, php has been successfully installed on our computers.
Some of the mistakes that we might get later on during the installation process
Error 1: configure: error: xml2-config not found:
While performing the. /configure PHP during installation, you may get the Following error:
#./configure - with-apxs2 = /usr/local/apache2/bin/apxs - with-mysql
configuring extensions
checking whether to enable libxml support ... yes
checking libxml2 install dir ... no
checking for xml2-config path ...
configure: error: xml2-config not found. Please check your libxml2 installation.
Install thelibxml2-devel and zlib-devel as shown below to the fix this issue.
#rpm-ivh /home/downloads/linux-iso/libxml2-devel-2.6.26-2.1.2.0.1.i386.rpm /home/downloads/linux-iso/zlib-devel-1.2.3-3.i386 . rpm
Preparing ... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
1: zlib-devel # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [50 %]
2: libxml2-devel # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100 %]
Error 2: configure: error: Can not find MySQL header files.
While performing the. /Configure PHP during installation, you may get the Following error:
#./configure - with-apxs2 = /usr/local/apache2/bin/apxs - with-mysql
checking for MySQL UNIX socket location ... /var/lib/mysql/mysql.sock
configure: error: Can not find MySQL header files under yes.
Note That the MySQL client library is not bundled anymore!
Install the MySQL-devel-community package as shown below to fix this issue.
#rpm-ivh /home/downloads/MySQL-devel-community-5.1.25-0.rhel5.i386.rpm
Preparing ... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
1: MySQL-devel-community # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
Finally, good luck and have a nice day
References PHP Manual
Very informative, keep posting such good articles, it really helps to know about things.
BalasHapus