Install PHP and related extensions in Ubuntu
1.
Download php's latest source code (to be registered) at http://php.net/downloads.phpand my version is php-5.3.8
2.
./Configure -- prefix =/usr/local/PhP5 -- with-apxs2 =/usr/local/apache2/bin/apxs -- With-mysql =/usr/local/MySQL
-- With-config-file-Path =/usr/local/PhP5 -- With-zlib -- enable-mbstring = all -- With-mysqli =/usr/local/MySQL/bin/mysql_config -- With-PDO-mysql =/usr/local/MySQL
The following describes the functions of each parameter:
First, specify the PHP installation path;
Second, specify the Apache path;
Third, specify the MySQL path;
Fourth, specify the storage path of the configuration file;
Fifth, it is very important to allow PHP to support zlib compression!
The next one indicates that PHP supports mbstring. This is also very important (because this parameter was not written when PHP was compiled for the first time, fatal is prompted when mb_strlen () is called.
Error: Call to undefined function mb_strlen (), So I re-compiled PHP and added this parameter)
Mbstring library full name is multi-byte string that all languages have their own encoding, their number of bytes is not the same, the current PHP internal encoding only supports ISO-8859-*, EUC-JP, other coding languages of UTF-8 cannot be correctly displayed on PHP programs.
The solution is to use the mbstring function library in PHP.
Detailed can refer to here: http://us.php.net/manual/en/mbstring.installation.php
Then, a parameter indicates that mysqli support is enabled, and mysqli (I indicates improvement enhancement) is newly introduced by PHP. It can be used to operate databases using object-oriented methods, in the past, only process-oriented operations (that is, calling a function to operate the database) were allowed. Note that you should replace this with your own mysql_config path!
The next parameter indicates that PHP supports PDO, PDO (PHPData Object) is a new abstract database access layer introduced by PHP. It is equivalent to an intermediary between PHP and the database. With it, PHP can use a unified function to access different databases.
Is the phpinfo () output without PDO installation:
We found that SQLite PDO is installed in PHP by default, while other PDO needs to be manually specified during configure.
The following is the phpinfo () output after MySQL PDO is installed:
3.
Make-J 2)
Make install
4.
Copy the configuration file of PHP. The default location of PHP. INI is in the Lib subdirectory under the PHP installation directory.
Cp php. ini-development/usr/local/PhP5/lib/PHP. ini
5.
Set httpd. conf to make Apache support PHP:
VI
/Usr/local/apache2/CONF/httpd. conf
Search for addtype and find addtype application/X-compress. Z.
Add two rows below:
Addtype application/X-httpd-PHP. php. phtml # parse the PHP File
Addtype application/X-httpd-PHP-source. PHPs # use. PHPs as the PHP source file for syntax highlighting
6.
Restart Apache:
Sudo
Apachectl restart
Let's test it below:
1.
Create a test. php file under/usr/local/apache2/htdocs/with the following content:
<? PHP
Phpinfo ();
?>
2.
In the browser:
Http: // localhost/test. php
You can see the following interface!
So far, all the lamp configurations in Ubuntu have been completed, so tired ~~ However, these configurations are only the most basic. As you learn more in the future, you may need to reconfigure them. Record them here for future viewing, more detailed information will be provided later ~~
Done!