1. Get installation files: http://www.php.net/downloads.php php-5.3.8.tar.gz
To obtain the support files needed to install PHP: http://download.111cn.net/download/netlong339/1351852 libxml2-2.6.32.tar.gz
2. Install LIBXML2
| The code is as follows |
Copy Code |
|
1 tar zxvf libxml2-2.6.32.tar.gz
2 CD libxml2-2.6.32
3./configure--PREFIX=/USR/LOCAL/LIBXML2
4 Make
5 Make Install |
If the installation is successful, the bin, include, Lib, man, and share five directories will be generated under the/USR/LOCAL/LIBXML2/directory. When you install the PHP5 source package configuration Later, you specify where to install LIBXML2 library files by adding the "--with-libxml-dir=/usr/local/libxml2" option to the Configure command.
3. Install php5 (install LIBXML2 before installing PHP5)
| The code is as follows |
Copy Code |
#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
--with-libxml-dir=/usr/local/libxml2
#make recommend that make and make install be executed separately
#make Install |
4. Reconfigure apache2 let him support PHP
Configure httpd.conf let Apache support PHP: (Note: The default installation of PHP in the path in/etc/php5/php.ini (add AddType here), the following httpd.conf is a blank file OH. , )
| The code is as follows |
Copy Code |
|
# vi/usr/local/apache/conf/httpd.conf
Find AddType application/x-gzip gz. tgz to add the following content below
AddType application/x-httpd-php. PHP (. Preceded by a space)
AddType application/x-httpd-php-source. Phps (. Preceded by a space) |
Then cpopy the PHP configuration file
| The code is as follows |
Copy Code |
| CP Php-5.3.8/php.ini.dist/usr/local/php/lib/php.ini |
(If there is no php.ini.dist, rename any one of the php.ini-development php.ini-production to Php.ini.dist.) )
Modify php.ini file Register_globals = On
Restart Apache
| The code is as follows |
Copy Code |
| Service Apache Restart |
5. Test whether PHP is installed successfully
Write a PHP test page info.php and put it into the apache2/htdocs.
| The code is as follows |
Copy Code |
|
<?php
Phpinfo ();
?>; |
Enter in Browser: server address/info.php
If the normal display of PHP information, then the apche+mysql+php installation success!
Another method:
First, install Apache
Next, let's start by introducing how to install Apache. The specific installation command looks like this:
| The code is as follows |
Copy Code |
|
$ sudo apt-get install apache2 |
Then run Apache, and the command looks like this:
| The code is as follows |
Copy Code |
|
$ sudo/etc/init.d/apache2 Restart |
Apache will create a new directory during installation:/var/www, which is the root directory where documents are stored in the server. All documents placed in this directory can be accessed as long as the IP address of the http://localhost/or machine is entered in the address bar of the browser.
Second, the installation of PHP
PHP is a popular server-side scripting language that is typically combined with MySQL or postgres to manage Web content, blogs, and forums. Here's how to install it, but it's also very simple to install, and the command looks like this:
| The code is as follows |
Copy Code |
|
$ sudo apt-get install LIBAPACHE2-MOD-PHP5 |
Restart Apache to load the module installed above:
| The code is as follows |
Copy Code |
|
$ sudo/etc/init.d/apache2 Restart |
To verify that the PHP module is loaded correctly, we can create a php file and then try to access the file through the Web server. In addition, we know that PHP has built a phpinfo function that can give details of its environment. So we can also use the following command to check the work of PHP:
| The code is as follows |
Copy Code |
|
sudo sh-c "echo" >/var/www/info.php " |
Then, type http://localhost/info.php in the browser address bar, and then enter, and you should be able to see a face and give the details of the PHP you just installed. It is important to note that if the browser does not display the page in this process, it prompts you to download the file, which means that Apache does not load the PHP module correctly. The solution is to add the following line of command to the/etc/apache2/apache2.conf or/etc/apache2/mods-enabled/php5.conf file:
| The code is as follows |
Copy Code |
|
AddType application/x-httpd-php. php. phtml. php3 |
After adding the above command line, in order to ensure that Apache re-read the configuration file shutdown, we can turn it off by following the command, and then start again:
| code is as follows |
copy code |
|
$ sudo/etc/ Init.d/apache2 stop
$ sudo/etc/init.d/apache2 start |