(Apacheand mysqlinstallation in front of the blog also has detailed introduction to the first few installation package libmcrypt-2.5.8.tar.gz (http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/ )php-5.6.2.tar.gz (http://cn2.php.net/downloads.php )&
(The installation of Apache and MySQL is also described in detail in the previous blog)
First, prepare several installation packages.
Libmcrypt-2.5.8.tar.gz (http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8)
Php-5.6.2.tar.gz (http://cn2.php.net/downloads.php)
1. first add the dependent application
Yum install-y gcc-c ++ autoconf libjpeg-devel libpng-devel freetype-devel libpng-devel libxml2 libxml2-devel zlib-devel glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c-devel
This step is to support some php running items and the following compilation needs:
2. install the encrypted Extension Library
Cd/usr/local/src/
Tar zxvf libmcrypt-2.5.8.tar.gz
Cd libmcrypt-2.5.8
./Configure
Make
Make install
3. go to the directory where the php compressed package is stored
Tar zxvf php-5.6.8.tar.gz # extract
Cd php-5.6.8 # enter the folder
Run
[Root @ VPS php-5.6.8] #. /configure -- prefix =/usr/local/php -- with-apxs2 =/usr/local/apache/bin/apxs -- with-mysql =/usr/local/mysql -- with-mysql- sock -- with-mysqli =/usr/local/mysql/bin/mysql_config -- enable-fpm -- with-ncurses -- enable-soap -- with-libxml-dir -- with-XMLrpc -- -openssl -- with-mcrypt -- with-mhash -- with-pcre-regex -- with-sqlite3 -- with-zlib -- enable-bcmath -- with-iconv -- with-bz2 -- enable-calendar -- with-curl -- with-cdb -- enable-dom -- enable-exif -- enable-fileinfo -- enable-filter -- with-pcre-dir -- enable-ftp -- with-gd -- with-openssl-dir -- with-jpeg-dir -- with-png-dir -- with-zlib-dir -- with-freetype-dir -- enable-gd-native-ttf -- enable-gd-jis-conv -- with-gettext -- with-gmp -- with-mhash -- enable-json -- enable-mbstring -- disable-mbregex-backtrack -- with-libmbfl -- with-onig -- enable -pdo -- with-pdo-mysql -- with-zlib-dir -- with-pdo-sqlite -- with-readline -- enable-session -- enable-shmop -- enable-simplexml -- enable-sockets -- enable-sqlite-utf8 -- enable-sysvmsg -- enable-sysvsem -- enable-sysvshm -- enable-wddx -- with-libxml-dir -- with-xsl -- enable-zip -- enable-mysqlnd-compression-support -- with-pear
There can be no errors in this step, and there may be warnings, that is, some packages cannot be identified and so on, generally there is no major problem
Run
Make
Display
Build complete.
Don't forget to run 'Make test '.
【
If: undefined reference to 'ts _ resource_ex 'is displayed'
Collect2: ld returned 1 exit status
Make: *** [sapi/cli/php] Error 1
The error message is that I have compiled PHP with different parameters.
Solution: execute make clean to delete the last compilation result, and then re-compile it.
If this is your first compilation, Baidu will solve this problem.
]
Run
Make install
Finally, configure apache to support php.
Modify the configuration file httpd. conf of apache
Vi/usr/local/apache/conf/httpd. conf
Then add at the end of the text
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php. php
(Note: in the apache installation directory, there is libphp5.so under modules. this is added during php installation. if not, you need to reinstall it .)
The code for generating the libphp5.so file is in./configure -- with-apxs2 =/usr/local/apache/bin/apxs, the path corresponds to the path you installed
)
Next, copy the php startup file.
Php-5.6.3/php. ini-development/usr/local/php/lib/php. ini
Save and restart
Service httpd start
If no error is reported, the startup is successful.
Test whether php is successfully installed.
Write a simple php page
Phpinfo ();
?>