系统环境:Centos6.0 x64
1.确认是否已经安装了构建LAMP所需的环境。
[root@centos6 ~]# rpm -q make gcc gcc-c++zlib-devellibaio
注意:安装libpng时需要zlib-devel。
安装mysql时需要Libaio。
2.如果没有安装,百胜会安装。
[root@centos6 ~]# yum install make gcc gcc-c++zlib-devel libaio -y
3.由于需要编译安装,所以要检查httpd、mysql、php是否安装,如果安装了就卸载。
[root@centos6 ~]# rpm -q httpd mysql php
4.编译并安装libxml2。
注意:libxml2是xml的C语言解析器,不仅支持C语言,还支持C、php、Pascal、Ruby、Tcl等语言的绑定。
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf libxml2-2.7.8.tar.gz
[root@centos6 LAMP]# cd ./libxml2-2.7.8
[root@centos6 libxml2-2.7.8]# ./configure --prefix=/usr/local/libxml2/
[root@centos6 libxml2-2.7.8]# make;make install
5.编译并安装libmcrypt
注意:libmcrypt是加密算法的扩展库。
支持DES,3DES,RIJNDAEL,Twofish,IDEA,GOST,CAST-256,ARCFOUR,SERPENT,SAFER等待算法.
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf libmcrypt-2.5.8.tar.gz
[root@centos6 LAMP]# cd ./libmcrypt-2.5.8
[root@centos6 libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt/
[root@centos6 libmcrypt-2.5.8]# make;make install
6.编译并安装zlib
注意:zlib是一个用于数据压缩的函数库。
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf zlib-1.2.5.tar.gz
[root@centos6 LAMP]# cd ./zlib-1.2.5
[root@centos6 zlib-1.2.5]# ./configure --prefix=/usr/local/zlib/
[root@centos6 zlib-1.2.5]# make ; make install
7.编译并安装libpng
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf libpng-1.5.4.tar.gz
[root@centos6 LAMP]# cd ./libpng-1.5.4
[root@centos6 libpng-1.5.4]#
./configure --prefix=/usr/local/libpng/--enable-shared
[root@centos6 libpng-1.5.4]# make ; make install
8.编译并安装jpeg
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf jpegsrc.v8c.tar.gz
[root@centos6 LAMP]# cd ./jpeg-8c/
[root @ centos6jpeg-8c] # mkdir/usr/local/JPEG/(create the installation directory of Joint Photographic Experts Group software)
[root @ centos 6 JPEG-8c]# mkdir/usr/local/JPEG/bin/(创建存放命令的目录)
[root @ centos6jpeg-8c] # mkdir/usr/local/JPEG/lib/(the directory where the joint photographic expert group library file is created)
[root @ centos 6 JPEG-8c]# mkdir/usr/local/JPEG/include/(创建存放头文件目录)
[root @ centos 6 JPEG-8c]# mkdir-p/usr/local/JPEG/man/man 1(建立存放手册的目录)
[root@centos6 jpeg-8c]#。/configure-prefix=/usr/local/JPEG/-enable-shared-enable-static(建立共享库使用的角马的libtool和静态库使用的角马的libtool)
[root@centos6 jpeg-8c]# make ; make install
9.编译并安装freetype
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf freetype-2.4.6.tar.gz
[root@centos6 LAMP]# cd ./freetype-2.4.6
[root@centos6 freetype-2.4.6]#
./configure --prefix=/usr/local/freetype/--enable-shared
[root@centos6 freetype-2.4.6]# make ;make install
10.编译并安装autoconf
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf autoconf-2.68.tar.gz
[root@centos6 LAMP]# cd ./autoconf-2.68
[root@centos6 autoconf-2.68]# ./configure
[root@centos6 autoconf-2.68]# make ; make install
11.编译并安装GD
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf gd-2.0.35.tar.gz
[root@centos6 LAMP]# cd ./gd-2.0.35
[root@centos6 gd-2.0.35]#
./configure --prefix=/usr/local/gd/--with-zlib=/usr/local/zlib/--with-jpeg=/usr/local/jpeg/--with-png=/usr/local/libpng/--with-freetype=/usr/local/freetype/
[root@centos6 gd-2.0.35]# make ; make install
12. Install street hooligans
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf httpd-2.2.19.tar.gz
[root@centos6 LAMP]# cd ./httpd-2.2.19
[root@centos6 httpd-2.2.19]#
./configure --prefix=/usr/local/apache/--enable-so --enable-rewrite
[root@centos6 httpd-2.2.19]# make ; make install
[root@centos6 LAMP]# /usr/local/apache/bin/apachectl start
[root@centos6 LAMP]#
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[root@centos6 LAMP]# chmod +x /etc/init.d/httpd
[root@centos6 ~]# chkconfig --add httpd
Note: If you are prompted that servicehttpddoes does not support chkconfig errors.
解决方法:编辑/etc/rc.d/init.d/httpd,添加到文件的第二行。
#chkconfig:234510 90
#description:Activates/Deactivates Apache Web Server
[root@centos6 ~]# chkconfig --level 2345 httpd on
[root@centos6 LAMP]# service httpd restart
引导时自动启动apache的另一种方法;
# vim /etc/rc.local
在文件中添加/usr/local/Apache/bin/Apache CTL start
13.编译并安装mysql
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf mysql-5.5.15-linux2.6-x86_64.tar.gz
[root@centos6 LAMP]# cd ./mysql-5.5.15-linux2.6-x86_64
[root@centos6 mysql-5.5.15-linux2.6-x86_64]# groupadd mysql
[root @ centos6mysql-5.5.15-Linux 2.6-x86 _ 64] # useradd-r-g MySQL (create a relational database user and assign the user to a relational database group)
[root@centos6 mysql-5.5.15-linux2.6-x86_64]# cd /usr/local/
[root@centos6 local]# ln -s /tmp/LAMP/mysql-5.5.15-linux2.6-x86_64 mysql
[root@centos6 local]# cd ./mysql/
[root @ centos 6 MySQL]# chown-rmy SQL。(将该目录的所有用户权限更改为mysql用户)
[root @ centos 6 MySQL]# chgrp-rmy SQL。(将此目录中的所有用户组更改为mysql用户组)
[root@centos6 mysql]#。 /scripts/mysql _ install _ DB-user=MySQL (specify the database usage right of relational database directory as MySQL).
[root@centos6 mysql]# chown -R root .
[root@centos6 mysql]# chown -R mysql data
[root@centos6 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@centos6 mysql]# chmod +x /etc/init.d/mysqld
[root@centos6 mysql]# chkconfig --add mysqld
[root@centos6 mysql]# chkconfig --level 345 mysqld on
[root@centos6 mysql]# servicemysqld restart
[root@centos6 mysql]#
/usr/local/MySQL/bin/mysqladmin-uroot password' 123456' (set the password for root user to log in to relational database).
[root @ centos 6 MySQL]#/usr/local/MySQL/bin/MySQL-u rootp(进入并访问关系型数据库数据)
Enter password:
Welcome to the MySQL monitor.Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.5.15-log MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
Mysql(成功登录mysql)
14.编译并安装php
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]#