Chinaunix首页 | 论坛 | 博客
  • 博客访问: 225933
  • 博文数量: 57
  • 博客积分: 955
  • 博客等级: 准尉
  • 技术积分: 587
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-14 13:30
文章分类

全部博文(57)

文章存档

2012年(2)

2011年(55)

分类: LINUX

2011-05-17 20:52:18

这个应该是比较经典应用最多的一个架构了,
先解释下这个名词吧----L--linux, A-apache,---M--mysql,--p--php或者perl或者python都行,今天笔者要说的是
php这个东东。

可能有些班门弄斧,呵呵,毕竟这个貌似没有人不会配的,不过还是想拿出来说一下,顺便想问一些问题,
rpm包安装的话
配置好本地Yum源,然后直接
yum install httpd mysql-server mysql php php-mysql -y;
一个命令就装完了,
不过这个不是今天的重点,接下来主要说的是源码编译安装的
首先准备好所有需要的包
上边是我的源码目录下的所有包,肯定还有多余的,不过不用管这个,----
接下来我们用到哪个说哪个就行了
然后 既然是编译首先要判断你的系统有没有装gcc工具,一般都是默认安装的
yum install gcc gcc-c++ -y
OK,接下来开始
一  apache的编译安装
 tar jxvf httpd-2.2.11.tar.bz2
 cd httpd-2.2.11
编译参数: ./configure --prefix=/usr/local/apache  --enable-so --enable-mods-shared=most --disable-userdir --with-mpm=prefork
具体大家要根据自己的实际需求来定制安装,
然后执行make && make install就OK
最后我们为了启动服务的方便需要自己再制作一个启动服务的脚本
如果默认的是在/usr/local/apache/bin/apachect1 -k start | stop | restart
我们自己在/etc/init.d/下写一个脚本如下
#!/bin/bash
#written by booduklee
#2011-05-12 
#this program is used to manager apache daemon
APACHE=/usr/local/apache/bin/apachectl
function start {
     $APACHE  -k start && echo "start ok" || echo "start error"
}
function stop {
     $APACHE -k stop && echo "stop ok-" || echo "stop error" 
}
function restart {
       $APACHE -k restart && echo " restart ok" || echo "restart error"
}
case $1 in
start)
    start
    ;;
stop)
    stop
     ;;
restart)
      restart
      ;;
*)
         echo "usage: start | stop | restart"
         ;;
esac

然后启动apache即可/etc/init.d/apache start
二 mysql编译安装(注意这个必须按照顺序来装,apache然后是mysql,然后才是php,次序不能乱php必须最后装)
tar zxvf mysql-5.5.3-m3
cd mysql-5.5.3-m3
  ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-embedded-server --enable-local-infile --with-plugins=innodbase --enable-static --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static
make && make install;
groupadd mysql;
useradd -g mysql mysql;
chown mysql.mysql /usr/local/mysql
修改库文件 /etc/ld.so.conf
在里边追加一行 
cat >> /etc/ld.so.conf << EOF
/usr/local/mysql/lib/mysql
EOF
ldconfig -v | grep mysql
正确的回显如下
然后copy主配置文件到/etc下
 cp /usr/local/src/mysql-5.5.3-m3/support-files/my-huge.cnf.sh  /etc/my.cnf
修改My.cnf
在[mysqld]下边追加一行
datadir = /usr/local/mysql/data
注释掉这一行 thread_concurrency = 8
mkdir  -pv /usr/local/mysql/data
chown mysql.mysql /usr/local/mysql/data
同样要设置启动脚本,这个有现成的,cp一下就行了
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/
做软连接
然后是个扫尾工作,去除一些不必要的东西
 /usr/local/mysql/bin/mysql_secure_installation
根据里边的提示设置root密码,删除test数据库,禁止远程登录等之类的设置
三 php编译安装
在开始php编译安装之前,首先需要先编译一些其他的包
第一个是libiconv,-----
编译参数 ./configure --prefix=/usr/local/   ;  make && make install
第二个是libmcrypt
编译参数  ./configure ; make && make install
然后输入Ldconfig,使新安装的函数库生效
cd libmcrypt-2.5.8/libtdl/
./configure --enable-ltdl-install
make && make install
第三个包 Mhash
./configure ; make && make install
ln -s /usr/local/lib/* /usr/lib/
第四个包 mcrypt
同样的编译安装,记得输入ldconfig来生效
最后在编译Php之前需要确认以下包已经装上
yum install libmxl2-devel curl-devel libpng-devel freetype-devel libjpeg-devel -y

--------------------PHP编译安装-------------------------------------------
tar zxvf php-5.2.14.tar.gz 
cd php-5.2.14
 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/local/apache/bin/apxs --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-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf 

make ZEND_EXTRA_LIBS='-liconv'

make install
----------------这个编译参数很多眼花缭乱的---------------------

 libtool --finish /usr/local/src/php-5.2.14/libs
cp /usr/local/src/php-5.2.14/php.ini-dist /usr/local/php/etc/php.ini 
在apache配置文件里边查看是否加载了Libphp5.so这个模块
然后在默认主页后边追加index.php
查找ADDtype
AddType application/x-httpd-php .php
如果要加载新的函数库的话

---------------至此安装完成,编译时间较长,推荐rpm安装,但是如果有特别需求的话就需要编译安装了

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