Chinaunix首页 | 论坛 | 博客
  • 博客访问: 379103
  • 博文数量: 165
  • 博客积分: 436
  • 博客等级: 下士
  • 技术积分: 887
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-10 02:49
文章分类

全部博文(165)

文章存档

2012年(95)

2011年(70)

分类:

2011-12-21 22:38:42

       任务:LinuxCentOS 5系列)编译安装 apache+php+mysql+Zend+GD+ImageMagick+eAccelerator环境。

       内容:1.需要用到的所有源码包(包括如何取消这些包)

                     2.源码包存放的位置

                     3.安装步骤

                     4.实现自动化安装

 

I.             用到的包:

apachehttpd-2.2.15.tar.gz

mysqlmysql-5.0.56.tar.gz

phpphp-5.2.13.tar.gz

eaccleratoreaccelerator-0.9.6.tar.bz2

Zend OptimizerZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

GDgd-2.0.32.tar.gz

ImageMagickImageMagick-6.5.7-10.tar.gz

扩展包和依赖包:

phplibiconv-1.13.tar.gz

              libmcrypt-2.5.8.tar.gz

              mhash-0.9.9.9.tar.gz

              mcrypt-2.6.8.tar.gz

ImagMagickMagickWandForPHP-1.0.8.tar.gz

II.          下载源码包。

为方便管理,下载的所有包都放在 /usr/src/source_package 目录下

wget

wget -c httpd-2.2.15.tar.gz

wget

wget mysql-5.0.56.tar.gz

wget

wget http://blog.s235.com/soft/linux/nginx_php/libiconv/libiconv-1.13.tar.gz

wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.tar.gz

wget http://blog.s235.com/soft/linux/nginx_php/mycrypt/libmccrypt-2.5.8.tar.gz

wget libmcrypt-2.5.8.tar.gz wget

wget http://blog.s235.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz

wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz

wget http://blog.s235.com/soft/linux/nginx_phpmcrypt/mcrypt-2.6.8.tar.gz

wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz

wget

wget

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

Wget

wget

wget

wget ftp://ftp.fifi.org/pub/ImageMagick/ImageMagick-6.6.0-10.tar.gz

wget

wget php/MagickWandForPHP-1.0.8.tar.gz

III.       准备工作

安装和更新软件所依赖的库文件

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openlab openlab-devel nss_ldap openlab_client openlab_servers

这样,CentOS系统自带的yum程序就会自动的从配置文件里的软件源下载更新需要下载和更新的源码包,包括因为依赖关系而需要下载或更新的包,并实现自动安装和更新。

 

Linux系统通常自带默认安装有一些重要常用的软件,如apachemysqlphp,几乎都是默认安装好的。如果想要自己编译安装其他版本的这些软件,就需要先把系统默认的软件卸载干净。

利用 rpm –qa|grep package_name 命令可以查看系统是否已经默认安装好想要安装的软件,如果有,则利用 rpm –e package_name 命令卸载该软件。如果碰到因为依赖关系而不能成功卸载的情况,则利用 rpm –e –nodeps package_name 强制卸载。

       必须保证把所有已安装的rpm包卸载干净,不妨利用 rpm –qa|grep package_name 多查几次。

 

 

IV.       编译安装

准备工作做好后,接下来就可以正式开始编译安装需要安装的软件。为方便管理,把软件都安装在 /usr/local 路径下。

1.      apache

# cd /usr/src/source_package

# tar –zxvf httpd-2.2.15.tar.gz

# cd httpd-2.2.15

# ./configure --prefix=/usr/local/httpd -enable-so 

 

 

./configure --prefix=/usr/local/httpd -enable-so -enable-module=info --enable-shared=info

编译前先make clean一下,删除之前编译生成的残留文件:

# make clean

# make

# make install

这样就能成功安装apache

修改配置文件:

# ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf

vi /usr/local/apache2/conf/httpd.conf

apache加入服务并实现自启动:

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

# chmod +x /etc/init.d/httpd

# vi /etc/init.d/httpd

#!/bin/bash下面添加两行:

#chakconfig:35 70 30

#description:apache

保存退出,apache服务的环境变量算是设置完了。接下来就可以启动apache服务。

# service httpd start

可能出现的问题: 

a.         重启apache的时候出错,系统提示“端口已被占用”,出现这种情况很可能是以前编译安装的apache没有卸干净,还有没有正确修改配置文件所致。

b.        apache能正常启动,但没有了提示信息。

找到#ServerName #去掉,再重启apache即可没事了。(解决httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0

 

2.      mysql 转到

# cd /usr/src/source_package

# tar –zxvf mysql-5.0.56.tar.gz

mysql添加管理组和成员:

# groupadd mysql

# useradd –g mysql mysql

建立mysql安装目录和数据储存目录:

# mkdir /usr/local/mysql

# mkdir /usr/local/mysql/data

开始安装:

# ./configure --prefix=/usr/local/mysql \

#>--sysconfdir=/etc \

#>--enable-assembler \

#>--with-charset=utf8 \

#>--with-extra-charsets=all \

#>--localstatedir=/usr/local/mysql/data

#make clean

#make

#make install

安装完成后,初始化数据库:

# /usr/local/mysql/bin/mysql_install_db --user=mysql

启动mysql服务器:

# /usr/local/mysql/bin/mysqld_safe --user=mysql

mysql加入服务:

# ln -s /usr/src/mysql-5.0.56/support-files/my-medium.cnf /etc/my.cnf

# ln -s /usr/src/mysql-5.0.56/support-files/mysql.server /etc/init.d/mysqld

# chmod +x /etc/init.d/mysqld

# /sbin/chkconfig --add mysqld

启动mysql服务:

# service mysqld start

可能出现的问题:

a.         mysqld_safe不能正常启动。通常是权限设置问题。mysqld_safe默认以mysql用户登录,可以尝试mysqld_safe --user=root 启动。

b.        启动mysql服务时出错,系统提示:no such process。通常是mysqld_safe没有正常启动导致。

c.         启动mysql服务时出错,系统提示:cannot connect to local MySQL server through socket ‘tmp/mysql.cache’。这种情况通常是数据存储路径没设置对所致。要不就是 ./configure 时没有指明数据存储路径:--localstatedir=/usr/local/mysql/data,要不就是没有执行ln -s /usr/src/mysql-5.0.56/supportfiles/my-medium.cnf /etc/my.cnf 命令,使得系统依然从默认的mysql数据存储路径 /tmp/mysql.cache 连接数据库。如果是后一种情况,执行以下命令就可以了。如果是后一种情况,可以执行ln -ef /usr/local/mysql/data /tmp/mysql.cache命令。

3.      php (先安装GD库)

编译安装php所需的支持库:

libiconv:

# tar -zxvf libiconv-1.13.tar.gz

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

# make clean

# make

# make install

libmcrypt:

# tar -zxvf libmcrypt-2.5.8.tar.gz

# ./configure

# make clean

# make

# make install

# /sbin/ldconfig

# cd libltdl

# ./configure --enable-ltdl-install

# make clean

# make

# make install

mhash:

# tar -zxvf mhash-0.9.9.9.tar.gz

# ./configure

# make clean

# make

# make install

# ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

# ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
# ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
# ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
# ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
# ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
# ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
#
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
# ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
# ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

mcrypt:

# tar -zxvf mcrypt-2.6.8.tar.gz

# /sbin/ldconfig

# ./configure

# make clean

# make

#make install

 

正式安装php(先安装GD)

# tar -zxvf php-5.2.13.tar.gz

# ./configure --prefix=/usr/local/php \

  --with-apxs2=/usr/local/httpd/bin/apxs \  (非常重要,否则不能与apache相连,解析不了php)

--with-gd \

--with-config-file-path=/usr/local/php/etc \

--with-mysql=/usr/local/mysql \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

--with-iconv-dir=/usr/local \

--with-freetype-dir --with-jpeg-dir --with-png-dir \

--with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath \

--enable-discard-path --enable-safe-mode --enable-bcmath \

--enable-shmop --enable-sysvsem --enable-inline-optimization \

--with-curl --with-curlwrappers --enable-mbregex \

--enable-fastcgi  --enable-force-cgi-redirect \

--enable-mbstring --with-mcrypt  --enable-gd-native-ttf \

--with-openssl --with-mhash --enable-pcntl --enable-sockets \

--with-xmlrpc --enable-zip --enable-soap

# make ZEND_EXTRA_LIBS='-liconv'

# make install

 

(#cp /usr/lib64/mysql/* /usr/lib/mysql/

 

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-gd --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/lib64/mysql --with-mysqli=/usr/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-dafe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gld --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap

 

64位系统)

 

cp php.ini-dist /usr/local/php/etc/php.ini

 

 

4.      eAccelerator

建立缓存目录:

# mkdir /tmp/eaccelerator

#chmod 0777 /tmp/eaccelerator

编译安装

# cd /usr/src/source_package

# tar –jxvf eaccelerator-0.9.6.tar.bz2

# cd eaccelerator-0.9.6

# /usr/local/php/bin/phpize

(# export  LC_ALL=en_US

# export LANGUAGE=en_US) 解决perl  warning locate问题

 

# ./configure --with-php-config=/usr/local/php/bin/php-config \

#>--enable-eaccelerator=shared

# make

# make install

#ln -s /usr/local/php/bin/php /usr/bin/php

/usr/local/php/etc/php.ini修改添加以下信息:

# vi /usr/local/php/etc/php.ini

找到:

extension_dir=”./”

修改成:

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

在文件末尾添加以下信息:

[eaccelerator]   注意以下的“”引号格式)

 

zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"

eaccelerator.shm_size="64"

eaccelerator.cache_dir="/tmp/eaccelerator"

eaccelerator.enable="1"

eaccelerator.optimizer="1"

eaccelerator.debug="0"

eaccelerator.filter=""

eaccelerator.shm_max="3600"

eaccelerator.shm_ttl="3600"

eaccelerator.shm_prune_period="3600"

eaccelerator.shm_only="0"

eaccelerator.compress="1"

eaccelerator.compress_level="9" (改了引号)

 

zend_extension=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so”

eaccelerator.shm_size=”64”

eaccelerator.cache_dir=”/tmp/eaccelerator”

eaccelerator.enable=”1”

eaccelerator.optimizer=”1”

eaccelerator.debug=”0”

eaccelerator.filter=””

eaccelerator.shm_max=”3600”

eaccelerator.shm_ttl=”3600”

eaccelerator.shm_prune_period=”3600”

eaccelerator.shm_only=”0”

eaccelerator.compress=”1”

eaccelerator.compress_level=”9”

保存退出。

重启服务:

chcon -t texrel_shlib_t /usr/local/httpd/modules(权限)

chcon -t texrel_shlib_t /usr/local/httpd/modules/libphp5.so

 

service httpd restart

验证安装是否正确:

# php -v

若显示:

with eaccelerator v0.9.6

则表示安装成功。

可能遇到的问题:

a.         找不到路径。可能是系统自带的phpeaccelerator没有成功卸载。

b.        php -v时系统提示:

eaccelerator requires Zend Engine API version 22060519

The Zend Engine API version 220051025 whitch is installed,is outdateed(newer)

php的版本太旧(或太新),把版本匹配好就行。

c.         php -v时系统提示:

Zend optimizer is incompatiple with eaccelerator

把扩展信息加入到php.ini的时候把Zend Optimizer的信息写在eaccelerator之前。应该把两者换个位置。

5.      Zend Optimizer   (64位系统要安装64位的)

# cd /usr/src/source_package

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

#./install.sh

进入安装界面。

选择安装路径:/usr/local/Zend

php.ini放置的路径: /usr/local/php/etc

是否使用apache服务器:y

填写apachectl的完整路径:/usr/local/httpd/bin/apachectl

完成安装后对/usr/local/php/etc/php.ini进行修改:

# vi /usr/local/php/etc/php.ini

在文件末尾添加以下内容:(已经有了)

[Zend]

zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3

zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3

zend_optimizer.version=3.3.3

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

zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so

保存退出。

#chcon -t texrel_shlib_t /usr/local/Zend/lib/Optimizer-3.3.3/php-5.2.x/ZendOptimizer.so

验证安装是否成功:

# php -v

如果显示:

with Zend Optimizer v3.3.3

则表示安装成功。

6.      GD

# tar -zxvf gd-2.0.32.tar.gz

# cd gd-2.0.32

# ./configure --with-png --with-freetype --with-jpeg

GD默认不支持jpeg,需要修改Makefile(这个已支持)

# vi Makefile

把以下内容:

CFLAGS=-g -O2

LIBS=-lz -lm

修改为:

CFLAGS=-O -DHAVE_XPM -DHAVE_JPEG -DHAVE_LIBTTF

LIBS=-lm -lgd -lpng -lz -ljpeg -lttf -lXpm -lX11(用默认就得)

-ljpeg -lfreetype -lpng12 -lz -lm

但对于没有xwindow的系统来说,应该修改为:

CFALGS=-O -DFAVE_LIBPNG -DHAVE_LIBJPEG

LIBS=-lgd -lpng -lz -lm -ljpeg

保存退出。

# make

# make install

7.      ImageMagick

# tar -zxvf ImageMagick-6.5.7-10.tar.gz

# cd ImagMagick-6.5.7-10

# ./configure --enable-lzw --with-modules \

#>--enable-shared --enable-static

# make

# make install

ImageMagick加入到php模块:

安装MagickWand

# cd /usr/src/source_package

# tar -zxvf MagickWandForPHP-1.0.8.tar.gz

# cd MagickWandForPHP-1.0.8

# /usr/local/php/bin/phpize

# ./configure --prefix=/usr/local/magicwand \

#>--enable-shared --with-php-config=/usr/local/php/bin/php-config \

#>--with-magickwand=usr/local/imagemagick

# make

# make install

把信息加入到/usr/local/php/etc/php.ini

# vi /usr/local/php/etc/php.ini

添加以下内容:

extension=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/magickwand.so”

(改成这个)extension=” magickwand.so”

 

保存退出。

重启apache服务。

 

 

 

########################################3

重启计算机时 开机启动

iptables -F

chcon -t texrel_shlib_t /usr/local/httpd/modules(权限)

chcon -t texrel_shlib_t /usr/local/httpd/modules/libphp5.so

service httpd start

service mysqld start

 

在目录(/usr/local/httpd/conf/httpd.conf /etc/httpd.cnf)或??试试

vi /usr/local/apache2/conf/httpd.conf 里的

    Options FollowSymLinks

    AllowOverride None

    Order deny,allow

   Allow from all  #(加上的)  !!!字符

#Deny from all

 

页面默认在:

 

 

当有

[root@localhost htdocs]# service httpd start

(98)Address already in use: make_sock: could not bind to address [::]:80

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

no listening sockets available, shutting down

Unable to open logs

解决:

killall -9 httpd

service httpd start

 

要修改/usr/local/httpd/htdocs/index.html内容

  则要先service httpd stop

service httpd start 才能生效。

 

参考网址:

 

 

安装phpmyadmin

 

#wget
  当然也可到你自己的windows机器,等以后编辑好了再上传到web服务器上
  B.将此档解压缩
  # tar zxvf phpMyAdmin-2.11.3-all-languages.tar.gz
  此时路径 / usr/local/httpd/htdocs /phpMyAdmin-2.11.3-all-languages
  C. 修改目录名为 / usr/local/httpd/htdocs/mysql
  # mv /phpMyAdmin-2.11.3-all-languages / usr/local/httpd/htdocs/mysql
  D.修改设定档
  1.找到 /libraries/config.default.php文件(config.default.php复制到phpmyadmin目录下,然后更名为config.inc.php),该文件有如下项目(2-8)须自行配置,windows用写字板(不要用记事本,这是UTF8编码)进行编辑,linux下直接用vim编辑.
  2.查找 $cfg['PmaAbsoluteUri'] 修改为你将上传到空间的phpMyAdmin的网址
  如:$cfg['PmaAbsoluteUri'] = '';
  3.查找 $cfg['Servers'][$i]['host'] = 'localhost';(通常用默认,也有例外,可以不用修改)
  4.查找 $cfg['Servers'][$i]['auth_type'] = 'config';
  在自己的机子里调试用config;如果在网络上的空间用cookie,这里我们既然在前面已经添加了网址,就修改成cookie ,这里建议使用cookie. (本人用http,这个好,少很多登录上的问题)
  5.查找 $cfg['Servers'][$i]['user'] = 'root'; // MySQL usermysql用户名,自己机里用root;)
  6.查找 $cfg['Servers'][$i]['password'] = ''; // MySQL password (mysql用户的密码,自己的服务器一般都是mysql用户root的密码)
  7.查找 $cfg['Servers'][$i]['only_db'] = ''; // If set to a db-name, only(你只有一个数据就设置一下;如果你在本机或想架设服务器,那么建议留空)
  8.查找 $cfg['DefaultLang'] = 'zh'; (这里是选择语言,zh代表简体中文的意思,这里不知道填gbk对否)
  9.设置完毕后保存
  如果出现配置文件现在需要绝密的短语密码(blowfish_secret)”那么请在$cfg['blowfish_secret'] = ' ';的等号里面设置你网站的cookie,例如:$cfg['blowfish_secret'] = '任意字符';这是因为你的“$cfg['Servers'][$i]['auth_type'] = 'cookie'的原因。
  E.测试
  开启浏览器,

grant all privileges on *.* to rabbit@127.0.0.1 identified by 'rabbit'; 

(rabbit,rabbit登录  注意清除浏览器缓存)

nginx配置

       location /phpmyadmin/ {

          root     html;

          index    index.php index.html index.htm;

 

 

 

Apache 解析php

vi /usr/local/httpd/conf/httpd.conf

找到:

   DirectoryIndex index.html

将该行改为
<IfModule dir_module>
      
DirectoryIndex index.html index.htm index.php

 

最后加上

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

阅读(1319) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~