Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1742913
  • 博文数量: 391
  • 博客积分: 8464
  • 博客等级: 中将
  • 技术积分: 4589
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-13 15:12
个人简介

狮子的雄心,骆驼的耐力,孩子的执著!

文章分类

全部博文(391)

文章存档

2023年(4)

2018年(9)

2017年(13)

2016年(18)

2014年(7)

2013年(29)

2012年(61)

2011年(49)

2010年(84)

2009年(95)

2008年(22)

分类: 系统运维

2009-05-24 17:26:07

一.手动安装依赖包,下载源代码
wget
wget
wget
wget
wget
wget
wget
wget
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.25-rc.tar.gz/from/http://mysql.byungsoo.net/
wget 或者使用yum 安装依

  1. #!/bin/bash
  2. yum install curl curl-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel perl perl-devel gd gd-devel libtool libtool-ltdl libtool-ltdl-devel fontconfig fontconfig-devel freetds freetds-devel freetype freetype-devel libjpeg-devel libpng-devel libc-client-devel pam-devel -y
  3. INSTALLDIR=/usr/local
  4. DIR=/usr/local/src
  5. IMAPVER=imap-2007f
  6. cd /usr/local/src
  7. tar xvzf $DIR/$IMAPVER.tar.gz
  8. cd $DIR/$IMAPVER
  9. make lsu IP6=4 EXTRACFLAGS=-fPIC
  10. mkdir -p /usr/local/imap/{include,lib}
  11. cp c-client/c-client.a /usr/local/imap/lib
  12. cp c-client/c-client.a /usr/local/imap/lib/libc-client.a
  13. cp c-client/*.c /usr/local/imap/lib
  14. cp c-client/*.h /usr/local/imap/include

  15. LIBICONV=libiconv-1.14
    cd $INSTALLDIR
    tar zxvf $DIR/$LIBICONV.tar.gz
    cd $LIBICONV
    ./configure
    make && make install
    ln -s /usr/lib64/libjpeg.so* /usr/lib/
    ln -s /usr/lib64/libpng* /usr/lib/
    ln -s /usr/lib64/libsybdb.so* /usr/lib/
    echo "/usr/local/lib64">>/etc/ld.so.conf
    echo "/usr/local/lib">>/etc/ld.so.conf
    /sbin/ldconfig
二.编译代码到目标执行文件
BASE=/usr/local/website
LD_RUN_PATH=$BASE/openssl/lib:$BASE/mysql/lib/:$BASE/zlib/lib:$BASE/gd/lib:$BASE/libxml2/lib
export LD_RUN_PATH

1.)ZLIB
ZLIB=$BASE/zlib
tar xzf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=$ZLIB
make && make install

2.)LIBICONV
LIBICONV=$BASE/gd
tar xzf libiconv-1.9.2.tar.gz
cd libiconv-1.9.2
./configure --prefix=$LIBICONV --enable-static=yes
make && make install

3.)FREETYPE
FREETYPE=$BASE/gd
tar xzf freetype-2.1.3.tar.gz
cd freetype-2.1.3
./configure --prefix=$FREETYPE
make && make install

4.)LIBJPEG
LIBJPEG=$BASE/gd
tar xzf libjpeg-6b.tar.gz
cd libjpeg-6b
./configure --prefix=$LIBJPEG --enable-shared
mkdir $BASE/gd/man/man1
make & make install

5.)LIBPNG
LIBPNG=$BASE/gd
tar xzf libpng-1.2.30.tar.gz
cd libpng-1.2.30
LDFLAGS="-L$BASE/zlib/lib -Wl,-R$BASE/zlib/lib/"
CPPFLAGS="-I$BASE/zlib/include"
export LDFLAGS CPPFLAGS
./configure --prefix=$LIBPNG
make & make install
 
安装软件时的/usr/local/lib/libz.a(compress.o)错误

/usr/bin/ld: /usr/local/lib/libz.a(compress.o): relocation R_X86_64_32 against `a local symbol' can not be used when

making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value

解决办法 : 重新安装 zlib-1.2.3.tar.gz

tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure

vi Makefile
找到 CFLAGS=-O3 -DUSE_MMAP
在后面加入-fPIC,即变成CFLAGS=-O3 -DUSE_MMAP -fPIC
接下面步骤

make
make install

6.)LIBXML
LIBXML=$BASE/libxml2
tar xzf libxml2-sources-2.6.32.tar.gz
cd libxml2-2.6.32
./configure --prefix=$LIBXML --with-iconv=$BASE/gd --with-zlib=$BASE/zlib
make & make install

7.)GD
GD=$BASE/gd
tar xzf gd-2.0.35RC4.tar.gz
cd gd-2.0.35RC4
./configure --prefix=$GD --with-png=$BASE/gd --with-freetype=$BASE/gd --with-jpeg=$BASE/gd
make & make install
 
8.)OPENSSL
OPENSSL=$BASE/openssl
./config --prefix=$OPENSSL no-threads shared -fPIC
make && make test && make install

9.)MYSQL
tar xzf mysql-5.1.25-rc.tar.gz
cd mysql-5.1.25-rc
#CFLAGS="-O3 -mpentiumpro"
#CXX="gcc"
#CXXFLAGS="-O3 -mpentiumpro -felide-constructors"
#export CFLAGS CXX CXXFLAGS
MYSQL=$BASE/mysql

./configure --prefix=$MYSQL --enable-assembler --with-charset=gbk \
--with-extra-charsets=gb2312,latin1,utf8 --enable-largefile --with-big-tables \
--without-debug --with-max-indexes=64 --with-zlib-dir=$ZLIB \
--with-mysqld-ldflags=-all-static --without-ndbcluster

make & make install
 
【安装后建立服务】
 mkdir $MYSQL/var
 cp mysql-version/share/mysql/my-large.cnf $MYSQL/var/my.cnf
 cp mysql-version/mysql-5.1.34/support-files/mysql.server  /etc/init.d/mysql
 
 $MYSQL/bin/mysql_install_db
 useradd mysql
 chown -Rcf mysql:mysql $MYSQL
 
 redhat\centos : chkconfig --add mysql ; service mysql start
 Ubuntu 9.04 : update-rc.d mysql defaults ; service mysql start
 
【注意】
如果提示”/usr/local/php-5.2.5/sapi/cli/php:error while loading shared libraries: /usr/local/mysql/lib/libmysqlclient.so.16:cannot restore segment prot after reloc: Permission denied”
原因:SELinux
解决方法:chcon –t texrel_shlib_t /usr/local/mysql/lib/libmysqlclient.so.16
 
编译mysql源码时碰到如下问题

checking for tgetent in -ltermcap... no
checking for termcap functions library... configure: error: No curses/termcap library found
 
需要安装ncurses-5.2.tar.gz,安装好之后把安装路径设置到PATH中.或者加参数
 
Redhat/Centos : --with-named-curses-libs=/usr/lib/libncursesw.so.5
 
Ubuntu 9.04 : --with-named-curses-libs=/lib/libncursesw.so.5
 
【./configure 增加innodb支持】
--with-plugins=innobase
 
my.cnf Example :
[mysqld]
innodb_data_home_dir  =  /mysql/var
innodb_data_file_path  =  ibdata1:2000M;ibdata2:2000M
innodb_log_group_home_dir  =  /mysql/var
set-variable  =  innodb_mirrored_log_groups=1
set-variable  =  innodb_log_files_in_group=3
set-variable  =  innodb_log_file_size=30M
set-variable  =  innodb_log_buffer_size=8M
innodb_flush_log_at_trx_commit=1
innodb_log_arch_dir  =  /mysql/var
innodb_log_archive=0
set-variable  =  innodb_buffer_pool_size=80M
set-variable  =  innodb_additional_mem_pool_size=10M
set-variable  =  innodb_file_io_threads=4
set-variable  =  innodb_lock_wait_timeout=50
参考:

10.)APACHE
export LDFLAGS="-L$BASE/openssl/lib -Wl,-R$BASE/openssl/lib"
       export CPPFLAGS="-I$BASE/openssl/include"
 ./configure --prefix=$BASE/apache --enable-ssl --with-ssl=$BASE/openssl \
   --enable-so --enable-mods-shared=most \
  --enable-dav --enable-maintainer-mode
make &&make install
 
# ./configure  \
# --enable-modules=vhost_alias so logio cache cache_mem  \
# --disable-userdir  \
# --with-mpm=worker  \
# --enable-lib64 
服务器在装好CentOS5.2后,开始安装MySql+httpd+php+other,和以往一样进行安装,除了Apache2安装出现了“/usr/lib/libexpat.so: could not read symbols: File in wrong format ”问题以外,其它软件一切正常,以下是我对apache编译configure后进行make遇到的问题:

/usr/lib/libexpat.so: could not read symbols: File in wrong format

这个问题出现在configure后的make,也就是说configure都能顺利通过,但是在make这一步时确有问题了。/usr/lib/libexpat.so: could not read symbols: File in wrong format

1、删除安装目录下的configure文件,在我的环境中是httpd-2.2.6/configure

2、删除“httpd-2.26/srclib/apr-util/configure”

3、通过以下命令重建编译文件(以下命令在http-2.26/目录下运行)。

#./buildconf

4. 、通过以上重建编译文件,现在可以拥有64位的apr-util了,最后在编辑时加上以上参数:

 ./configure --enable-lib64=/usr/lib64

11.)PHP
PHP=$BASE/php
./configure --prefix=$BASE/php --with-apxs2=$BASE/apache/bin/apxs \
 --with-openssl=$BASE/openssl --with-mysql=$BASE/mysql \
 --with-zlib-dir=$BASE/zlib --with-jpeg-dir=$BASE/gd \
 --with-png-dir=$BASE/gd --with-freetype-dir=$BASE/gd \
 --with-ttf --enable-gd-native-ttf --enable-mbstring=cn \
 --with-gd --enable-sockets --enable-bcmath --with-iconv-dir=$BASE/gd \
 --with-libxml-dir=$BASE/libxml2
# --without-sqlite --disable-json 有待验证
make
make install
cp php.ini-dist $PHP/lib/php.ini
#修改 $APACHE/conf/httpd.conf
AddType application/x-httpd-php .php .phtml .php4 .inc
DirectoryIndex index.php
 
#测试PHP连接MYSQL
mysql.php:
mysql_connect("localhost", "username", "password") or die(mysql_error());
echo "Connected to MySQL
";
mysql_select_db("testdb") or die(mysql_error());
echo "Connected to Database";
echo "

";
phpinfo();
?>
阅读(4404) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~