Home >Backend Development >PHP Problem >Linux php installation and configuration method

Linux php installation and configuration method

藏色散人
藏色散人Original
2020-12-02 09:26:062266browse

How to install and configure Linux PHP: first obtain the support files needed to install PHP; then install libxml2; then install PHP5 through "make install"; and finally reconfigure apache2 to support PHP.

Linux php installation and configuration method

Recommended: "PHP Video Tutorial"

The operating environment of this tutorial: linux5.9.8 system, PHP5.3.8 version, this method is applicable to all brands of computers.

The example in this article describes how to install and configure the PHP environment on Linux. Share it with everyone for your reference, the details are as follows:

1. Get the installation file: http://www.php.net/downloads.php php-5.3.8.tar.gz

Get the support files needed to install php: http://download.csdn.net/download/netlong339/1351852 libxml2-2.6.32.tar.gz

2. Installation libxml2

The code is as follows:

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

If the installation is successful, bin, include, lib, man and share will be generated in the /usr/local/libxml2/ directory directory. When installing the configuration of the PHP5 source code package later, the "--with-libxml-dir=/usr/local/libxml2" option will be added to the options of the configure command to specify the location where the libxml2 library file is installed.

3. Install php5

The code is as follows:

#tar zvxf php-5.3.8.tar.gz
#cd php-5.3.8
#./configure \
--prefix=/usr/local/php \
--with-mysql=/usr/local/mysql \
--with-apxs=/usr/local/apache2/bin/apxs \
--enable-fastcgi \
--enable-fpm
#make
#make install

4.Reconfigure apache2 to support php

① Configure httpd.conf to let apache support PHP:

The code is as follows:

# vi /usr/local/apache/conf/httpd.conf

Find AddType application/x-gzip .gz .tgz and add it under it The following content

AddType application/x-httpd-php .php (.前面有空格)
AddType application/x-httpd-php-source .phps (.前面有空格)

② Then the CPOPY PHP configuration file

code is as follows:

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

(If there is no php.ini.dist, put php.ini-development Just rename any one in php.ini-production to php.ini.dist.)

Modify the php.ini file

The code is as follows:

register_globals = On

③ Restart apache

The code is as follows:

service apache restart

5. Test whether php is successfully installed

Write a php test page info.php and put it in in apache2/htdocs.

<?php
 phpinfo();
?>

Enter in the browser: server address/info.php

If the php information can be displayed normally, it means that Apche Mysql PHP is installed successfully!

The above is the detailed content of Linux php installation and configuration method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to hide .php in nginxNext article:How to hide .php in nginx