LNAMP第二版(Nginx 1.2.0+Apache 2.4.2+PHP 5.4)(4)

#=================== Install PHP 5.4.0 ===============#
#编译安装相关支持库
cd /opt
tar -zxvf libiconv-1.14.tar.gz
cd libiconv-1.14/
./configure
make;make install
cd ../

tar -jxvf libmcrypt-2.5.8.tar.bz2
cd libmcrypt-2.5.8/
./configure
make;make install
/sbin/ldconfig

cd libltdl/
./configure --enable-ltdl-install
make;make install

cd /opt
tar -jxvf mhash-0.9.9.9.tar.bz2
cd mhash-0.9.9.9/
./configure
make;make install
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

cd /opt
tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make;make install

#编译php,这里我们为php打入补丁.有助于防止邮件发送被滥用(多用户)以及在邮件中提供有价值的信息.补丁介绍信息请点击:~steveb/patches/php-mail-header-patch/
cd /opt
tar -jxvf php-5.4.0.tar.gz
patch -d php-5.4.0 -p1 < php5-mail-header.patch
cd php-5.4.0
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/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-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-ldap \
--with-ldap-sasl \
--with-xmlrpc \
--enable-zip \
--enable-soap

make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-production /usr/local/php/etc/php.ini
cd ../

#安装php扩展模块
cd /opt
tar -zxvf memcache-3.0.6.tgz
cd memcache-3.0.6/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir --enable-memcache
make;make install
cd ../

#make时出错(如下图)

LNAMP第二版(Nginx 1.2.0+Apache 2.4.2+PHP 5.4)


#解决办法:修改memcache.c
将721行:
zend_list_insert(mmc, le_memcache_server);
改为:
zend_list_insert(mmc TSRMLS_CC, le_memcache_server);

将738行:
zend_list_insert(mmc, le_memcache_server);
改为:
zend_list_insert(mmc TSRMLS_CC, le_memcache_server);

将778行:
list_id = zend_list_insert(pool, le_memcache_pool);
改为:
list_id = zend_list_insert(pool TSRMLS_CC, le_memcache_pool);

将839行:
list_id = zend_list_insert(pool TSRMLS_CC, le_memcache_pool);
改为:
list_id = zend_list_insert(pool, le_memcache_pool);

#用sed修改

sed -i 's#zend_list_insert(mmc, le_memcache_server);#zend_list_insert(mmc TSRMLS_CC, le_memcache_server);#' memcache.c  sed -i 's#list_id = zend_list_insert(pool, le_memcache_pool);#list_id = zend_list_insert(pool TSRMLS_CC, le_memcache_pool);#' memcache.c 

#php的扩展memcache,不支持cas,所以我们要装memcached扩展,memcached扩展是基于libmemcached,所以要先安装libmemcached

#安装memcached的服务端支持库
cd /opt
tar -xzf libevent-2.0.18-stable.tar.gz
cd libevent-2.0.18-stable
./configure
make;make install
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib

#安装Memcached服务端
cd /opt
tar -xzf memcached-1.4.13.tar.gz
cd memcached-1.4.13
./configure --prefix=/usr/local/memcached --with-libevent=/usr
make;make install

cd /opt
tar -zxvf libmemcached-1.0.2.tar.tar
cd libmemcached-1.0.2
./configure --prefix=/usr/local/libmemcached  --with-memcached
 make;make install

#安装php的memcached扩展库
cd /opt
tar -zxvf memcached-2.0.1.tgz
cd memcached-2.0.1
/usr/local/php/bin/phpize
./configure --enable-memcached --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --with-memcached --with-zlib
make;make install

#因eaccelerator-0.9.6.1不支持php 5.4.0,所以就改用XCache 2.0.0
cd /opt
tar -zxvf xcache-2.0.0.tar.gz
cd xcache-2.0.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make;make install

#安装pdo扩展
cd /opt
php-5.4.0/ext/pdo_mysql
/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 /opt
tar -jxvf ImageMagick-6.7.6-7.tar.bz2
cd ImageMagick-6.7.6-7
./configure --prefix=/usr/local/imagemagick
make;make install

#imagick最新正式版为imagick-3.0.1.tgz,但imagick-3.0.1.tgz在make的时候会出现大量的报错信息,所以就改用imagick-3.1.0RC1.tgz
cd /opt
tar -zxvf imagick-3.1.0RC1.tgz
cd imagick-3.1.0RC1/
export  PKG_CONFIG_PATH=/usr/local/imagemagick/lib/pkgconfig
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/imagemagick
make;make install

cd /opt
tar -jxf ioncube_loaders_lin_x86.tar.bz2
cd ioncube
mkdir /usr/local/ioncube
mv ioncube_loader_lin_5.2.so /usr/local/ioncube/

#修改php.ini添加php扩展

sed -i 's#; extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20100525/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\nextension = "memcached.so"\nextension = "imagick.so"\n#' /usr/local/php/etc/php.ini cat >> /usr/local/php/etc/php.ini <<EOF [xcache-common]  extension = xcache.so   [xcache]  xcache.shm_scheme =        "mmap" xcache.size  =               256M xcache.count =                 8 xcache.slots =                8K xcache.ttl   =                 0 xcache.gc_interval =           0  xcache.var_size  =            8M xcache.var_count =             8 xcache.var_slots =            8K xcache.var_ttl   =             0 xcache.var_maxttl   =          0 xcache.var_gc_interval =     300  xcache.test =                Off xcache.readonly_protection = Off xcache.mmap_path =    "/dev/zero"  xcache.coredump_directory =   ""  xcache.cacher =               On xcache.stat   =               On xcache.optimizer =           Off  [xcache.coverager]  xcache.coverager =          Off  xcache.coveragedump_directory = "" EOF 

#隐藏php版本
sed -i 's#expose_php = On#expose_php = Off#' /usr/local/php/etc/php.ini

#php安全设置,禁用函数
sed -i 's#disable_functions =#disable_functions =phpinfo,exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source#' /usr/local/php/etc/php.ini
  
#重启apache,查看php扩展加载的情况
/etc/init.d/httpd restart

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/190e9d2b65671c8d3e1bb107b74c759a.html