The following is an example of the latest php-5.3.10 installation.
wget http://cn.php.net/distributions/php-5.3.10.tar.gz
TAR-ZXVF php-5.3.10.tar.gz
CD php-5.3.10
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql-- With-mysqli=/usr/local/mysql/bin/mysql_config--with-iconv-dir--with-freetype-dir--with-jpeg-dir--with-png-dir- -with-zlib--with-libxml-dir--enable-xml--disable-rpath--enable-bcmath--enable-shmop-- Enable-inline-optimization--with-curl--with-curlwrappers--enable-mbregex--enable-fpm--enable-mbstring-- With-mcrypt--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets- -WITH-LDAP-SASL--with-xmlrpc--enable-zip--enable-soap
The specific parameters above can be used./configure--help View
Make zend_extra_libs= '-liconv '
Make Test
Made && make install (this is best done separately, because there will be an error when making.) )
I reported the following error when I made it above
Root/source/php-5.3.10/sapi/cli/php:error while loading shared libraries:libmysqlclient.so.18:cannot open shared Object File:no such file or directory
Make: * * * [ext/phar/phar.php] Error 127
The solution is (my MySQL installation directory is/usr/local/msyql, depending on your MySQL installation path). )
Ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib/
The 64-bit system should use the following line
Ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib64/
If the following error, is the compilation of MySQL time without adding mysqli this item, the next marked the red part of the cancellation, re-edited the line.
Make: * * * [Ext/mysqli/mysqli.lo] Error 1
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql-- With-mysqli=/usr/local/mysql/bin/mysql_config--with-iconv-dir--with-freetype-dir--with-jpeg-dir--with-png-dir- -with-zlib--with-libxml-dir--enable-xml--disable-rpath--enable-bcmath--enable-shmop-- Enable-inline-optimization--with-curl--with-curlwrappers--enable-mbregex--enable-fpm--enable-mbstring-- With-mcrypt--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets- -WITH-LDAP-SASL--with-xmlrpc--enable-zip--enable-soap
In addition, there are also the possibility of the following mistakes. The problem may be that there are no packages installed iconv This code conversion, and there are some that can be installed, but still have this error.
Sapi/cli/php:error while loading shared libraries:libiconv.so.2:cannot open Shared object file:no such file or Directo Ry
MAKE[1]: * * * [Install-pear-installer] Error 127
Make: * * * [install-pear] Error 2
Find/-name libiconv.so.2 found in/usr/lib/libiconv.so.2 location Libiconv has been installed.
So run/sbin/ldconfig, and then recompile, no longer reported the above error. Ldconfig is used to load the latest compiled package.
Note: Many of the above needed packages I have passed through./configure--prefix=/usr--libdir=/usr/lib--sysconfdir=/etc parameter compilation. This allows the package to be found in the default directory.
CP Php.ini-production/usr/local/php/etc/php.ini
CP SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM
CP sapi/fpm/php-fpm.conf/usr/local/php/etc/php-fpm.conf
modifying parameters in PHP.ini and php-fpm files can be changed manually or with the following SED command
Sed-i ' S#short_open_tag = Off#short_open_tag = On#g '/usr/local/php/etc/php.ini
Sed-i ' s#;p id = run/php-fpm.pid#pid = Run/php-fpm.pid#g '/usr/local/php/etc/php-fpm.conf
Sed-i ' S#pm.max_children = 5#pm.max_children = 32#g '/usr/local/php/etc/php-fpm.conf
Sed-i ' s#pm.start_servers = 2#pm.start_servers = 16#g '/usr/local/php/etc/php-fpm.conf
Sed-i ' s#pm.min_spare_servers = 1#pm.min_spare_servers = 8#g '/usr/local/php/etc/php-fpm.conf
Sed-i ' s#pm.max_spare_servers = 3#pm.max_spare_servers = 32#g '/usr/local/php/etc/php-fpm.conf
Sed-i ' s#;p m.max_requests = 500#pm.max_requests = 120#g '/usr/local/php/etc/php-fpm.conf
PHP official also gave a description of all of the parameters, specifically see http://www.php.net/manual/en/install.fpm.configuration.php
Setting up boot
chmod 755/etc/init.d/php-fpm
Chkconfig--add PHP-FPM
/ETC/INIT.D/PHP-FPM start
At this point, the installation of PHP is complete.
Finally you can install some PHP expansion pack and open the PHP acceleration (the specific software package can be installed according to the latest version of the Web):
Tar zxvf memcache-2.2.5.tgz
CD memcache-2.2.5/
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
Make
Make install
Cd.. /
Tar jxvf eaccelerator-0.9.6.1.tar.bz2
CD EACCELERATOR-0.9.6.1/
/usr/local//php/bin/phpize
./configure--enable-eaccelerator=shared--with-php-config=/usr/local/php/bin/php-config
Make
Make install
Cd.. /
Tar zxvf pdo_mysql-1.0.2.tgz
CD PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config--with-pdo-mysql=/usr/local/mysql
Make
Make install
Cd.. /
Tar zxvf ImageMagick.tar.gz
CD imagemagick-6.5.1-2/
./configure
Make
Make install
Cd.. /
Tar zxvf imagick-2.3.0.tgz
CD imagick-2.3.0/
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
Make
Make install
Cd.. /
modifying php.ini files
Manual modification: Find the Extension_dir = "./" in/usr/local/php/etc/php.ini
Modified to Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
and add the following lines after this row, and then save:
Extension = "memcache.so"
Extension = "pdo_mysql.so"
Extension = "imagick.so"
Then look for output_buffering = off
Modify to Output_buffering = On
Search again; Cgi.fix_pathinfo=0
Modify to Cgi.fix_pathinfo=0 to prevent Nginx file type error resolution vulnerabilities.
Configure Eaccelerator to accelerate PHP:
Mkdir-p/opt/webserver/eaccelerator_cache
Vi/usr/local/php/etc/php.ini
At the end of the php.ini configuration file, add the following configuration information:
[Eaccelerator]
zend_extension= "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
Eaccelerator.shm_size= "64"
Eaccelerator.cache_dir= "/opt/webserver/eaccelerator_cache"
eaccelerator.enable= "1"
Eaccelerator.optimizer= "1"
Eaccelerator.check_mtime= "1"
eaccelerator.debug= "0"
Eaccelerator.filter= ""
eaccelerator.shm_max= "0"
Eaccelerator.shm_ttl= "3600"
eaccelerator.shm_prune_period= "3600"
eaccelerator.shm_only= "0"
eaccelerator.compress= "1"
Eaccelerator.compress_level= "9"
Security Settings for PHP:
Find:; open_basedir =
modified to: Open_basedir =.:/ tmp/ #防止php木马跨站, Important!!
Find: disable_functions =
Modified to: Disable_functions = Passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec, Proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru, Stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname, GETSERVBYPORT,DISK_TOTAL_SPACE,POSIX_CTERMID,POSIX_GET_LAST_ERROR,POSIX_GETCWD, Posix_getegid,posix_geteuid, Posix_getgid, Posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_ Getpid, Posix_getppid,posix_getpwnam,posix_getpwuid, Posix_getrlimit, Posix_getsid,posix_getuid,posix_isatty, Posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, Posix_setpgid,posix_setsid,posix_setuid,posix _strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数, if some programs need to use this function, you can remove it and disable it.
Find:;d Ate.timezone =
Modified as: Date.timezone = PRC
Find: expose_php = On
Modified to: expose_php = off #禁止显示php版本的信息
Find: Display_errors = On
Modified to: Display_errors = off #关闭错误提示
about the installation of modules I'll add an article to you.
1. Static installation
You will first install the program you need to install before installing PHP, such as FTP, Mhash, MCrypt ... After the installation is complete, unpack the PHP installation package and execute./configure--with-ftp--with-mhash--wth-mcrypt etc. The following specific parameters can be seen in the./configure--help view. Once you have compiled it, do make && make install.
2. Dynamic Installation
And often we do compile PHP often forget to add an extension, and then want to add extensions, but because the installation of PHP and then installed some things such as pear, do not want to reload PHP, so you can use the phpize to dynamically load the module needs to be installed.
The implementation method is as follows (here is an example of forgetting to install the Pdo_mysql module):
Cd/root/source/php-5.3.10/ext/pdo_mysql
/usr/local/php/bin/phpize
After installing MySQL, not into the/root/source/mysql-5.5.21 directory to run Phpize, but into the PHP source file to increase the expansion module file directory---that is/root/source/php-5.3.10/ext /pdo_mysql Directory execution phpize. If this is not the case, you will be prompted with the following error:
Cannot find CONFIG.M4.
Make sure so you run '/usr/local/php/bin/phpize ' in ' the '
On the above error, I have to despise the Internet some self-righteous guy, since think of all the installation operation very understand, reported above the error, to modify the source code, mess, fraught. Do not follow the official PHP documentation.
Directory/root/source/php-5.3.10/ext/pdo_mysql, there is no configure file, only config.m4 file before running the phpize command. Running Phpize generates an executable configure file. You can now compile the following method:
./configure--with-php-config=/usr/bin/php-config (You can also add some other parameters to the./configure--help View)
Make
Make install
When the compilation is complete, the extension module is prompted to build in the/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626 directory.
modifying php.ini files
Vi/usr/local/php/etc/php.ini
Add the following at the end of the file:
Extension_dir= "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626"
Extension=pdo_mysql.so
After the installation is complete, restart the PHP-FPM and the Web server. (Because I'm using PHP-FPM and Tengine, if you're using Apache, restart the appropriate program, reload it)
This article in fact about the acceleration of the part is wrong, because at that time I test, just install the PHP, the back of the Eaccelerator acceleration part is directly copied the original installation part, did not test, and later because of the production environment needs, to install, Found Eaccelerator does not support the latest php5.3.10. Then replaced by the fastest update XCache discovery support.