1. 安装SecureCRT的sz/rz工具包(linux终端可以跳过)
yum install lrzsz
2. 安装apache
2.1. 编译依赖
2.1.1安装zlib
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
2.1.2 安装 openssl
./config \
--prefix=/usr/local/openssl \
shared zlib-dynamic \
enable-camellia
2.2. 编译配置
./configure \
--prefix=/usr/local/apache \
--enable-mods-shared=most \
--enable-rewrite \
--enable-speling \
--enable-forward \
--enable-ssl \
--enable-so \
--with-ssl=/usr/local/openssl
2.3. 编译后工作
# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
# service httpd start
2.4. 错误处理
httpd: Syntax error on line 83 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/mod_ssl.so into server: libssl.so.1.0.0: cannot open shared object file: No such file or directory
修改/etc/init.d/http
增加export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openssl/lib, 此外64位系统也会造成这个错误。那么也许要把lib文件夹拷贝一份称为lib64.
3. 安装mysql
3.1. 编译依赖
如果是fedora/centos/redhat可以执行
# yum -y install ncurses-devel
如果是ubuntu可以执行
apt-get install libncurses5-dev
3.2. 编译配置
./configure \
--prefix=/usr/local/mysql \
--with-charset=utf8 \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--with-extra-charsets=all \
--with-charset=utf8 \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--with-plugins=all \
--with-pthread \
--enable-thread-safe-client \
--enable-assembler
3.3. 编译后工作
配置MySQL
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
./bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
chgrp -R mysql .
./bin/mysqld_safe --user=mysql &
./bin/mysqladmin -uroot password ‘your passwd’
启动mysql: /usr/local/mysql/bin/mysqld_safe &
关闭mysql:/usr/local/mysql/bin/mysqladmin shutdown
代码: cp ./support-files/mysql.server /etc/ init.d/mysqld
可以使用server mysqld restart启动
4. 安装php
4.1. 编译依赖
bizp2
gd2
iconv
Freetype
yum install freetype*
yum install *mcrypt*
yum install *mhash*
yum install gdbm-devel db4-devel
yum install libjpeg-devel freetype-devel libpng-devel
yum install libXpm-devel
4.2. 配置依赖
./configure \
--prefix=/usr/local/php \
--with-libdir=lib64 \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-bz2 \
--enable-zip \
--enable-calendar \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql \
--enable-sqlite-utf8 \
--with-iconv=/usr/local/libiconv \
--enable-mbstring \
--with-curl=/usr/local \
--enable-exif \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-xpm-dir=/usr \
--with-ttf \
--with-freetype-dir=/usr \
--enable-gd-native-ttf \
--with-xmlrpc \
--enable-soap \
--enable-sockets \
--with-mcrypt \
--with-mhash \
--enable-shmop \
--with-gdbm \
--with-db4 \
--with-kerberos \
--with-mcrypt=/usr/local \
--with-mhash=/usr/local \
--enable-pcntl \
--enable-fpm \
--enable-ftp \
--enable-calendar \
--with-openssl
4.3. 错误提示
其他啥错误都是浮云。解决so easy.以下2个错误搞的我很蛋疼。
/usr/bin/ld: /usr/local/lib/libbz2.a(bzlib.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with –fPIC
/usr/local/lib/libbz2.a: could not read symbols: Bad value
collect2: ld 返回 1
make: *** [libtokyocabinet.so.8.22.0] 错误
/usr/bin/ld: /usr/local/lib/libz.a(crc32.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
make: *** [libtokyocabinet.so.8.22.0] 错误 1
解决方案:
- 修改zlib-1.2.3的Makefile文件
把gcc的编译参数加上 –fPIC
原文:CFLAGS=-O3 -DUSE_MMAP
修改为:CFLAGS=-O3 -DUSE_MMAP –fPIC
- 修改bzip2的Makefile文件
CC改为CC=gcc –fPIC
然后重新编译。