系统环境:Centos 6.3 X64 mini
源码存放路径:/usr/local/src
源码安装路径:/usr/local
数据库路径:/data/mysql/data
网站路径:/usr/local/apache/htdocs
——————————————-前期准备工作———————————————–
关闭防火墙以及selinux
#service iptables stop
#chkconfig iptables off
#vi /etc/selinux/config #把SELINUX=enforcing 修改为disabled
保存并退出。重新启动电脑
——————————————-安装开始—————————————————–
yum -y install gcc gcc-c++ autoconf nss_ldap libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers pcre pcre-devel make wget vim cmake gd gd-devel libevent libevent-devel zip unzip
——————————————-安装apache————————————————-
#cd /usr/local/src
#tar zvxf apr-1.4.6.tar.gz
#tar zvxf apr-util-1.5.1.tar.gz
#tar zvxf httpd-2.4.3.tar.gz
cd apr-1.4.6
./configure –prefix=/usr/local/apr
make && make install
cd ../
cd apr-util-1.5.1
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
make && make install
cd ../
cd httpd-2.4.3
./configure –prefix=/usr/local/apache –enable-dav –enable-so –enable-maintainer-mode –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util
make && make install
cd ../
——————————————-安装mysql————————————————-
groupadd mysql
useradd -g mysql mysql -s /sbin/nologin
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
mkdir -p /usr/local/mysql
tar zxvf mysql-5.5.28.tar.gz
cd mysql-5.5.28
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/data -DSYSCONFDIR=/etc
make
make install
cd /usr/local/mysql
cp ./support-files/my-medium.cnf /etc/my.cnf
./scripts/mysql_install_db –datadir=/data/mysql/data –user=mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig mysqld on
echo ‘basedir=/usr/local/mysql/’ >> /etc/rc.d/init.d/mysqld
echo ‘datadir=/data/mysql/data/’ >>/etc/rc.d/init.d/mysqld
service mysqld start
echo ‘export PATH=$PATH:/usr/local/mysql/bin’ >> /etc/profile
ln -s /usr/local/mysql/lib/mysql /usr/local/lib64/mysql
ln -s /usr/local/mysql/include/mysql /usr/local/include/mysql
——————————————-安装PHP————————————————-
cd /usr/local/src
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
/sbin/ldconfig
cd libltdl
./configure –enable-ltdl-install
make && make install
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
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
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
cd ../
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make && make install
cd ../
tar zxvf pcre-8.31.tar.gz
cd pcre-8.31
./configure –prefix=/usr/local/pcre
make
make install
cd ../
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure –prefix=/usr/local
make && make install
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make && make install
cd ../
tar zxvf php-5.3.18.tar.gz
cd php-5.3.18/
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs –with-mysql=/usr/local/mysql/ –with-ttf –with-xmlrpc –with-openssl –with-zlib –with-freetype-dir –with-gd –with-jpeg-dir –with-png-dir –with-iconv=/usr/local/libiconv –enable-short-tags –enable-sockets –enable-zend-multibyte –enable-soap –enable-mbstring –enable-static –enable-gd-native-ttf –with-curl –with-mcrypt
make && make install
cp php.ini-production /usr/local/php/etc/php.ini
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 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 ../
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
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
mkdir /tmp/eaccelerator
chmod 777 /tmp/eaccelerator
cd ../
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
mkdir -p /usr/local/zend/
cp ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/
chown www.www /usr/local/apache/htdocs/ -R
chmod 700 /usr/local/apache/htdocs/ -R
——————————————-修改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文件类型错误解析漏洞。
3.13配置eAccelerator加速PHP:
mkdir -p /usr/local/eaccelerator_cache
vi /usr/local/php/etc/php.ini
按shift+g键跳到配置文件的最末尾,加上以下配置信息:
[eaccelerator]
zend_extension=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so”
eaccelerator.shm_size=”64″
eaccelerator.cache_dir=”/usr/local/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″
[Zend Optimizer]
zend_optimizer.optimization_level=15
zend_extension=”/usr/local/zend/ZendOptimizer.so”
/usr/local/apache/bin/apachectl restart
本文出自 “爱在7元钱” 博客,请务必保留此出处http://oakcdrom.blog.51cto.com/1940330/1126883