LAMP 环境搭建

安装环境 CentOS 6.3 x_86 安装开发环境

yum groupinstall “Developement Tools”

1、安装libxml2-2.7.8.tar.gz

./configure –prefix=/usr/local/libxml2

make

make install

导出库搜索路径

vim /etc/ld.so.conf.d/libxml2.conf

/usr/local/libxml2/lib

2、安装libmcrypt-2.5.8.tar.gz

./configure –prefix=/usr/local/libmcrypt
make
make install
cd  /libmcrypt-2.5.8/libltdl
./configure –enable-ltdl-install
make
make install

导出库搜索路径

vim /etc/ld.so.conf.d/usrlocal.conf
/usr/local/lib

3、安装zlib-1.2.7.tar.gz

./configure
make
make install

安装zlib不要指定目录否则后导致freetype无法编译

4、安装libpng-1.5.9.tar

./configure –prefix=/usr/local/libpng
make
make install

5、安装jpegsrc.v7.tar.gz

mkdir /usr/local/jpeg7 #软件安装目录
mkdir /usr/local/jpeg7/bin #建立存放命令的目录
mkdir /usr/local/jpeg7/lib #创建jpeg6库文件所在目录
mkdir /usr/local/jpeg7/include #建立存放头文件目录
mkdir -p /usr/local/jpeg7/man/man1 #建立存放手册的目录
cp /usr/share/libtool/config/config.sub . 
cp /usr/share/libtool/config/config.guess .
./configure–prefix=/usr/local/jpeg6/ 
--enable-shared \ #建立共享库使用的GNU的libtool
--enable-static #建立静态库使用的GNU的libtool
make && make install

6、安装freetype

./configure –prefix=/usr/local/freetype
 make && make install

导出库搜索路径

vim /etc/ld.so.conf.d/freetype.conf
/usr/local/freetype/lib

7、安装fontconfig

./configure --prefix=/usr/local/fontconfig \
--with-freetype-config=/usr/local/freetype/bin/freetype-config --enable-libxml2

安装fontconfig提示

checking for LIBXML2… configure: error: Package requirements (libxml-2.0 >= 2.6) were not met:  No package ‘libxml-2.0′ found Consider

adjusting

the

PKG_CONFIG_PATH

environment variable if you

installed software in a non-standard prefix.

Alternatively, you may set the environment variables

设置环境变量

export PKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig

安装autoconf-2.61

CFLAGS=”-O3 -fPIC” ./configure

make

make install 

 

8、安装gd-2.0.33

Vim gd_png.c include png.h”替换成 Include /usr/local/libpng/include/png.h

./configure \
--prefix=/usr/local/gd2/ \ #指定软件安装的位置
--with-zlib=/usr \ #指定到哪去找zlib库文件的位置
--with-jpeg=/usr/local/jpeg7/ #指定到哪去找jpeg库文件的位置
--with-png=/usr/local/libpng/ #指定到哪去找png库文件的位置
--with-freetype=/usr/local/freetype/ 
--with-fontconfig=/usr/local/fontconfig #字体库的位置
make && make install

安装完成后编辑 /usr/local/gd2/inclued/gd_io.h  添加 void (*data);

 typedef struct gdIOCtx

{

  int (*getC) (struct gdIOCtx *);
    int (*getBuf) (struct gdIOCtx *, void *, int);
void (*putC) (struct gdIOCtx *, int);
int (*putBuf) (struct gdIOCtx *, const void *, int);
/* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
int (*seek) (struct gdIOCtx *, const int);
long (*tell) (struct gdIOCtx *);
void (*gd_free) (struct gdIOCtx *);
void (*data);
}

9、安装apache 服务器  

安装apr-1.4.8

./configure –prefix=/usr/local/apr

make && make install

安装apr-util-1.5.2

./configure –prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config 

make && make install

安装pcre-8.33

./configure –prefix=/usr/local/pcre

make && make install

安装httpd-2.4.4

./configure  \  prefix=/usr/local/apache2 \       #指定Apache软件安装的位置

sysconfdir=/etc/httpd  \     #指定Apache服务器的配置文件存放位置

with-z=/usr/local/zlib/ \    #指定zlib库文件的位置,如果之前编译zlib没指定这里不要加路径

with-apr=/usr/local/apr \                #使用捆绑APR/APR-Util的副本

with-apr-util=/usr/local/apr-util \

with-pcre=/usr/local/pcre \

enable-so \                          #以动态共享对象(DSO)编译

enable-deflate=shared \               #缩小传输编码的支持

enable-expires=shared \             #过期时间控制

enable-rewrite=shared \               #基于规则的URL操控

enable-static-support                #建立一个静态链接版本的支持

make && make install

10、安装ncurses-5.6

./configure –with-shared –without-debug –without-ada –enable-overwrite

make #make install  

11、安装mysql-5.1.68

./configure –prefix=/usr/local/mysql \

without-debug \

with-charset=utf8 \

with-unix-socket-path=/usr/local/mysql/sock/mysql.sock \

with-plugins=innodb_plugin \

enable-thread-safe-client \

with-big-tables \

with-ssl \

enable-assembler

make && make install

配置mysql

cp support-files/my-medium.cnf /usr/local/mysql/my.cnf

vim /usr/local/mysql/my.cnf

basedir = /usr/local/mysql

datadir = /data/mysql

mkdir /data

创建mysql数据库

/usr/local/mysql/bin/mysql_install_db –user=mysql –datadir=/data/mysql

测试启动

Nohup /usr/local/mysql/bi/mysqld_safe –defaults-file=/usr/local/mysql/my.cnf &

安装innodb存储引擎

Mysql –uroot –p install plugin innodb soname ‘ha_innodb_plugin.so'; 

12、安装php-5.4.0  

cd php-5.4.0

 vim ext/gd/libgd/gd_compat.c 
# include </usr/local/libpng/include/png.h>   #png.h使用全路径

./configure –prefix=/usr/local/php \

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

–with-apxs2=/usr/local/apache2/bin/apxs \

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

–with-libxml-dir=/usr/local/libxml2/ \

–with-png-dir=/usr/local/libpng/ \

–with-jpeg-dir=/usr/local/jpeg7/ \

–with-freetype-dir=/usr/local/freetype/ \

–with-gd=/usr/local/gd2/ \

–with-zlib-dir=/usr \

–with-mcrypt=/usr/local/libmcrypt/ \

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

–enable-soap \

–enable-mbstring=all \

–enable-sockets

配置php

# cp php.ini-dist /usr/local/php/etc/php.ini  //创建配置文件

vi /etc/httpd/httpd.conf     //使用vi编辑apache配置文件

Addtype application/x-httpd-php   .php    .phtml    #添加这一条

# vi /usr/local/apache2/htdocs/index.php         //编辑index.php文件 <?php phpinfo(); ?> 

 13、创建apache启动脚本

vim /etc/rc.d/init.d/httpd
#!/bin/bash
#chkconfig: - 85 15
#description:Apache is a World Wide Web Server
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ];then
 . /etc/sysconfig/httpd
fi
#如果该变量有值则用原来的值,如果没有则使用C
HTTPD_LANG=${HTTPD_LANG-"C"}
#
INITLOG_ARGS=""
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
start() {
 echo -n $"Starting $prog:"
 LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
 RETVAL=$?
 echo 
 [ $RETVAL = 0 ] && touch ${lockfile}
 return $RETVAL
}
stop() {
 echo -n "$Stopping $prog:"
 killproc -p ${pidfile} -d 10 $httpd
 RETVAL=$?
 echo
 [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
 echo -n $"Reloading $prog:"
 if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t &> /dev/null;then
 RETVAL=$?
 echo $"not reloading due to configuration syntax error"
 failure $"not reloading $httpd due to configuration syntax error"
 else
 killproc -p ${pidfile} $httpd -HUP
 RETVAL=$?
 fi
 echo
}
case "$1" in
 start)
 start
 ;;
 stop)
 stop
 ;;
 status)
 status -p ${pidfile} $httpd
 RETVAL=$?
 ;;
 restart)
 stop
 start
 ;;
 condrestart)
 if [ -f ${pidfile} ];then
 stop
 start
 fi
 ;;
 reload)
 reload
 ;;
 gracefull|help|configtest|fullstatus)
 $apachectl $0
 RETVAL=$?
 ;;
 *)
 echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|gracefull|help|configtest}"
 exit 1
esac

 

 

发表评论