Installation tutorials for PHP in Linux

  • 2020-05-13 04:23:43
  • OfStack

1. Download the installation package

http://www.php.net/downloads.php

Get download address

wget

http://hk1.php.net/distributions/php-7.0.13.tar.gz
http://xmlsoft.org
ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz

2. Install python - devel

centos install python-dev package No package python-dev available:

The reason for this problem is that python-dev's package is not called python-dev in yum of centos, but python-devel.

So install python-dev with the following command:


yum install python-devel

1. Check out the package with python-devel first


yum search python | grep python-devel

2.64-bit install python-devel. x86_64, 32-bit install python-devel. i686, I install it here:


yum install python-devel.x86_64

After successful installation:

rpm -qa |grep python-devel

3. Install libxml2 (requires step 2)


tar zxvf libxml2-2.9.4.tar.gz 
cd libxml2-2.9.1.
./configure --prefix=/usr/local/libxml2 
make
make install

If the installation is successful, five directories, bin, include, lib, man, and share2, will be generated under /usr/local/libxml2/.

When you install the configuration of the PHP5 source code package later, you will add "-- with-libxml-dir =/usr/ local/libxml2" option to the configure command.

Used to specify the location where the libxml2 library files are installed.

3. Install php


#tar zvxf php-5.5.4.tar.gz 
#cd php-5.5.4
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache-httpd/bin/apxs --with-libxml-dir=/usr/local/libxml2
#make 
#make install 

4. Reconfigure apache-httpd to support php

Configure httpd.conf to enable apache to support PHP:


  # vi /usr/local/apache2/conf/httpd.conf
 find  AddType application/x-gzip .gz .tgz  Add the following below 
AddType application/x-httpd-php .php (. There's a space in front of it )
   AddType application/x-httpd-php-source .phps (. There's a space in front of it )

Then the CPOPY PHP configuration file


cp php-5.5.4/php.ini.dist /usr/local/php/lib/php.ini 

(if there is no php.ini.dist, rename any one of php.ini-development php.ini-production to php.dist.)

Modify php.ini file to add register_globals = On

Restart apache - httpd


Related articles: