LAMP+phpMyAdmin+eAccelerator+Zend的安装

一、安装前的准备工作
1、操作系统的准备
2、相关软件的准备
3、系统环境的准备
bzip2-devel
zlib-devel
libjpeg-devel
libpng-devel
libtiff-devel
freetype-devel
openssl-devel
libxml2-devel
gettext-devel

这 里我们将编译GD所必须的一些小软件比如libpng,libtiff,freetype,libjpeg,gettext-devel等先用RPM 的方式一并安装好,避免手动编译浪费时间,同时也能避免很多错误,这几个小软件的编译很麻烦。这几个小软件编译错误了,GD 当然安装不了,php5 的编译当然也没戏了。所以我们抓大放小,对这些小牛鬼蛇神采取快速简洁的方式进行安装。并且对服务器的性能也不能产生什么影响。
在终端下用命令:rpm -qa | grep bzip,依次检查各个小软件,没有安装就用命令:yum install -y 文件名 安装。

二、下载以下软件,上传到服务器/usr/src目录下
eaccelerator-0.9.5.2.tar.bz2
mysql-5.0.51.tar.gz
gd-2.0.35.tar.gz
php-5.2.5.tar.gz
httpd-2.2.6tar.gz
ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz

我是在U盘版puppy系统下远程操作CentOS系统的,我要复制软件喽

用命令 :scp -r /mnt/home/src/ root@192.168.2.249:/usr/src/
再用命令 ssh -l root 192.168.2.249 登录远程Linux服务器看下文件。好所有文件都已经复制好了!

三安装gd、apache、mysql、php基本环境
1、安装GD2
cd /usr/src/src
tar -xzvf gd-2.0.35.tar.gz // 解压软件包
cd gd-2.0.35
./configure --prefix=/web/gd // 配置
make // 是用来编译的,它从 Makefile 中读取指令,然后编译。
make install //是用来安装的,它也从 Makefile 中读取指令,安装到指定的位置。

其实安装源码软件要这三步走: ./configure make make install

2,

卸载默认低版本的环境
先看看有没有安装httpd软件包
# rpm -qa | grep httpd
如果装了就卸载
# rpm -e httpd --nodeps
说明:卸载软件包, --nodeps 如果有连带关系,也强制卸载
# cd /etc/httpd
# rm -rf *

# rpm -qa | grep mysql
# rpm -qa | grep php
一样如果装了就卸载

 

安装gcc gcc-c++编译器
# yum install gcc
# yum install -y gcc gcc-c++

3、安装apache2
tar zxvf httpd-2.2.6.tar.gz
cd httpd-2.2.6
#./configure --prefix=/web/apache --with-ssl --enable-ssl --enable-so --enable-rewrite --disable-cgid --disable-cgi
make :好像apache默认状态下是需要apr和apr-uitl这两个依赖库的,CentOS6.3默认是安装好拉这些库的。[root@bogon ~]# rpm -qa |grep apr
apr-1.3.9-5.el6_2.i686
apr-util-ldap-1.3.9-3.el6_0.1.i686
apr-util-1.3.9-3.el6_0.1.i686
root@bogon ~]# rpm -qa |grep pcre
pcre-7.8-4.el6.i686

我在make的时候出现了如下问题,

所以我把 --with-sssl --enable-ssl 取消了,所以安装apache也就很顺利啦!

make install


下面教大家如何把apache设置成系统服务

将apache 设置成开机自启动:的两种方法

在/etc/rc.d/rc.local 文件中加入一行
/web/apache/bin/apachectl start
这样每次重新启动系统以后,apache 也会随系统一起启动.

或者将apache 安装为系统服务

cp /web/apache/bin/apachectl /etc/rc.d/init.d/httpd然后
vi /etc/rc.d/init.d/httpd

添加(在#!/bin/sh 下面)
chkconfig: 2345 10 90
description: Activates/Deactivates Apache Web Server

(备注:添加上面俩行必须带#号)否则会报错[root@bogon rc.d]# chkconfig --add httpd
httpd 服务不支持 chkconfig

最后,运行chkconfig 把Apache 添加到系统的启动服务组里面:
chkconfig –-add httpd
chkconfig httpd on

然后再service httpd start

[root@bogon ~]# service httpd start
httpd: Could not reliably determine the server's fully qualified domain name, using 221.192.153.44 for ServerName
httpd (pid 18670) already running
出现如上提示:输入命令 vi /web/apache/conf/httpd.conf
找到找到# ServerName www.example.com:80 把#去掉,重启apache即可

启动Apache
# /web/apache/bin/apachectl start
关闭Apache
# /web/apache/bin/apachectl stop

查看80端口是否开启
# netstat -tnl|grep 80(备注:开启apache才可以查看80端口)

[root@bogon rc.d]# netstat -tnl |grep 80
tcp        0      0 0.0.0.0:5800                0.0.0.0:*                   LISTEN     
tcp        0      0 :::5800                     :::*                        LISTEN     
tcp        0      0 :::80                       :::*                        LISTEN     


3 安装mysql5

#tar zxvf mysql-5.0.50.tar.gz
#cd mysql-5.0.50

# ./configure --prefix=/web/mysql --with-comment=Source --with-server-suffix=-enterprise-gpl --with-mysqld-user=mysql --without-debug --with-socket-path=/web/mysql/var/mysql.sock --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --without-isam --enable-local-infile --with-readline --with-raid

敲回车:如果成功会提示如下界面


MySQL has a Web site at http://www.mysql.com/ which carries details on the
latest release, upcoming features, and other information to make your
work or play with MySQL more productive. There you can also find
information about mailing lists for MySQL discussion.

Remember to check the platform specific part of the reference manual for
hints about installing MySQL on your platform. Also have a look at the
files in the Docs directory.

Thank you for choosing MySQL!

#make
#make install

很慢 等着吧
 

建立mysql用户组:
#groupadd mysql

在mysql用户组中添加mysql用户:
#useradd -g mysql mysql

进入安装目录:
#cd /web/mysql

修改属性:
#chown -R mysql .
#chgrp -R mysql .

安装基本库:
#bin/mysql_install_db --user=mysql

安装成功出现以下界面:[root@bogon mysql]# bin/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/web/mysql/bin/mysqladmin -u root password 'new-password'
/web/mysql/bin/mysqladmin -u root -h bogon password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /web/mysql ; /web/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /web/mysql/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
 

修改属性:
#chown -R root .
#chown -R mysql var

复制配置文件到系统etc下:
#cp share/mysql/my-medium.cnf /etc/my.cnf
#cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
 

 

把mysql设置成系统服务开机加载:
#chmod 755 /etc/rc.d/init.d/mysqld
#chkconfig --add mysqld
#chkconfig --level 3 mysqld on
#/etc/rc.d/init.d/mysqld start

将root密码设置成123456:
#bin/mysqladmin -u root password 123456

测试一下:
# bin/mysql -u root -p
然后输入密码,如果能够进入就说明安装好了

七、安装php
#tar zxvf php-5.2.5.tar.gz
#cd php-5.2.5
#./configure --prefix=/web/php --with-apxs2=/web/apache/bin/apxs --with-zlib-dir --with-bz2 --with-libxml-dir --with-gd=/web/gd --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-ttf --enable-mbstring --with-mysql=/web/mysql --with-config-file-path=/etc --with-iconv --disable-ipv6 --enable-static --enable-zend-multibyte --enable-inline-optimization --enable-zend-multibyte --enable-sockets --enable-soap --with-openssl --with-gettext --enable-ftp
#make的时候出错了:

make: *** [ext/openssl/openssl.lo] Error 1
解决方法是:在--with-openssl后面加上路径:如下--with-openssl=/usr/local/openssl/

#make install

复制配置文件到系统etc下:
#cp php.ini-recommended /etc/php.ini

整合apache与php
#vi /web/apache/conf/httpd.conf

找到
DocumentRoot “/web/www”
把它变成自己的服务目录
找到
AddType application/x-gzip .gz .tgz
在其下添加如下内容:
AddType application/x-httpd-php .php
查找:(设置 WEB 默认文件)
DirectoryIndex index.html
修改为:
DirectoryIndex index.php index.html index.htm

 找到这一段:
AllowOverride controls what directives may be placed in .htaccess files.
It can be “All”, “None”, or any combination of the keywords:Options FileInfo AuthConfigLimit
#AllowOverride none

更改为
AllowOverride all
允许apache rewrite
保存httpd.conf,退出。

保存退出:

确保防火墙已关闭,重新启动apache:

#service httpd restart

在apache的服务目录中新建一个文件用来测试php的情况
文件名为test.php
内容为
< ? php
phpinfo();
?>

测试一下php
# vi /web/apache/htdocs/test.php
<?php
phpinfo();
?>
通过浏览器访问http://localhost/info.php,获得php的详细配置信息

到此:我们的PHP环境已经安装成功!

安装phpMyAdmin

cd /usr/src

tar -zxvf phpMyAdmin-3.5.8-all-languages.tar.gz

cp -a phpMyAdmin-3.5.8-all-languages /web/apache/htdocs/phpmyadmin   // 复制目录到指定位置并改名为phpmyadmin

找到phpmyadmin文件夹里的config.sample.inc.php文件,重命名为config.inc.php文件。操作如下:

cd /web/apache/htdocs/phpmyadmin/

cp config.sample.inc.php config.inc.php

用vi进行编辑:vi config.inc.php

认证方法
$cfg['Servers'][$i]['auth_type'] = 'cookie';
在此有四种模式可供选择,cookie,http,HTTP,config
config方式即输入phpmyadmin的访问网址即可直接进入,无需输入用户名和密码,是不安全的,不推荐使用。
当该项设置为cookie,http或HTTP时,登录phpmyadmin需要数据用户名和密码进行验证,,具体如下:
PHP安装模式为Apache,可以使用http和cookie;
PHP安装模式为CGI,可以使用cookie

     28 /* Authentication type */
     29 $cfg['Servers'][$i]['auth_type'] = 'cookie';


     42 /* User used to manipulate with storage */

mysql主机信息
     43 // $cfg['Servers'][$i]['controlhost'] = ''; // 改成你数据库服务器的主机名或IP地址;

mysql用户名和密码
     44 // $cfg['Servers'][$i]['controluser'] = 'pma'; //改成MYSQL数据库的用户名
     45 // $cfg['Servers'][$i]['controlpass'] = 'pmapass'; // 改成MYSQL数据库的密码

以上几项改好了记得删除行开头的 // 。详细配置请看如下网址:http://www.jb51.net/article/22412.htm

主要修改这几项,修改好保存退出!重启apache:/web/apache/bin/apachectl restart
 

在浏览器输入 http://192.168.2.249/phpmyadmin,再输入用户名和密码就可以进去了!

感觉 phpmyadmin3.5.8版本没有3.5.1这个版本快!也没要这个版本好用

八、安装zend

cd /usr/src/
tar -zxvf ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz

cd ZendOptimizer-3.3.0a-linux-glibc21-i386

 

#./install.sh

接下来是图形安装界面,需要注意的是zend安装目录为:/web/zend ;php的配置文件在:/etc ,apache控制命令行位置:/web/apache/bin/apachectl

安装完成重新刷新test.php,看是否安装成功。

九、安装eaccelerator

#cd /usr/src

#tar jxvf eaccelerator-0.9.5.2.tar.bz2

#cd eaccelerator-0.9.5.2

#export PHP_PREFIX="/web/php"   //指定php安装目录

# /web/php/bin/phpize

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

#make & make install

编译安装后会看到屏幕提示的eaccelerator.so 所在的目录,"/web/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"  记住它,后面会用到。

[root@bogon eaccelerator-0.9.5.2]# make install
Installing shared extensions:     /web/php/lib/php/extensions/no-debug-non-zts-20060613/
 

安装eaccelerator加速软件为php扩展:

打开php.ini文件,在[zend]之前添加下列信息:

zend_extension="/web/php/lib/php/extensions/no-debug-non-zts-20060613/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.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"
创建/tmp/eaccelerator文件夹,并设置777权限,重新启动apache。

命令如下:mkdir -p /tmp/eaccelerator

                   chmod 777 /tmp/eaccelerator

/web/apache/bin/apachectl stop
/web/apache/bin/apachectl start
 

 

运行test.php显示的zend信息大致如下则说明安装成功。

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    with eAccelerator v0.9.5.2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator  #加速软件安装成功
    with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.3.0, Copyright (c) 1998-2007, by Zend Technologies  #zend安装成功

安装Suhosin:为加固PHP的安全性需要安装Suhosin,它是一个专门的安全小组开发的专门针对PHP进行安全加固的补丁程序:

cd/usr/src

tar -zxvf suhosin-0.9.32.1.tar.gz

cd suhosin-0.9.32.1
# /web/php/bin/phpize

# ./configure --with-php-config=/web/php/bin/php-config
#make;

#make install

[root@bogon suhosin-0.9.32.1]# make install
Installing shared extensions:     /web/php/lib/php/extensions/no-debug-non-zts-20060613/
继续修改php.ini,

vi /etc/php.ini
查找代码:extension_dir = "./"

替换为:extension_dir = "/web/php/lib/php/extensions/no-debug-non-zts-20060613/"

                extension="suhosin.so"

输入命令重启apache:/web/apache/bin/apachectl restart

再打开test.php就可以看到Suhosin的信息喽


 

到此,LAMP环境搭建完毕。

 

也可参照以下网址:http://www.61916.com/linux-1110.html

http://www.opsers.org/server/lamp-eaccelerator-zend-installation-video-tutorial-debut.html