一直用一件安装包,要么就是yum安装。以前也编译安装过Lamp.但是次数有限。这次终于狠心,决定弄搞的熟练一些。 同时也说明了一个问题,想100次不如做一次!~
====基本软件信息====
linux: CentOS release 6.5 (Final) (最小安装)
apache: 2.2.29
mysql: 5.1.51
php:5.3.22
====关闭selinux/防火墙====
关闭 SELinux : vi /etc/selinux/conf; 改成disabled
关闭防火墙: chkconfig iptables off
====编译安装安装====
#确认搭建LAMP所需要的环境是否已经安装
rpm -q make gcc gcc-c++ zlib-devel libaio
#如果没安装则yum安装 ( make 和 libaio 应该是存在的)
yum install gcc gcc-c++ zlib-devel -y
#编译安装libxml2 libxml2是一个xml的c语言版的解析器,不仅支持c语言,还支持c++、php、Pascal、Ruby、Tcl等语言的绑定
tar -zxvf libxml2-2.7.8.tar.gz
cd ./libxml2-2.7.8
./configure --prefix=/usr/local/libxml2/
make && make install
#编译安装libmcrypt
#注:libmcrypt是加密算法扩展库。支持DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+等算法。
tar -zxvf libmcrypt-2.5.8.tar.gz
cd ./libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt/
make && make install
#编译安装zlib
#注:zlib是提供数据压缩用的函式库
tar -zxvf zlib-1.2.5.tar.gz
cd ./zlib-1.2.5
./configure --prefix=/usr/local/zlib/
make && make install
#编译安装libpng
tar -zxvf libpng-1.5.4.tar.gz
cd ./libpng-1.5.4
./configure --prefix=/usr/local/libpng/ --enable-shared
make && make install
#编译安装jpeg
tar -zxvf jpegsrc.v8c.tar.gz
cd ./jpeg-8c/
mkdir /usr/local/jpeg/(创建jpeg软件的安装目录)
mkdir /usr/local/jpeg/bin/(创建存放命令的目录)
mkdir /usr/local/jpeg/lib/(创建jpeg库文件所在目录)
mkdir /usr/local/jpeg/include/(创建存放头文件目录)
mkdir -p /usr/local/jpeg/man/man1(建立存放手册的目录)
./configure --prefix=/usr/local/jpeg/ --enable-shared --enable-static(建立共享库使用的GNU的libtool和静态库使用的GNU的libtool)
make && make install
#编译安装freetype
tar -zxvf freetype-2.4.6.tar.gz
cd ./freetype-2.4.6
./configure --prefix=/usr/local/freetype/ --enable-shared
make && make install
#编译安装GD
tar -zxvf gd-2.0.35.tar.gz
cd ./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/
make && make install
#####
* png错误,修改方法:
vi gd_png.c
把 #include “png.h” 替换为 #include "/usr/local/libpng/include/png.h"
#####
###(我编译时候遇到的错误,基本百度都可以解决)
yum install libpng-devel #解决configure: error: png.h not found.
yum -y install curl-devel #checking for cURL in default path... not found configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/
yum install openssl openssl-devel #解决Cannot find OpenSSL's <evp.h>
yum install libxml2-devel -y #解决 checking libxml2 install dir... no checking for xml2-config path... configure: error: xml2-config not found. Please check your libxml2 installation.
#安装apache
tar -zxvf httpd-2.2.19.tar.gz
cd ./httpd-2.2.19
./configure --prefix=/usr/local/apache/ --enable-so --enable-rewrite
make && make install
/usr/local/apache/bin/apachectl start #启动;其他配置例如开机启动百度查吧
#若不安装ncurses编译MySQL时会报错
yum -y install ncurses*
# 安装MySQL
groupadd mysql #添加用户组mysql
useradd -g mysql mysql #将mysql用户默认组设置为mysql用户组
cd /mysql- 5.1.59
./configure --prefix=/usr/local/mysql --without-debug --enable-thread-safe-client --with-pthread --enable-assembler --enable-profiling
--with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-extra-charsets=all --with-plugins=all --with-mysqld-user=mysql --without-embedded-server
--with-server-suffix=-community --with-unix-socket-path=/tmp/mysql.sock
make && make install
#修改mysql配置文件
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
#生成MySQL配置文件
setfacl -m u:mysql:rwx -R /usr/local/mysql
setfacl -m d:u:mysql:rwx -R /usr/local/mysql
#用原本源代码的方式去使用和启动mysql
/usr/local/mysql/bin/mysqld_safe --user=mysql &
#解决mysql_config not found的问题,
ln -s /usr/local/mysql/bin/mysql_config /usr/local/bin/mysql_config
##编译安装php
tar -zxvf php-5.3.7.tar.gz
cd ./php-5.3.7
./configure --prefix=/usr/local/php --with-gd --with-apxs2=/usr/local/apache/bin/apxs --enable-mbregex --enable-bcmath --with-mysql=/usr/local/mysql --with-zlib-dir --enable-mbstring=all
--with-pdo-mysql --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/jpeg --with-openssl --with-curl