LAMP安装手记(CentOS6.4+Apache-2.2.22+Mysql-5.1.63+PHP-5.2.17+phpmyadmin-3.4.10.2+ZendDebug)

LAMP安装手记(CentOS6.4+Apache-2.2.22+Mysql-5.1.63+PHP-5.2.17+phpmyadmin-3.4.10.2+ZendDebug)

rpm -e httpd

rpm -e mysql

rpm -e php

yum -y remove httpd php mysql-server mysql php-mysql 

setenforce 0

yum -y install gcc gcc-c++  make automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel  pcre-devel libtool-libs freetype-devel gd zlib-devel file bison patch mlocate flex diffutils   readline-devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel wget unzip 

wget -c http://archive.apache.org/dist/httpd/httpd-2.2.22.tar.gz

wget -c http://dl.mysql.cn/mysql5/5.1/mysql-5.1.63.tar.gz

wget -c http://iweb.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.4.10.2/phpMyAdmin-3.4.10.2-all-languages.tar.gz

wget -c http://us2.php.net/get/php-5.2.17.tar.gz/from/am.php.net/mirror

tar xzf httpd-2.2.22.tar.gz

tar xzf mysql-5.1.63.tar.gz

tar xzf php-5.2.17.tar.gz

tar xzf phpMyAdmin-3.4.10.2-all-languages.tar.gz

cd /tmp/httpd-2.2.22

./configure --prefix=/usr/local/apache --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared  --enable-headers=shared --enable-rewrite=shared --enable-static-support

make

make install

cp build/rpm/httpd.init /etc/init.d/httpd //使用init脚本管理httpd

chmod 755 /etc/init.d/httpd //增加执行权限

chkconfig --add httpd  //添加httpd到服务项

chkconfig  httpd on   //设置开机启动

ln -fs /usr/local/apache/ /etc/httpd

ln -fs /usr/local/apache/bin/httpd /usr/sbin/httpd

ln -fs /usr/local/apache/bin/apachectl /usr/sbin/apachectl

ln -fs /usr/local/apache/logs /var/log/httpd //设置软链接以适应init脚本

groupadd mysql

useradd -g mysql mysql

cd /tmp/mysql-5.1.63

./configure --prefix=/usr/local/mysql/ --localstatedir=/usr/local/mysql/data --without-debug --with-unix-socket-path=/tmp/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=gbk,gb2312,utf8 --with-pthread

make

make install

cp support-files/my-medium.cnf /etc/my.cnf //复制配置文件夹my.cnf

/usr/local/mysql/bin/mysql_install_db --user=mysql  //初始化数据库

chown -R root.mysql /usr/local/mysql

chown -R mysql /usr/local/mysql/data 

cp /tmp/mysql-5.1.63/support-files/mysql.server /etc/rc.d/init.d/mysqld  //init启动脚本

chown root.root /etc/rc.d/init.d/mysqld 

chmod 755 /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

chkconfig  mysqld on

ln -s /usr/local/mysql/bin/mysql /usr/bin

ln -s /usr/local/mysql/bin/mysqladmin /usr/bin

service mysqld start

/usr/local/mysql/bin/mysqladmin -u root password '新密码'   //设置root密码

安装PHP

cd /tmp

wget http://superb-dca2.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

wget http://superb-dca2.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz

wget http://superb-sea2.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz

tar xzf libmcrypt-2.5.8.tar.gz

tar xzf mhash-0.9.9.9.tar.gz

tar xzf mcrypt-2.6.8.tar.gz

//安装libmcrypt

cd /tmp/libmcrypt-2.5.8

./configure --prefix=/usr

make && make install

//安装libmcrypt

cd /tmp/mhash-0.9.9.9

./configure --prefix=/usr

make && make install

//安装mcrypt

/sbin/ldconfig //搜索出可共享的动态链接库

cd /tmp/mcrypt-2.6.8

./configure

make && make install

解决可能出现的报错:

If configure fails try --with-jpeg-dir=<DIR>

configure: error: libpng.(a|so) not found.

解决:

yum install libpng libpng-devel

ln -s /usr/lib64/libjpeg.so /usr/lib/

ln -s /usr/lib64/libpng.so /usr/lib/

解决可能出现的libiconv报错

cd /tmp

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

tar xzf libiconv-1.14.tar.gz

cd libiconv-1.14

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

make && make install

cd /tmp/php-5.2.17

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-openssl --with-zlib --enable-bcmath --with-bz2 --with-curl --enable-ftp --with-gd --enable-gd-native-ttf --with-gettext --with-mhash --enable-mbstring --with-mcrypt --enable-soap --enable-zip --with-iconv=/usr/local/libiconv --with-mysql=/usr/local/mysql --without-pear

make

make install

cp php.ini-dist /usr/local/php/etc/php.ini //复制配置文件php.ini

修改apache配置文件:

在/etc/httpd/conf/httpd.conf文件中加入php文件类型解析:

vi /etc/httpd/conf/httpd.conf

添加

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

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

找到:

ServerName www.example.com:80

修改为:

ServerName localhost:80

service httpd restart  //重启httpd

安装ZendOptimizer-3.3.9

64位:http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz

32位:http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

cd /tmp

wget  http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz

tar xzf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

cd /tmp/ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/

mkdir -p /usr/local/Zend/lib/

cp ZendOptimizer.so /usr/local/Zend/lib

加载zendoptimizer,建立/etc/php.d/zend.ini文件,加入如下代码加载:

[zend]

zend_optimizer.optimization_level=15

zend_extension=/usr/local/Zend/lib/ZendOptimizer.so

service httpd restart

安装eAccelerator-0.9.6.1

cd /tmp

wget http://jaist.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip

unzip eaccelerator-0.9.6.1.zip

cd eaccelerator-0.9.6.1

export PHP_PREFIX="/usr/local/php"

$PHP_PREFIX/bin/phpize

./configure -enable-eaccelerator=shared -with-php-config=$PHP_PREFIX/bin/php-config

make && make install

cd /tmp

mkdir eaccelerator

chmod 0777 eaccelerator

php zenddebugger 加载失败

用php -v 查看信息

[root@E modules]# php -v

Failed loading /usr/lib64/php/modules/ZendDebugger.so: libssl.so.0.9.8: cannot open shared object file: No such file or directory

Failed loading /usr/local/Zend/lib/ZendOptimizer.so: /usr/local/Zend/lib/ZendOptimizer.so: undefined symbol: zend_throw_exception_internal

Failed loading /usr/lib64/php/modules/ZendDebugger.so: libssl.so.0.9.8: cannot open shared object file: No such file or directory

Warning: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0

Warning: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0

PHP 5.3.3 (cli) (built: Nov 22 2013 10:59:29)

Copyright (c) 1997-2010 The PHP Group

Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

原因:因为最新的linux发行版本 libssl 和 libcrypto 已升级到1.0.0

解决:只要创建相应的软链接即可

[root@E modules]# ll /usr/lib64/libssl*

-rwxr-xr-x. 1 root root 221568 2鏈? 23 2013 /usr/lib64/libssl3.so

lrwxrwxrwx. 1 root root 16 11鏈?26 19:31 /usr/lib64/libssl.so -> libssl.so.1.0.1e

lrwxrwxrwx. 1 root root 16 11鏈?26 19:31 /usr/lib64/libssl.so.10 -> libssl.so.1.0.1e

-rwxr-xr-x. 1 root root 436984 12鏈? 4 2013 /usr/lib64/libssl.so.1.0.1e

建立软连接:

ln -s /usr/lib64/libssl.so.1.0.1e /usr/lib64/libssl.so.0.9.8

[root@E modules]# ll /usr/lib64/libcrypto*

lrwxrwxrwx. 1 root root 19 11鏈?26 19:31 /usr/lib64/libcrypto.so -> libcrypto.so.1.0.1e

lrwxrwxrwx. 1 root root 19 11鏈?26 19:31 /usr/lib64/libcrypto.so.10 -> libcrypto.so.1.0.1e

-rwxr-xr-x. 1 root root 1946880 12鏈? 4 2013 /usr/lib64/libcrypto.so.1.0.1e

建立软连接:

ln -s /usr/lib64/libcrypto.so.1.0.1e /usr/lib64/libcrypto.so.0.9.8

参考资料:

linux下让apache能够解析php: http://hi.baidu.com/dengyun0302/item/549840396caa7ffae6bb7a61

解决configure: error: libpng.(a|so) not found.:http://blog.csdn.net/alexdream/article/details/7408438

解决php zenddebugger 安装失败:http://blog.csdn.net/dragon8299/article/details/7175932

http://forums.zend.com/viewtopic.php?f=59&t=12423

http://blog.csdn.net/jianfyun/article/details/6434052

http://stackoverflow.com/questions/13467358/zend-debugger-will-not-load

http://forums.zend.com/viewtopic.php?f=57&t=4071

http://sourceforge.net/projects/eaccelerator/postdownload?source=dlp

mysql:http://download.softagency.net/MySQL/Downloads/MySQL-5.1/

mysql-5.1.63(gz)http://download.mysql.cn/src/2012/0531/5603.html

apache/httpd:http://archive.apache.org/dist/httpd/

http://www.zend.com/en/products/studio/downloads

转载请注明出处:怡然之乐 – FineYi

CentOS6.4 PHP5.2添加ZendDebug扩展 完美支持Zend Studio10.5

之前一段时间用的开发环境是wamp,这个集成包的优点是:安装简单,操作便捷,缺点是:每次重装系统后都要重新安装配置环境,并且和线上的lamp环境不一致,有时本地运行正常的代码上到线上却出现莫名其妙的问题,所以考虑重新为本地安装lamp开发环境,即:windows8+VMware Workstation 10 +CentOs6.4 64位 + lamp + Zend Studio10.5

安装完成后发现无法为PHP添加ZendDebug扩展,查看资料才知道zend官方在PHP5.2之后就不再对ZendDebug提供更新支持,所以如果要用Zend Studio + ZendDebug调试代码的话PHP的版本必须在5.3以下(当然也可以用Zend Studio+Xdebug 组合),无奈只有编译PHP5.2.*老版本安装lamp。

ZendDebug下载:linux64位 linux32位 Zend官方下载

ZendDebug配置过程如下:

[root@E /]#yum -y install php-devel

选择对应版本的ZendDebug.so文件放至:/usr/lib64/php/modules/目录下

(因为本机安装的为PHP5.2.1.7,所以选择ZendDebugger-20110410-linux-glibc23-x86_64/ZendDebugger-20110410-linux-glibc23-x86_64/5_2_x_comp/ZendDebugger.so)

在php.ini中最下方添加配置:

[root@E /]#vi /etc/php.ini
[Zend]
zend_extension=/usr/lib64/php/modules/ZendDebugger.so  //扩展文件绝对路径
zend_debugger.allow_hosts=127.0.0.1/32,192.168.0.0/16   //设置你允许访问的主机IP范围
zend_debugger.expose_remotely=always

保存

[root@E /]#service httpd restart   //重启apache

用phpinfo查看,未发现ZendDebugger扩展,说明加载失败。

用php -v查看,有报错:

[root@E /]# php -v
Failed loading /usr/lib64/php/modules/ZendDebugger.so: libssl.so.0.9.8: cannot open shared object file: No such file or directory
PHP 5.3.3 (cli) (built: Nov 22 2013 10:59:29)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
原因:因为最新的linux发行版本 libssl 和 libcrypto 已升级到1.0.0,而系统中找不到 libssl.so.0.9.8文件

解决:只要创建相应的软链接即可

[root@E /]# ll /usr/lib64/libssl*
-rwxr-xr-x. 1 root root 221568 2 nov  23 2013 /usr/lib64/libssl3.so
lrwxrwxrwx. 1 root root 16 11 nov 26 19:31 /usr/lib64/libssl.so -> libssl.so.1.0.1e
lrwxrwxrwx. 1 root root 16 11 nov 26 19:31 /usr/lib64/libssl.so.10 -> libssl.so.1.0.1e
-rwxr-xr-x. 1 root root 436984 12 nov  4 2013 /usr/lib64/libssl.so.1.0.1e
建立软连接:
[root@E /]#ln -s /usr/lib64/libssl.so.1.0.1e /usr/lib64/libssl.so.0.9.8

[root@E /]# ll /usr/lib64/libcrypto*
lrwxrwxrwx. 1 root root 19 11 nov 26 19:31 /usr/lib64/libcrypto.so -> libcrypto.so.1.0.1e
lrwxrwxrwx. 1 root root 19 11 nov 26 19:31 /usr/lib64/libcrypto.so.10 -> libcrypto.so.1.0.1e
-rwxr-xr-x. 1 root root 1946880 12 nov  4 2013 /usr/lib64/libcrypto.so.1.0.1e
建立软连接:
[root@E /]#ln -s /usr/lib64/libcrypto.so.1.0.1e /usr/lib64/libcrypto.so.0.9.8
[root@E /]#service httpd restart   //重启apache
[root@E /]# php -v
Zend Debugger requires Zend Engine API version 220060519.
The Zend Engine API version 220090626 which is installed, is newer.
Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Debugger.

PHP 5.3.3 (cli) (built: Jul 12 2013 20:35:47)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

报错解决

用phpinfo查看ZendDebug扩展加载成功!

Zend Studio10.5测试,调试正常!

转载请注明出处:怡然之乐 – FineYi

参考资料:stackoverflow  forums.zend.com CSDN

CentOS6.4 LAMP环境为PHP添加Xdebug扩展手记

CentOS6.4 LAMP环境为PHP添加Xdebug扩展手记

之前一直用Zend Studio结合Zend debug+ Firefox+toolbar组合跟踪、调试代码,用起来非常方便。但是Zend官方对zend debug在PHP5.2之后就不再提供支持。目前PHP已更新到5.4,所以就不能再用zend debug调试代码,Xdebug扩展也可以实现类似zend debug的功能。现提供在linux下为PHP添加Xdebug扩展的方法。

当前环境:CentOS6.4 64位 / PHP Version 5.3.3

安装依赖:
[root@E /]# yum -y install gcc automake autoconf libtool make wget php-devel

下载
http://xdebug.org/files/
最新版本:2.2.3
[root@E /]# cd /home/soft
[root@E /]# wget install http://xdebug.org/files/xdebug-2.2.3.tgz
[root@E /]# tar -zxvf xdebug-2.2.3.tgz
[root@E /]# cd xdebug-2.2.3/

查看phpize和php-config路径
[root@E xdebug-2.2.3]# whereis phpize php-config
phpize: /usr/bin/phpize /usr/share/man/man1/phpize.1.gz
php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz

接着执行:
[root@E /]# /usr/bin/phpize  ./configure --enable-xdebug --with-php-config=/usr/bin/php-config

无报错的话执行
[root@E /]# make
在当前目录会生成./modules/xdebug.so
复制到php扩展目录
[root@E xdebug-2.2.3]# cp modules/xdebug.so /usr/lib64/php/modules/

修改php.ini
[root@E modules]# vi /etc/php.ini
在底部加入:
[Xdebug]
zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.profiler_enable = on
xdebug.default_enable = on
xdebug.trace_output_dir="/tmp/xdebug"
xdebug.trace_output_name = trace.%c.%p
xdebug.profiler_output_dir="/tmp/xdebug"
xdebug.profiler_output_name="cachegrind.out.%s

重启apache:
[root@E modules]# service httpd restart

phpinfo查看:

Xdebug

Xdebug扩展添加成功!

转载请注明出处:怡然之乐 – FineYi

参考资料:xdebug file  XMSND  SinaBlog