./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 ../ 修改php.ini文件 手工修改:查找/usr/local/php/etc/php.ini中的extension_dir = "./" 修改为extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/" 并在此行后增加以下几行,然后保存: extension = "memcache.so" extension = "pdo_mysql.so" extension = "imagick.so" 再查找output_buffering = Off 修改为output_buffering = On 再查找; cgi.fix_pathinfo=0 修改为cgi.fix_pathinfo=0,防止Nginx文件类型错误解析漏洞。 配置eAccelerator加速PHP: mkdir -p /opt/webserver/eaccelerator_cache vi /usr/local/php/etc/php.ini 在php.ini配置文件的最末尾,加上以下配置信息: [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" php的安全性设置: 找到:;open_basedir = 修改为:open_basedir = .:/tmp/ #防止php木马跨站,重要!! 找到:disable_functions = 修改为: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可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。 找到:;date.timezone = 修改为:date.timezone = PRC 找到:expose_php = On 修改为:expose_php = OFF #禁止显示php版本的信息 找到:display_errors = On 修改为:display_errors = OFF #关闭错误提示 关于模块的安装我给各位补充一篇文章 1、静态安装 将先将在安装php之前先将需要安装的程序装上,如ftp、mhash、mcrypt……安装完成后,解压php安装包,执行./configure --with-ftp --with-mhash --wth-mcrypt等等。后面具体跟的参数可以参看./configure --help查看。编译好后,执行make && make install 就行了。 2、动态安装 而在往往我们进行编译php时经常会忘记添加某扩展,后来想添加扩展,但是因为安装php后又装了一些东西如PEAR等,不想再重新装php,于是可以采用phpize来动态加载需要安装的模块。 具体实现方法如下(这里以忘记安装pdo_mysql模块为例): cd /root/source/php-5.3.10/ext/pdo_mysql /usr/local/php/bin/phpize |