Before you start to compile and install PHP under Ubuntu, first install the software package 1, flexsudoapt-getinstallflex2, apache2-threaded-devsudoapt-getinstallapache2-threaded-dev after installation, you can find the installation content at the following location, for example, apache2/usr/bin/apxs2, if it is apache1/usr/bin/apxs3,
Install the software package before compiling and installing PHP In Ubuntu.
1. flex
Sudo apt-get install flex
2. apache2-threaded-dev
Sudo apt-get install apache2-threaded-dev
After installation, you can find the installation content at the following location
For example, apache2
/Usr/bin/apxs2
For apache1
/Usr/bin/apxs
3. libxml2-dev
Sudo apt-get install libxml2-dev
After installing the above software, you need to modify httpd. conf.
Add fake content to httpd. conf.
For example:
# Dummy LoadModule directive to aid module installations
# LoadModule dummy_module/usr/lib/apache2/modules/mod_dummy.so
Because if the content of httpd. conf is empty
An error occurs when installing PHP.
Start compiling and installing PHP
1. Extract
$ Tar zxvf php-5.2.8.tar.gz
2. view available compilation Parameters
$./Configure-help
3. Now the Basic installation is available, except for apache2. If you encounter other problems during later use, modify the compilation parameters and process them one by one.
Where
-- Prefix is used to specify the installation directory
-- The with-apxs2 is used to specify the location of apxs2.
./Configure -- prefix =/usr/local/php -- with-apxs2 =/usr/bin/apxs2
2. Compile
Make
3. Compile and Test
Make test
3. Installation
Sudo make install
Modify httpd. conf
Add the following content
AddType application/x-httpd-php. php. phtml
AddType application/x-httpd-php-source. phps
Add index. php to/var/www /.
Echo phpinfo ();
?>
Restart apache
Sudo apache2ctl-k restart
Access 127.0.0.1/index. php in a browser