主要依照的是张宴的一篇博文《》,安装的软件是也是从他提供的列表中下载,这里都是tar.gz格式,如果更希望是rpm格式的话,提供一个网址《》这里列出了比较完全的下载包。 1、下载; 我安装的下载来自张宴博文下的地址,下载保存的是home下自己目录的一个文件夹下:
复制代码
代码如下:
cd /home/xuxx/softwarewgethttp://blog.s135.com/soft/linux/nginx_php/php/php-5.2.8.tar.gzwgethttp://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.1.33.zipwgethttp://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gzwgethttp://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgzwgethttp://blog.s135.com/soft/linux/nginx_php/pcre/pcre-7.8.tar.gzwgethttp://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgzwgethttp://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.2.2.tgz
2、准备编译安装环境,需要编译源码用到gc++ 建议如果是新安装的系统,使用yum upgrade更新下系统。
复制代码
代码如下:
sudo -sLANG=Cyum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-develglib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-developenldap openldap-devel nss_ldap openldap-clients openldap-servers
注意:这里所有的命令是一行的而不能有换行符,如果是copy的时候,注意要去处该换行符 确保安装成功!才能正确使用编译。 1、编译安装PHP 5.2.8所需的支持库:
复制代码
代码如下:
tar zxvf libiconv-1.13.tar.gzcd libiconv-1.13/./configure --prefix=/usr/localmakemake installmake clean>make distcleancd ../
make clean 和make distclean都是删除安装过程中生成的缓存文件。当然如果你不介意放着也可以跳过这两步清理操作。
复制代码
代码如下:
tar zxvf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8/./configuremakemake installmake cleanmake distclean/sbin/ldconfigcd libltdl/./configure --enable-ltdl-installmakemake installmake cleanmake distcleancd
复制代码
代码如下:
tar zxvf mhash-0.9.9.9.tar.gzcd mhash-0.9.9.9/./configuremakemake installcd ../
注意:因为该库和libmcrypt有依赖性,所以在安装前必须知道libmcrypt,否则的话会出现:
复制代码
代码如下:
checking for libmcrypt – version >= 2.5.0…*** ‘libmcrypt-config –version’ returned 2.4.0, but LIBMCRYPT (2.5.8)*** was found! If libmcrypt-config was correct, then it is best*** to remove the old version of LIBMCRYPT. You may also be able to fix the error*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing*** /etc/ld.so.conf. Make sure you have run ldconfig if that is*** required on your system.*** If libmcrypt-config was wrong, set the environment variable LIBMCRYPT_CONFIG*** to point to the correct copy of libmcrypt-config, and remove the file config.cache*** before re-running configureconfigure: error: *** libmcrypt was not found
是因为path的问题,所以执行:
复制代码
代码如下:
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.laln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.soln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.aln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.laln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.soln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
复制代码
代码如下:
tar zxvf mcrypt-2.6.8.tar.gzcd mcrypt-2.6.8//sbin/ldconfig./configuremakemake installcd ../
复制代码
代码如下:
/usr/sbin/groupadd mysql/usr/sbin/useradd -g mysql xxxunzip mysql-5.1.33.zipcd mysql-5.1.33/./configure --prefix=/usr/local/webserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables--with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobasemakemake installmake cleanmake distcleanchmod +w /usr/local/webserver/mysqlcHOWn -R xxx:mysql /usr/local/webserver/mysqlcp support-files/my-medium.cnf.sh /usr/local/webserver/mysql/my.cnfcd ../
注意:这里编译./configure命令是一行的而不能有换行符,如果是copy的时候,注意要去处该换行符 在最后一步拷贝的时候,我安装完在support-files下没有my-medium.cnf而只有my-medium.cnf.sh所以将这个文件拷贝过去。 附:以下为附加步骤,如果你想在这台服务器上运行MySQL数据库,则执行以下两步。如果你只是希望让PHP支持MySQL扩展库,能够连接其他服务器上的MySQL数据库,那么,以下两步无需执行。 ①、以xxx用户帐号的身份建立数据表:
复制代码
代码如下:
/usr/local/webserver/mysql/bin/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/usr/local/webserver/mysql/data --user=xxx
②、启动MySQL(最后的&表示在后台运行)
复制代码
代码如下:
/bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/usr/local/webserver/mysql/my.cnf &
复制代码
代码如下:
tar zxvf php-5.2.8.tar.gzgzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1cd php-5.2.8/./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem--enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap--with-ldap-saslmake ZEND_EXTRA_LIBS='-liconv'make installcp php.ini-dist /usr/local/webserver/php/etc/php.inicd ../
注意:这里./configure命令是一行的而不能有换行符,如果是copy的时候,注意要去处该换行符 4、编译安装PHP5扩展模块--可选安装
复制代码
代码如下:
tar zxvf memcache-2.2.5.tgzcd memcache-2.2.5//usr/local/webserver/php/bin/phpize./configure --with-php-config=/usr/local/webserver/php/bin/php-configmakemake installmake cleanmake distcleancd ../tar jxvf eaccelerator-0.9.5.3.tar.bz2cd eaccelerator-0.9.5.3//usr/local/webserver/php/bin/phpize./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-configmakemake installmake cleanmake distcleancd ../tar zxvf PDO_MYSQL-1.0.2.tgzcd PDO_MYSQL-1.0.2//usr/local/webserver/php/bin/phpize./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysqlmakemake installmake cleanmake distcleancd ../tar zxvf ImageMagick.tar.gzcd ImageMagick-6.5.1-2/./configuremakemake installmake cleanmake distcleancd ../tar zxvf imagick-2.2.2.tgzcd imagick-2.2.2//usr/local/webserver/php/bin/phpize./configure --with-php-config=/usr/local/webserver/php/bin/php-configmakemake installmake cleanmake distcleancd ../
并在此行后增加以下几行,然后保存: 按shift+g键跳到配置文件的最末尾,加上以下配置信息:
复制代码
代码如下:
[eaccelerator]zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"eaccelerator.shm_size="128"eaccelerator.cache_dir="/usr/local/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="300"eaccelerator.shm_prune_period="120"eaccelerator.shm_only="0"eaccelerator.compress="1"eaccelerator.compress_level="9"
然后执行以下命令使配置生效:/sbin/sysctl -p 以下的步骤和张宴步骤中一样配置,不再赘诉














发表评论