CentOS 5.x编译安装配置ProFTPd与添加MySQL虚拟用户

在安装ProFTPd与配置MySQL虚拟用户之前,请确保你的系统已经正常运行MySQL服务器。

编译安装ProFTPd

  1. wget ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/ftp.proftpd.net/distrib/source/proftpd-1.3.1.tar.gz
  2. tar xzvf proftpd-1.3.1.tar.gz
  3. cd proftpd-1.3.1
  4. ./configure –with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql
  5. –with-includes=/usr/include/mysql
  6. –with-libraries=/usr/lib/mysql
  7. make && make install

请根据你的MySQL安装路径修改–with-includes和–with-libraries的参数。

添加ftp用户和用户组

  1. groupadd -g 5500 ftpgroup
  2. adduser -u 5500 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser

MySQL配置

登录MySQL并创建数据库。

  1. mysql -u root -p
  2. create database ftpdb;
  3. grant select, insert, update on ftpdb.* to proftpd@localhost identified by ‘password’;
  4.  
  5. use ftpdb;
  6.  
  7. #
  8. # Table structure for table `ftpgroup`
  9. #
  10.  
  11. CREATE TABLE ftpgroup (
  12. groupname varchar(16) NOT NULL default ”,
  13. gid smallint(6) NOT NULL default ‘5500’,
  14. members varchar(16) NOT NULL default ”,
  15. KEY groupname (groupname)
  16. ) TYPE=MyISAM COMMENT=’ProFTP group table’;
  17.  
  18. #
  19. # Dumping data for table `ftpgroup`
  20. #
  21.  
  22. INSERT INTO `ftpgroup` VALUES (‘ftpgroup’, 5500, ‘ftpuser’);
  23. INSERT INTO `ftpgroup` VALUES (‘ftpgroup’, 5500, ‘ftpguest’);
  24.  
  25. CREATE TABLE `ftpquotatallies` (
  26. `name` varchar(30) NOT NULL default ”,
  27. `quota_type` enum(‘user’,’group’,’class’,’all’) NOT NULL default ‘user’,
  28. `bytes_in_used` float NOT NULL default ‘0’,
  29. `bytes_out_used` float NOT NULL default ‘0’,
  30. `bytes_xfer_used` float NOT NULL default ‘0’,
  31. `files_in_used` int(10) unsigned NOT NULL default ‘0’,
  32. `files_out_used` int(10) unsigned NOT NULL default ‘0’,
  33. `files_xfer_used` int(10) unsigned NOT NULL default ‘0’
  34. ) TYPE=MyISAM;
  35.  
  36. # ——————————————————–
  37.  
  38. #
  39. # Table structure for table `ftpuser`
  40. #
  41.  
  42. CREATE TABLE ftpuser (
  43. id int(10) unsigned NOT NULL auto_increment,
  44. userid varchar(32) NOT NULL default ”,
  45. passwd varchar(32) NOT NULL default ”,
  46. uid smallint(6) NOT NULL default ‘5500’,
  47. gid smallint(6) NOT NULL default ‘5500’,
  48. homedir varchar(255) NOT NULL default ”,
  49. shell varchar(16) NOT NULL default ‘/sbin/nologin’,
  50. count int(11) NOT NULL default ‘0’,
  51. accessed datetime NOT NULL default ‘0000-00-00 00:00:00’,
  52. modified datetime NOT NULL default ‘0000-00-00 00:00:00’,
  53. PRIMARY KEY (id),
  54. UNIQUE KEY userid (userid)
  55. ) TYPE=MyISAM COMMENT=’ProFTP user table’;
  56. INSERT INTO `ftpuser` VALUES (1, ‘testaccount’, ‘ftppasswd’, 5500, 5500, ‘/home/testdomain.com’, ‘/sbin/nologin’,0,”,”);
  57.  
  58. exit;

proftpd配置文件

要目录下建proftpd.conf配置文件,请在下面的代码修改好MySQL数据库登录信息。

  1. ServerName "Khoosys Proftpd Server"
  2. ServerType Standalone
  3. ServerAdmin [email protected]
  4.  
  5. # Hide as much as possible to outside users
  6. ServerIdent on "Welcome to the Khoosys FTP server. Please login…"
  7. DeferWelcome on
  8.  
  9. DefaultServer on
  10.  
  11. # Allow FTP resuming.
  12. # Remember to set to off if you have an incoming ftp for upload.
  13. AllowStoreRestart on
  14.  
  15. # Port 21 is the standard FTP port.
  16. Port 21
  17.  
  18. # Umask 022 is a good standard umask to prevent new dirs and files
  19. # from being group and world writable.
  20. Umask 022
  21.  
  22. # To prevent DoS attacks, set the maximum number of child processes
  23. # to 30. If you need to allow more than 30 concurrent connections
  24. # at once, simply increase this value. Note that this ONLY works
  25. # in standalone mode, in inetd mode you should use an inetd server
  26. # that allows you to limit maximum number of processes per service
  27. # (such as xinetd).
  28. MaxInstances 30
  29.  
  30. # Set the user and group under which the server will run.
  31. User ftpuser
  32. Group ftpgroup
  33.  
  34. # To cause every FTP user to be "jailed" (chrooted) into their home
  35. # directory, uncomment this line.
  36. DefaultRoot ~
  37.  
  38. # Normally, we want files to be overwriteable.
  39.  
  40. AllowOverwrite on
  41.  
  42. # The passwords in MySQL are encrypted using CRYPT
  43. SQLAuthTypes Plaintext Crypt
  44. SQLAuthenticate users* groups*
  45.  
  46. # used to connect to the database
  47. # databasename@host database_user user_password
  48. SQLConnectInfo ftpdb@localhost proftpd password
  49.  
  50. # Here we tell ProFTPd the names of the database columns in the "usertable"
  51. # we want it to interact with. Match the names with those in the db
  52. SQLUserInfo ftpuser userid passwd uid gid homedir shell
  53.  
  54. # Here we tell ProFTPd the names of the database columns in the "grouptable"
  55. # we want it to interact with. Again the names match with those in the db
  56. SQLGroupInfo ftpgroup groupname gid members
  57.  
  58. # set min UID and GID – otherwise these are 999 each
  59. SQLMinID 500
  60.  
  61. # create a user’s home directory on demand if it doesn’t exist
  62. SQLHomedirOnDemand on
  63.  
  64. # Update count every time user logs in
  65. SQLLog PASS updatecount
  66. SQLNamedQuery updatecount UPDATE "count=count+1, accessed=now() WHERE userid=’%u’" ftpuser
  67.  
  68. # Update modified everytime user uploads or deletes a file
  69. SQLLog STOR,DELE modified
  70. SQLNamedQuery modified UPDATE "modified=now() WHERE userid=’%u’" ftpuser
  71.  
  72. # User quotas
  73. # ===========
  74. QuotaEngine on
  75. QuotaDirectoryTally on
  76. QuotaDisplayUnits Mb
  77. QuotaShowQuotas on
  78.  
  79. SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits WHERE name = ‘%{0}’ AND quota_type = ‘%{1}’"
  80.  
  81. SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM ftpquotatallies WHERE name = ‘%{0}’ AND quota_type = ‘%{1}’"
  82.  
  83. SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = ‘%{6}’ AND quota_type = ‘%{7}’" ftpquotatallies
  84.  
  85. SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" ftpquotatallies
  86.  
  87. QuotaLimitTable sql:/get-quota-limit
  88. QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
  89.  
  90.  
  91. RootLogin off
  92. RequireValidShell off

proftpd启动文件

创建/etc/init.d/proftpd文件,并写入下面的代码。

  1. #!/bin/sh
  2. # $Id: proftpd.init,v 1.1 2004/02/26 17:54:30 thias Exp $
  3. #
  4. # proftpd This shell script takes care of starting and stopping
  5. # proftpd.
  6. #
  7. # chkconfig: – 80 30
  8. # description: ProFTPD is an enhanced FTP server with a focus towards
  9. # simplicity, security, and ease of configuration.
  10. # It features a very Apache-like configuration syntax,
  11. # and a highly customizable server infrastructure,
  12. # including support for multiple ‘virtual’ FTP servers,
  13. # anonymous FTP, and permission-based directory visibility.
  14. # processname: proftpd
  15. # config: /etc/proftp.conf
  16. # pidfile: /var/run/proftpd.pid
  17. # Source function library.
  18. . /etc/rc.d/init.d/functions
  19.  
  20. # Source networking configuration.
  21. . /etc/sysconfig/network
  22.  
  23. # Check that networking is up.
  24. [ ${NETWORKING} = "no" ] && exit 0
  25.  
  26. [ -x /usr/sbin/proftpd ] || exit 0
  27.  
  28. RETVAL=0
  29.  
  30. prog="proftpd"
  31.  
  32. start() {
  33. echo -n $"Starting $prog: "
  34. daemon proftpd
  35. RETVAL=$?
  36. echo
  37. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/proftpd
  38. }
  39.  
  40. stop() {
  41. echo -n $"Shutting down $prog: "
  42. killproc proftpd
  43. RETVAL=$?
  44. echo
  45. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/proftpd
  46. }
  47.  
  48. # See how we were called.
  49. case "$1" in
  50. start)
  51. start
  52. ;;
  53. stop)
  54. stop
  55. ;;
  56. status)
  57. status proftpd
  58. RETVAL=$?
  59. ;;
  60. restart)
  61. stop
  62. start
  63. ;;
  64. condrestart)
  65. if [ -f /var/lock/subsys/proftpd ]; then
  66. stop
  67. start
  68. fi
  69. ;;
  70. reload)
  71. echo -n $"Re-reading $prog configuration: "
  72. killproc proftpd -HUP
  73. RETVAL=$?
  74. echo
  75. ;;
  76. *)
  77. echo "Usage: $prog {start|stop|restart|reload|condrestart|status}"
  78. exit 1
  79. esac
  80.  
  81. exit $RETVAL
  1. chmod 755 /etc/init.d/proftpd

之后,我们可以使用
service proftpd (start|stop|restart|reload|condrestart|status)来管理proftpd服务器。

测试proftpd

之前在配置MySQL的时候,我们添加了测试帐号testaccount和密码ftppasswd,可以用这个帐号来测试proftpd是否运行正常。

CentOS 5.x YUM安装ProFTPd与添加虚拟用户

ProFTP已经成为继Wu-FTP之后最为流行的FTP服务器软件,越来越多的站点选用它构筑安全高效的FTP站点,ProFTP配置方便,并有MySQL和Quota模块可供选择,利用它们的完美结合可以实现非系统账号的管理和用户磁盘的限制。下面介绍如何安装和添加虚拟用户。

安装EPEL软件包

  1. rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

YUM安装ProFTPd

  1. yum install proftpd

设置开机启动

  1. chkconfig –level 3 proftpd on

ProFTPd管理:
启动proftpd:service proftpd start
停止proftpd:service proftpd stop
重启proftpd:service proftpd restart
重载proftpd:service proftpd reload
配置文件/etc/proftpd.conf,可以通过proftpd -t6指令检测语法是否正确。

添加虚拟用户

首先我们需要设置配置文件/etc/proftpd.conf。
添加下面代码进配置文件:

  1. AuthUserFile /etc/ftpd.passwd
  2. AuthGroupFile /etc/ftpd.group

关闭检测/etc/shells:

  1. RequireValidShell off

设置仅使用虚拟用户认证:

  1. AuthOrder mod_auth_file.c

禁止PAM认证:

  1. PersistentPasswd off
  2. AuthPAM off

限制改变根目录:

  1. DefaulRoot ~

按照上面的要求设置好配置文件后,我们使用ftpasswd工具来添加虚拟用户,首先下载这个工具。

  1. cd /usr/sbin/
  2. wget http://www.castaglia.org/proftpd/contrib/ftpasswd
  3. chmod +x ftpasswd

ftpasswd工具的格式如下:

  1. # ftpasswd –passwd –name {username} –file /etc/ftpd.passwd –uid {5000} –gid {5000} –home /var/ftp/username-home/ –shell /bin/false
  2. # ftpasswd –group –name group1 –file /etc/ftpd.group –gid 5000 –member username

CentOS 源码编译安装LAMP(Apache MySQL PHP)

源码编译安装LAMP虽然过程繁琐,但可以根据自己PHP程序的需要配置相应的环境,非常的灵活。对于比较急于配置好LAMP的同学,可以使用lamp一键安装

卸载yum或rpm安装的amp软件

在编译安装lamp之前,首先先卸载已存在的rpm包吧。

  1. rpm -e httpd
  2. rpm -e mysql
  3. rpm -e php
  4. yum -y remove httpd
  5. yum -y remove php
  6. yum -y remove mysql-server mysql
  7. yum -y remove php-mysql

禁用SeLinux

selinux可能会致使编译安装失败,我们先禁用它。

  1. sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config //永久禁用,需要重启生效
  2. setenforce 0 //临时禁用,不需要重启

yum安装必要工具

1、安装编译工具gcc gcc-c++make automake autoconf kernel-devel
2、安装PHP所需依赖,如libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel等

  1. yum -y install gcc gcc-c++  make automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel  pcre-devel libtool-libs freetype-devel gd zlib-devel file bison patch mlocate flex diffutils   readline-devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel

下载所需源码

apache:http://httpd.apache.org/
mysql:http://mysql.com/downloads/mysql/
php:http://php.net/downloads.php
phpmyadmin:http://www.phpmyadmin.net/home_page/downloads.php
我们这里选择的版本为:apache-2.2.22,mysql-5.1.62,php-5.2.17,phpmyadmin-3.4.10.2

  1. cd /tmp
  2. wget -c http://apache.ziply.com//httpd/httpd-2.2.22.tar.gz
  3. wget -c http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.64.tar.gz/from/http://mysql.he.net/
  4. wget -c http://us2.php.net/get/php-5.2.17.tar.gz/from/am.php.net/mirror
  5. wget -c http://iweb.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.4.10.2/phpMyAdmin-3.4.10.2-all-languages.tar.gz
  6. tar xzf httpd-2.2.22.tar.gz
  7. tar xzf mysql-5.1.62.tar.gz
  8. tar xzf php-5.2.17.tar.gz
  9. tar xzf phpMyAdmin-3.4.10.2-all-languages.tar.gz

安装apache2.2.22

  1. cd /tmp/httpd-2.2.22
  2. ./configure –prefix=/usr/local/apache –with-included-apr –enable-so –enable-deflate=shared –enable-expires=shared  –enable-headers=shared –enable-rewrite=shared –enable-static-support
  3. make
  4. make install

编译参数解释:
–prefix=/usr/local/apache:指定安装目录
–with-included-apr:在编译时强制使用当前源代码中绑定的APR版本
–enable-so:允许运行时加载DSO模块
–enable-deflate=shared:将deflate模块编译为DSO
–enable-expires=shared:将expires模块编译为DSO
–enable-headers=shared:将headers模块编译为DSO
–enable-rewrite=shared:将rewrite模块编译为DSO
–enable-static-support:使用静态连接(默认为动态连接)编译所有二进制支持程序
更详细的编译参数解释:http://lamp.linux.gov.cn/Apache/ApacheMenu/programs/configure.html

  1. cp build/rpm/httpd.init /etc/init.d/httpd //使用init脚本管理httpd
  2. chmod 755 /etc/init.d/httpd //增加执行权限
  3. chkconfig –add httpd  //添加httpd到服务项
  4. chkconfig  httpd on   //设置开机启动
  5. ln -fs /usr/local/apache/ /etc/httpd
  6. ln -fs /usr/local/apache/bin/httpd /usr/sbin/httpd
  7. ln -fs /usr/local/apache/bin/apachectl /usr/sbin/apachectl
  8. ln -fs /usr/local/apache/logs /var/log/httpd //设置软链接以适应init脚本

安装mysql5.1.62

  1. groupadd mysql
  2. useradd -g mysql mysql
  3. cd /tmp/mysql-5.1.62
  4. ./configure –prefix=/usr/local/mysql/ –localstatedir=/usr/local/mysql/data –without-debug –with-unix-socket-path=/tmp/mysql.sock –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –with-extra-charsets=gbk,gb2312,utf8 –with-pthread
  5. make
  6. make install

编译参数解释:
–prefix=/usr/local/mysql/:指定安装位置
–localstatedir=/usr/local/mysql/data:指定数据库文件位置
–without-debug:禁用调用模式
–with-unix-socket-path=/tmp/mysql.sock:指定sock文件位置
–with-client-ldflags=-all-static:
–with-mysqld-ldflags=-all-static:以纯静态方式编译服务端和客户端
–enable-assembler:使用一些字符函数的汇编版本
–with-extra-charsets=gbk,gb2312,utf8 :gbk,gb2312,utf8字符支持
–with-pthread:强制使用pthread库(posix线程库)
更多编译参数请执行./configure –help命令查看。

  1. cp support-files/my-medium.cnf /etc/my.cnf //复制配置文件夹my.cnf
  2. /usr/local/mysql/bin/mysql_install_db –user=mysql  //初始化数据库
  3. chown -R root.mysql /usr/local/mysql
  4. chown -R mysql /usr/local/mysql/data 
  5. cp /tmp/mysql-5.1.62/support-files/mysql.server /etc/rc.d/init.d/mysqld  //init启动脚本
  6. chown root.root /etc/rc.d/init.d/mysqld 
  7. chmod 755 /etc/rc.d/init.d/mysqld
  8. chkconfig –add mysqld
  9. chkconfig  mysqld on
  10. ln -s /usr/local/mysql/bin/mysql /usr/bin
  11. ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
  12. service mysqld start
  13. /usr/local/mysql/bin/mysqladmin -u root password ‘新密码’   //设置root密码

安装PHP5.2.17

在编译php之前,先要解决两个问题:centos 6上libmcrypt的安装和可能有些系统找不到libiconv导致的错误。
1、centos 6官方源已经没有libmcrypt的rpm包,我们这里选择编译安装,当然你也可以导入第三方源安装(centos 5略过此步)。
下载源码:

  1. cd /tmp
  2. wget http://superb-dca2.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
  3. wget http://superb-dca2.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
  4. wget http://superb-sea2.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
  5. tar xzf libmcrypt-2.5.8.tar.gz
  6. tar xzf mhash-0.9.9.9.tar.gz
  7. tar xzf mcrypt-2.6.8.tar.gz
  8. //安装libmcrypt
  9. cd /tmp/libmcrypt-2.5.8
  10. ./configure –prefix=/usr
  11. make && make install
  12. //安装libmcrypt
  13. cd /tmp/mhash-0.9.9.9
  14. ./configure –prefix=/usr
  15. make && make install
  16. //安装mcrypt
  17. /sbin/ldconfig //搜索出可共享的动态链接库
  18. cd /tmp/mcrypt-2.6.8
  19. ./configure
  20. make && make install

2、解决可能出现的libiconv错误。

  1. cd /tmp
  2. wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
  3. tar xzf libiconv-1.14.tar.gz
  4. cd libiconv-1.14
  5. ./configure –prefix=/usr/local/libiconv
  6. make && make install

开始安装php-5.2.17:

  1. cd /tmp/php-5.2.17
  2. ./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs –with-config-file-path=/etc –with-config-file-scan-dir=/etc/php.d –with-openssl –with-zlib –enable-bcmath –with-bz2 –with-curl –enable-ftp –with-gd –enable-gd-native-ttf –with-gettext –with-mhash –enable-mbstring –with-mcrypt –enable-soap –enable-zip –with-iconv=/usr/local/libiconv –with-mysql=/usr/local/mysql –without-pear
  3. make
  4. make install

编译参数解释:
–prefix=/usr/local/php:设置安装路径
–with-apxs2=/usr/local/apache/bin/apxs:编译共享的 Apache 2.0 模块
–with-config-file-path=/etc:指定配置文件php.ini地址
–with-config-file-scan-dir=/etc/php.d:指定额外的ini文件目录
–with-openssl:编译OpenSSL支持
–with-zlib:编译zlib支持
–enable-bcmath:启用BC风格精度数学函数
–with-bz2:BZip2支持
–with-curl:CRUL支持
–enable-ftp:FTP支持
–with-gd:GD支持
–enable-gd-native-ttf:启用TrueType字符串函数
–with-gettext:启用GNU gettext支持
–with-mhash:mhash支持
–enable-mbstring:启用支持多字节字符串
–with-mcrypt:编译mcrypt加密支持
–enable-soap:SOAP支持
–enable-zip:启用zip 读/写支持
–with-iconv=/usr/local/libiconv:iconv支持
–with-mysql=/usr/local/mysql:启用mysql支持
–without-pear:不安装PEAR
更多编译参数解释参考http://www.php.net/manual/zh/configure.about.php或者./configure –help查看。

  1. cp php.ini-dist /usr/local/php/etc/php.ini //复制配置文件php.ini

在/etc/httpd/conf/httpd.conf文件中加入php文件类型解析:

  1. Addtype application/x-httpd-php .php

重启httpd:

  1. service httpd restart

安装ZendOptimizer-3.3.9(可选)

ZendOptimizer的作用是分析,优化由Zend 编译器加密产生的代码的程序,对不是Zend编译器加密过的程序,没有必要安装这个。
64位:http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
32位:http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

  1. cd /tmp
  2. wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
  3. tar xzf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
  4. cd /tmp/ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/
  5. mkdir -p /usr/local/Zend/lib/
  6. cp ZendOptimizer.so /usr/local/Zend/lib

加载zendoptimizer,建立/etc/php.d/zend.ini文件,加入如下代码加载:

  1. [zend]
  2. zend_optimizer.optimization_level=15
  3. zend_extension=/usr/local/Zend/lib/ZendOptimizer.so

重启httpd生效:

  1. service httpd restart

安装eAccelerator-0.9.6.1(可选)

eAccelerator是一个自由开放源码php加速器,优化和动态内容缓存,提高了php脚本的缓存性能,使得PHP脚本在编译的状态下,对服务器的开销几乎完全消除。 它还有对脚本起优化作用,以加快其执行效率。使您的PHP程序代码执效率能提高1-10倍。类似的php加速器有:Xcache,APC等。下面是安装方法:

  1. cd /tmp
  2. wget http://voxel.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip
  3. unzip eaccelerator-0.9.6.1.zip
  4. cd eaccelerator-0.9.6.1
  5. export PHP_PREFIX="/usr/local/php"
  6. $PHP_PREFIX/bin/phpize
  7. ./configure -enable-eaccelerator=shared -with-php-config=$PHP_PREFIX/bin/php-config
  8. make && make install
  9. cd /tmp
  10. mkdir eaccelerator
  11. chmod 0777 eaccelerator

加载eAccelerator,创建/ec/php.d/ea.ini文件,加入如下代码加载:

  1. [eaccelerator]
  2. zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
  3. eaccelerator.shm_size="32"
  4. eaccelerator.cache_dir="/tmp/eaccelerator"
  5. eaccelerator.enable="1"
  6. eaccelerator.optimizer="1"
  7. eaccelerator.check_mtime="1"
  8. eaccelerator.debug="0"
  9. eaccelerator.filter=""
  10. eaccelerator.shm_max="0"
  11. eaccelerator.shm_ttl="0"
  12. eaccelerator.shm_prune_period="0"
  13. eaccelerator.shm_only="0"
  14. eaccelerator.compress="1"
  15. eaccelerator.compress_level="9"

eaccelerator参数设置参考:http://devops.webres.wang/2012/03/eaccelerator-parameter/
重启httpd生效:

  1. service httpd restart

error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file

今天编译安装LAMP,运行mysql命令时出现error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file,在其它机子上安装又没问题,不明白这次有问题。下面是解决方法。
首先确定 libmysqlclient.so.15确实存在,出现这种错误可能是没有装载上。通过下列方法解决。
通过ldconfig注册即可
ldconfig /usr/local/mysql/lib/mysql/libmysqlclient.so.15