构造AMP平台完全攻略

10 篇文章 0 订阅
7 篇文章 0 订阅
 

                            构造AMP平台完全攻略

作者:Kein.U (YOUDI)

E-mail/Gtalk:youdimail@gmail.com

apache:

wget http://apache.mirror.phpchina.com/httpd/httpd-2.2.9.tar.bz2

php:

wget http://cn2.php.net/distributions/php-5.2.6.tar.bz2

mysql:

wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.51b.tar.gz/from/htp://mysql.ntu.edu.tw/

Openssh:

wget http://www.openssl.org/source/openssl-0.9.8h.tar.gz

pdflib:

wget http://www.pdflib.com/binaries/PDFlib/703/PDFlib-7.0.3-Linux-php.tar.gz

jpeg:

wget ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz

pnglib:

wget http://nchc.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.31.tar.bz2

zlib:

wget http://www.zlib.net/zlib-1.2.3.tar.gz

pdflib所需的:

http://dl.maptools.org/dl/libtiff/tiff-3.8.2.zip

freetype:

http://download.savannah.gnu.org/releases/freetype/freetype-2.3.7.tar.gz

gd:

http://www.libgd.org/releases/gd-2.0.35.tar.bz2

libxml2

wget ftp://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/libxml2-2.6.30.tar.gz

curl:

wget http://curl.haxx.se/download/curl-7.18.2.tar.bz2

 

libiconv

 

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.12.tar.gz

 

gettext:

wget ftp://ftp.ntu.edu.tw/pub/gnu/gnu/gettext/gettext-0.17.tar.gz

ncurses:

wget ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz

libmcrypt:

wget http://nchc.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.bz2

mhash:

wget http://nchc.dl.sourceforge.net/sourceforge/mhash/mhash-0.9.9.tar.bz2

 

bz2:

wget http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz

为了让PHP运行相对独立于系统,这样做是为更好管理PHP扩展,更好的与系统中的其它软件不生冲突。

 mkdir /usr/local/phplibs

我们使用标准的安装路径,/usr/local/src

目标是/usr/local/

首先我们来安装数据库

/usr/local/database

tar zxvf mysql-5.0.51b.tar.gz

mv mysql-5.0.51b mysqlsrc

  加入mysql用户

groupadd mysql

useradd -g mysql mysql

查看cpu信息:

cat /proc/cpuinfo

我的cpu是:

 

processor : 0

vendor_id : GenuineIntel

cpu family : 6

model : 15

model name : Intel(R) Core(TM)2 Duo CPU T7250 @ 2.00GHz

stepping : 13

cpu MHz : 2001.000

cache size : 2048 KB

physical id : 0

siblings : 2

core id : 0

cpu cores : 2

fpu : yes

fpu_exception : yes

cpuid level : 10

wp : yes

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm ida

bogomips : 3993.29

clflush size : 64

cache_alignment : 64

address sizes : 36 bits physical, 48 bits virtual

power management:

因此我采用编译参数为:

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"

CXXFLAGS="${CFLAGS}"

建立make.sh

#!/bin/sh

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"

CXXFLAGS="${CFLAGS}"

./configure --prefix=/usr/local/database --with-charset=gbk --with-extra-charsets=gb2312,big5 --enable-thread-safe-client --enable-local-infile --enable-assembler --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --without-debug

make

make installl

安装mysql系统表:

/usr/local/src/mysqlsrc/scripts/mysql_install_db

修改用户权限:

chown -R mysql:mysql /usr/local/database

mkdir -p /var/mysql/var

 

ln -s  /usr/local/database/var /var/mysql/var

cp /usr/local/database/share/mysql/mysql.server /etc/rc.d/init.d/

 

chkconfig –add mysql.server

chkconfig –level 3 mysql.server on

chkconfig –level 4 mysql.server on

chkconfig –level 5 mysql.server on

serivice mysql.server start

vi /etc/ld.so.conf

/usr/local/database/lib/mysql/

运行

ldconfig

mysql安装完成。

安装 openssl-0.9.8h

tar zxvf openssl-0.9.8h.tar.gz

cd openssl-0.9.8h

./config  –prefix=/usr/local/phplibs

make

make test

make install

安装jpeg:

 

tar zxvf jpegsrc.v6b.tar.gz

cd jpeg-6b

mkdir -p  /usr/local/phplibs/bin/cjpeg

mkdir -p /usr/local/phplibs/man/man1

mkdir –p /usr/local/phplibs/include

mkdir –p /usr/local/phplibs/lib

./configure -–prefix=/usr/local/phplibs

make

make install

make install-lib

如果是64位系统加入

make CFLAGS=-fpic libjpeg.a


jpeg安装完成。

 

安装freetype

tar zxvf freetype-2.3.7.tar.gz

cd freetype-2.3.7

./configure –-prefix=/usr/local/phplibs

make

make install

freetype 安装完成

 

安装zlib

tar zxvf zlib-1.2.3.tar.gz

cd zlib-1.2.3

./configure –-prefix=/usr/local/phplibs

如果是64位系统加入

 vim Makefile

CFLAGS=-O3 -DUSE_MMAP 改为 CFLAGS=-O3 -DUSE_MMAP -fPIC

make

make install

zlib 安装完成

 

安装libpng

tar jxvf libpng-1.2.29.tar.bz2

cd libpng-1.2.29

./configure –-prefix=/usr/local/phplibs

cp scripts/makefile.linux makefile

make

make install

libpng 安装完成

 

安装tiff

unzip tiff-3.8.2.xip

cd tiff-3.8.2

make

make install

tiff 安装完成

 

安装gd

tar jxvf gd-2.0.35.tar.bz2

cd  gd-2.0.35

./configure

make

make install

cp gd.h /usr/local/phplibs/lib/

gd安装完成。

 

安装libxml2-2.6.30

tar zxvf libxml2-2.6.30.tar.gz

cd libxml2-2.6.30

./configure –-prefix=/usr/local/phplibs

make

make install

make tests

libxml安装完成

 

安装curl

tar jxvf curl-7.18.2.tar.bz2

cd curl-7.18.2

./configure

make

make install

安装 openssl-0.9.8h

tar zxvf openssl-0.9.8h.tar.gz

cd openssl-0.9.8h

./config –prefix=/usr/local/ssl

make

make test

make install

 

安装libiconv

tar zxvf libiconv-1.12.tar.gz

./configure –prefix=/usr/local/phplibs

make

make install

make clean

 

安装gettext:

tar zxvf gettext-0.17.tar.gz

cd gettext-0.17

 . ./configure --prefix=/usr/local/phplibs/

 make 

 make install

 

安装ncurses

cd ncurses-5.6

./configure --prefix=/usr/local/phplibs/

make

make install

 

安装libmcrypt

tar jxvf libmcrypt-2.5.8.tar.bz2

cd libmcrypt-2.5.8

./configure –prefix=/usr/local/phplibs

make

make install

cp include/mcrypt.h  /usr/include/

安装mhash

tar jxvf mhash-0.9.9.tar.bz2

cd mhash-0.9.9

./configure --prefix=/usr/local/phplibs/

make

make install

安装bz2

tar zxvf bzip2-1.0.5.tar.gz

cd bzip2-1.0.5

make install PREFIX=/usr/local/phplibs

 

安装apache

建立makehttpd.sh

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"

CXXFLAGS="${CFLAGS}"

./configure  --prefix=/usr/local/www/apache --enable-mods-shared=all --with-ssl=/usr/local/phplibs/

make

make install

make clean

设置ssl

ln -s /usr/local/ssl/bin/openssl /usr/local/bin/openssl

建立自己的CA

mkdir /usr/local/www/apache/conf/ssl.key

cd /usr/local/www/apache/conf/ssl.key

wget  http://www.openssl.org/contrib/ssl.ca-0.1.tar.gz

tar zxvf ssl.ca-0.1.tar.gz

cd ssl.ca-0.1

./new-root-ca.sh       (生成根证书ca.keyca.crt)

./new-server-cert.sh server    (生成服务端证书server.csrserver.key)

./sign-server-cert.sh server   (签署)

./new-user-cert.sh client   客户端证书制作

./sign-user-cert.sh client 客户端证书签署

./p12.sh client   将客户端证书从x.509转化成pkcs12格式

chmod 400  server.key

mv server.key ../

mv server.crt ../

参加apache为系统服务

cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

vim /etc/init.d/httpd

添加两行代码:

#chkconfig: 345 85 15
#description: Apache

345为,系统运行级别3,4,5

85为开始序列

15为停止序列

ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc5.d/S85httpd

chkconfig --add httpd

 

 

 

 

安装php

tar jxvf php-5.2.6.tar.bz2

cd php-5.2.6

建立makephp.sh

 

HOST="i686-pc-linux-gnu"

CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"

CXXFLAGS="${CFLAGS}"

 ./configure  --with-apxs2=/usr/local/www/apache/bin/apxs --with-mysql=/data/mysql5 --with-mysqli=/data/mysql5/bin/mysql_config --ena

ble-inline-optimization --disable-debug --enable-bcmath --enable-calendar --enable-ctype --enable-dbase --enable-discard-path --enab

le-exif --enable-force-cgi-redirect --enable-ftp  --enable-gd-native-ttf --with-ttf --enable-shmop --enable-sigchild --enable-sysvse

m --enable-sysvshm --enable-wddx --with-jpeg-dir=/usr/local/phplibs --with-png-dir=/usr/local/phplibs --with-freetype-dir=/usr/local

/phplibs --with-zlib=yes --with-zlib-dir=/usr/local/phplibs --with-openssl=/usr/local/phplibs --with-ncurses=/usr/local/phplibs --wi

th-gd --with-gettext=/usr/local/phplibs --with-mysql-sock=/tmp/mysql.sock --with-mcrypt=/usr/local/phplibs --with-mhash=/usr/local/p

hplibs --enable-sockets --enable-mbstring=all --with-curl=/usr/local/phplibs --enable-mbregex --enable-zend-multibyte --enable-exif

--enable-pcntl --with-iconv=/usr/local/phplibs --enable-zip --with-libxml-dir=/usr/local/phplibs –with-bz2=/usr/local/phplibs  --enable-maintainer-zts --enable-zend-multibyte

make  

make test

make install

make clean

如果在make时候出现这个错误

这是安装位置:

usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1

可以这样解决这个问题yum install libtool-ltdl-devel

安装个开发包就可以了。

Installing PHP CLI binary:        /usr/local/bin/

Installing PHP CLI man page:      /usr/local/man/man1/

Installing build environment:     /usr/local/lib/php/build/

Installing header files:          /usr/local/include/php/

Installing helper programs:       /usr/local/bin/

  program: phpize

  program: php-config

Installing man pages:             /usr/local/man/man1/

  page: phpize.1

  page: php-config.1

Installing PEAR environment:      /usr/local/lib/php/

[PEAR] Console_Getopt - installed: 1.2.3

[PEAR] Archive_Tar    - installed: 1.3.2

[PEAR] Structures_Graph- installed: 1.0.2

pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)

[PEAR] PEAR           - installed: 1.7.1

Wrote PEAR system config file at: /usr/local/etc/pear.conf

You may want to add: /usr/local/lib/php to your php.ini include_path

Installing PDO headers:          /usr/local/include/php/ext/pdo/

Installing ZIP headers:          /usr/local/include/php/ext/zip/lib

增加php.ini:

cp /usr/local/src/php-5.2.6/php.ini-recommended /usr/local/lib/php.ini

注意linux php扩展的位置是:

/usr/local/lib/php/extensions/

 

增加mime类型

vim /usr/local/www/apache/conf/httpd.conf

AddType application/x-httpd-php .php , .inc

AddType application/x-httpd-php-source .phps

 

加装php动态扩展的方法:

动态扩展网站http://pecl.php.net

加装memcache

wget http://pecl.php.net/get/memcache-2.2.4.tgz

方法之一:

pear upgrade-all

pear install memcache-2.2.4.tgz

方法二

tar zxvf memcache-2.2.4.tgz  

cd memcache-2.2.4

phpize

./configure

make

make install

vim /usr/local/lib/php.ini

加入:

extension_dir = "/usr/local/lib/php/extensions/no-debug-zts-20060613"

extension= extension=memcache.so

安装opcode优化zend扩展eAccelerator

wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2

tar jxvf eaccelerator-0.9.5.3.tar.bz2

cd eaccelerator-0.9.5.3

./configure --enable-shared

make

make install

mkdir /tmp/eaccelerator 

chmod 777 /tmp/eaccelerator

touch /var/log/eaccelerator_log

修改php.ini

加载模块:

extension=eaccelerator.so

加载选项:

eaccelerator.shm_size=”16″
eaccelerator.cache_dir=”/tmp/eaccelerator”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
eaccelerator.log_file = “/var/log/eaccelerator_log”
eaccelerator.filter=”"
eaccelerator.shm_max=”0″
eaccelerator.shm_ttl=”0″
eaccelerator.shm_prune_period=”0″
eaccelerator.shm_only=”0″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″

安装Zend Optimizer v3.3

wget http://www.phpchina.com/download/soft/zend/optimizer/3.3.3/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz

tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz

cd ZendOptimizer-3.3.3-linux-glibc23-i386

./install-tty

Welcome to the Zend Optimizer 3.3.3 Installation!

 

For more information regarding this procedure, please see the

Zend Optimizer Installation Guide.

 

[To continue, press Enter]

 

 

Do you accept the terms of this license?

Answer (yes or no) [YES]:

 

Please specify the location for installing Zend Optimizer [/usr/local/Zend]:

 

Confirm the location of your php.ini file [/usr/local/lib]

 

Are you using Apache Web server?

Answer (yes or no) [YES]:

The following configuration changes have been made:

 

- The php.ini file has been relocated from /usr/local/lib to /usr/local/Zend/etc

 

- A symbolic link for the php.ini file has been created in /usr/local/lib.

 

- The original php.ini was backed up to

 /usr/local/lib/php.ini-zend_optimizer.bak

 

[To continue, press Enter]

Apache has restarted successfully.

[To continue, press Enter]

一路回车搞定

/usr/local/www/apache/bin/apachectl stop 

/usr/local/www/apache/bin/apachectl start

关于线程安全问题:

线程安全是跟PHP本身并没有关系,是由于过于陈旧的php扩展不支持php5的线程安全,现在新版本的扩展差不多都支持线程安全,所以只要安装新版本的PHP动态扩展不存在线程安全问题

编译PHP,建议apache 2.0以上版本,必须开启

--enable-maintainer-zts

安全动态扩展时:

有线程安全的默认目录

/usr/local/lib/php/extensions/no-debug-zts-20060613

没有线程安全的默认目录

/usr/local/lib/php/extensions/no-debug-non-zts-20060613

如果有问题,请与我联系,欢迎一起讨论解决问题。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值