转自:http://www.wemvc.com/535.html
时间:2009年3月
前提:安装centos 5.2安装时默认配置就好,配置好网卡,安装系统时自订软件,只安装最基本的工具,Development Library、Development Tool、Editor。
相关站点:
相关软件:
首先我们要看下Zend Framework官方的的需求。
Table A.1. PHP Extensions Used in Zend Framework by Component
php-5.2.5.tar.gz
libxml2-2.6.24.tar.gz (安装php5必须)
curl-7.15.0.tar.gz
libiconv-1.12.tar.gz
libmcrypt-2.5.7.tar.gz
mcrypt-2.6.7.tar.gz
xmlrpc-2.2.1.tar.gz
libedit-0.3.tar.gz
pspell-.12.2.tar.gz
openssl-0.9.8i.tar.gz
gettext-0.17.tar.gz
gd-2.0.35.tar.gz
freetype-2.3.7.tar.gz
jpegsrc.v6b.tar.gz
libpng-1.2.33.tar.gz
zlib-1.2.3.tar.gz
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.12.tar.gz
libiconv-1.12.tar.gz
ftp://ftp.gnu.org/gnu/gettext/gettext-0.17.tar.gz
http://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/libxml2-2.6.24.tar.gz
http://curl.haxx.se/download/curl-7.15.0.tar.gz
ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
http://voxel.dl.sourceforge.net/sourceforge/mcrypt/mcrypt-2.6.7.tar.gz
http://www.libgd.org/releases/gd-2.0.35.tar.gz
http://voxel.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.7.tar.gz
http://www.ijg.org/files/jpegsrc.v6b.tar.gz
http://voxel.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.33.tar.gz
http://www.zlib.net/zlib-1.2.3.tar.gz
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.12.tar.gz
把以上所有软件包下载到:/home/source/software/目录下。
mysql-5.1.30-linux-i686-glibc23
如果系统为64位,请下载mysql源码进行64位的编译安装。
shell> groupadd mysql shell> useradd -g mysql mysql shell> cd /usr/local shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf - shell> ln -s full-path-to-mysql-VERSION-OS mysql shell> cd mysql shell> chown -R mysql . shell> chgrp -R mysql . shell> scripts/mysql_install_db --user=mysql shell> chown -R root . shell> chown -R mysql data shell> bin/mysqld_safe --user=mysql &
cd support-files cp my-large.cnf /etc/my.cnf cp mysql.server /etc/rc.d/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on service mysqld start /usr/local/mysql/bin/mysqld_safe -user=mysql & //加&以后台模式启动mysql 设置mysql root密码 /usr/local/mysql/bin/mysqladmin -u root password 密码 //全新安装的mysql没有密码 修改mysql root密码 /usr/local/mysql/bin/mysqladmin -u原密码 root password 新密码 进入mysql /usr/local/mysql/bin/mysql -u root -p 停止、启动mysql /usr/local/mysql/support-files/mysql.server { stat | stop } service mysqld { stat | stop }
MySQL路径为/usr/local/mysql
去PHP官网下载最新的源码包,我下的是php-5.2.6.tar.bz2。
pspell-.12.2.tar.gz
mkdir /usr/local/pspell cd pspell-.12.2 ./configure --prefix=/usr/local/pspell make; make install
a.安装 jpeg6
建立目录:
mkdir -p /usr/local/jpeg mkdir -p /usr/local/jpeg/bin mkdir -p /usr/local/jpeg/lib mkdir -p /usr/local/jpeg/include mkdir -p /usr/local/jpeg/man mkdir -p /usr/local/jpeg/man1 mkdir -p /usr/local/jpeg/man/man1 cd /home/source/software/ tar -zvxf jpegsrc.v6b.tar.gz cd jpeg-6b ./configure --prefix=/usr/local/jpeg/ --enable-shared --enable-static make; make install
备注:
在64 位下编译jpeg-6b时候报以下错误:
make: ./libtool: Command not found make: *** [jcapimin.lo] Error 127
错误分析:由于libtool版本过低导致的,重新下载新版本的libtool以默认方式安装,执行以下命令:
./configure make make install
然后进入jpeg-6b的源码目录,然后执行以下步骤,切记!
cp /usr/share/libtool/config.sub . cp /usr/share/libtool/config.guess . ./configure --prefix=/usr/local/jpeg/ --enable-shared --enable-static make make install
b.:安装zlib
cd /home/source/software/ tar -zxvf zlib-1.2.3.tar.gz mkdir -p /usr/local/zlib cd zlib.1.2.3 ./configure --prefix=/usr/local/zlib make;make install
c.安装 freetype
cd /home/source/software/ tar -zvxf freetype-2.1.10.tar.gz cd freetype-2.1.10 mkdir -p /usr/local/freetype ./configure --prefix=/usr/local/freetype make;make install
d.安装libpng
cd /home/source/software/ mkdir -p /usr/local/png tar -zvxf libpng-1.2.8.tar.gz cd libpng-1.2.8 cp scripts/makefile.std makefile vi makefile
不要用prefix定义路径否则会影响gd安装
ZLIBLIB=/usr/local/zlib ZLIBINC=/usr/local/zlib/include
make; make install
e.安装gettext
ftp://ftp.gnu.org/gnu/gettext/gettext-0.17.tar.gz
tar xf gettext-0.17.tar.gz cd gettext-0.17 mkdir /usr/local/gettext ./configure --prefix=/usr/local/gettext make make install
f.安装GD库
cd /home/source/software/ tar -zvxf gd-2.0.33.tar.gz mkdir -p /usr/local/gd2 cd gd-2.0.33 ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg/ --with-zlib=/usr/local/zlib --with-freetype=/usr/local/freetype/ --with-png make; make install
安装GD
tar xzvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure –prefix=/usr/local/gd2 –with-jpeg=/usr/local/jpeg6/ –with-png –with-zlib –with-freetype=/usr/local/freetype/ –with-fontconfig=/usr/local/fontconfig
make
make install
错误:
configure.ac:64: error: possibly undefined macro: AM_ICONV
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
解决:
cd ..
tar zxvf gettext-0.17.tar.gz
cd gettext-0.17
./configure –prefix=/usr/local/gettext –disable-java –disable-native-java
make
make install
/bin/sed: can’t read /lib/libattr.la: No such file or directory
ln -s /usr/lib/* /lib/
再安装gettext
再安装gdX86 64位LINUX下安装GD的注意事项
错误提示:
/usr/bin/ld: /usr/local/lib/libjpeg.a(jcapimin.o): relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC进入Jpeg目录
CFLAGS=”-O3 -fPIC” ./configure
make
make install-lib编译前需指定为64位编译模式,否则会出现以下错误:
/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32against `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.gztar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configurevi Makefile
找到 CFLAGS=-O3 -DUSE_MMAP
在后面加入-fPIC,即变成CFLAGS=-O3 -DUSE_MMAP -fPIC
接下面步骤make
make installnfig.so -L/usr/lib64 /usr/local/freetype/lib/libfreetype.so -lpng -lz -lm -Wl,–rpath -Wl,/usr/local/freetype/lib -Wl,-soname -Wl,libgd.so.2 -o .libs/libgd.so.2.0.0
/usr/bin/ld: /usr/local/lib/libpng.a(png.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/libpng.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
重新安装libpng;删除解压文件,重新解压
cp scripts/makefile.linux makefile
vi Makefile
找到 CFLAGS=后加上-fPIC
make test
make install再重新安接gd;
vi Makefile
找到 CFLAGS=后加上-fPIC
g.安装Curl库
cd /home/source/software/ tar -zvxf curl-7.15.0.tar.gz mkdir -p /usr/local/curl ./configure --prefix=/usr/local/curl make; make install
h.安装libxml2
cd /home/xiutuo/software/ tar -zxvf libxml2-2.6.24.tar.gz cd libxml2-2.6.24 mkdir -p /usr/local/libxml2 ./configure --prefix=/usr/local/libxml2 make; make install
i.安装libiconv-1.12.tar.gz
tar -zxvf libiconv-1.12.tar.gz cd libiconv-1.12 ./configure --prefix=/usr/local/libiconv make make install make clean
j.安装libmcrypt
ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar xf libmcrypt-2.5.7.tar.gz mkdir /usr/local/libmcrypt cd libmcrypt-2.5.7 ./configure --prefix=/usr/local/libmcrypt make make install
k.安装mhash
http://voxel.dl.sourceforge.net/sourceforge/mhash/mhash-0.9.9.tar.gz
tar xf mhash-0.9.9.tar.gz cd mhash-0.9.9 mkdir /usr/local/mhash ./configure --prefix=/usr/local/mhash/ make;make install
j.安装PHP
如果使用PHP-FPM (PHP FastCGI Process Manager)来对进程进行管理,则需要提前做如下工作:
请阅读:《使用PHP-FPM (PHP FastCGI Process Manager)来对php-cgi进程进行管理》
$ sudo -s $ mkdir /usr/local/php $ mkdir /usr/local/php/sourcecode $ mv ~/Download/php-5.2.6.tar.bz2 /usr/local/php/sourcecode $ cd /usr/local/php/sourcecode $ tar xf php-5.2.6.tar.bz2 $ cd php-5.2.6
$ ./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fastcgi --enable-force-cgi-redirect --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-curl=/usr/local/curl --with-libxml-dir=/usr/local/libxml2 --with-libexpat-dir=/usr/lib --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg/ --with-zlib-dir=/usr/local/zlib/ --with-png-dir=/usr/local/png/ --with-freetype-dir=/usr/local/freetype/ --enable-soap --enable-sockets --enable-dom --enable-sysvshm=yes --enable-ftp --enable-calendar --enable-sockets --with-db4 --with-bz2 --with-iconv=/usr/local/libiconv --with-gettext=/usr/local/gettext --with-mcrypt=/usr/local/libmcrypt --enable-mbstring=cn --with-mhash=/usr/local/mhash --with-mime-magic --with-openssl --disable-cli --enable-bcmath --enable-calendar --enable-ctype --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-zip --enable-dba=shared --enable-dbase --enable-exif --with-pspell=/usr/local/pspell --with-gmp $ make $ make install
当编译php时如果在64位系统下出现如下报错信息
checking for MySQL UNIX socket location… no
checking for mysql_close in -lmysqlclient… no
checking for mysql_error in -lmysqlclient… no
configure: error: mysql configure failed. Please check config.log for more information.
是使用了二进制的mysql所致,请下载mysql源码进行64位的编译安装。
说明:
sudo -s切换到超级用户模式,输入你的密码;
mkdir /usr/local/php建立php 5.2.6的安装目录;
mkdir /usr/local/php/sourcecode 并建立源码包存放位置,以方便日后快速的往php里面添加所须的模块;
解压缩,然后配置安装。
Mac OS 10.5不带PCRE,而PCRE又是NGINX不可缺少的,所以要我们自己安装。
$ mkdir -p /usr/local/src $ cd /usr/local/src $ curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz $ tar xvfz pcre-7.7.tar.gz $ cd pcre-7.7 $ ./configure --prefix=/usr/local --enable-utf8 $ make $ make install $ cd ..
可以直接到官方下载源码包,也可以从用下面的CURL下载。
$ cd /tmp $ curl -O http://sysoev.ru/nginx/nginx-0.6.32.tar.gz $ tar xvfz nginx-0.6.32.tar.gz $ cd nginx-0.6.32 $ ./configure --prefix=/usr/local/nginx --with-http_ssl_module $ make $ sudo make install
启动NGINX:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
至此东西安装好了,看下http://localhost/,是不是nginx在欢迎你进入它的世界呢?呵呵,如果你看到了,那么恭喜你。
NGINX配置文件修改:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location ~ .*\.php?$ {
fastcgi_pass 127.0.0.1:1026;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
启动PHPCGI:
/usr/local/php/bin/php-cgi -q -b "127.0.0.1:1026"
此时你可以在/usr/local/nginx/html/底下写一个index.php,然后访问http://localhost/index.php
phpinfo();
?>
bash-3.2# curl -o http://www.lighttpd.net/download/lighttpd-1.4.20.tar.gz
bash-3.2# tar xf lighttpd-1.4.20.tar.gz
bash-3.2# cd lighttpd-1.4.20
bash-3.2# ./configure
bash-3.2# make
bash-3.2# cp src/spawn-fcgi /usr/local/nginx/sbin/
bash-3.2# /usr/local/nginx/sbin/spawn-fcgi -p 1026 -C 5 -u nobody -g nobody -f /usr/local/php/bin/php-cgi
也可以自己写个shell脚本,在此就不多写了。
大公告成~!
备注:
若出现这个错误
error while loading shared libraries: /usr/local/gd/lib/libgd.so.2: cannot restore segment prot after reloc: Permission denied
原来这是SELinux搞的鬼,解决办法有如下两个
1. 使用chcon 命令
示例: chcon -t texrel_shlib_t /usr/local/gd/lib/libgd/*.so.2
2. 禁止掉SELinux
更改/etc/sysconfig/selinux 文件的内容为 SELINUX=disabled
附加使用教程:
关闭NGINX:(Mac OS 用户可以通过活动监视器杀死nginx进程)
killall -9 nginx
不中断服务,重新启动NGINX:
ps -aux | grep nginx
查看主进程号pid
kill -HUP pid
作者:JoshuaLJD