Centos系统下载大全 | Redhat系统下载大全 | Windows2012系统下载大全 | Windows2008系统下载大全| CMS教程 | 网站地图 51运维网-专注Linux/Unix系统安全运维!
当前位置:51运维网 > 架构 > Linux架构 > 正文

最佳LAMP环境搭建

时间:2013-09-18 10:07 来源:未知 作者:51ou.com 阅读:
一.软件包&下载地址[来自兄弟连PPT]

1.httpd 下载地址:

http://www.apache.org/

2.mysql 下载地址:

http://dev.mysql.com/downloads/

3.php 下载地址:

http://www.php.net/downloads.php

4.phpmyadmin 下载地址:

http://www.phpmyadmin.com/

5.libxml 下载地址:ftp://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/libxml2-2.6.30.tar.gz

6.libmcrypt 下载地址:

http://prdownloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?use_mirror=peterhost

7.zlib 下载地址:

http://www.zlib.net/zlib-1.2.3.tar.gz

8.gd 下载地址:

http://www.libgd.org/releases/gd-2.0.35.tar.gz

9.Autoconf 下载地址:

ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.gz

10.Freetype 下载地址:

http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz

11. libpng 下载地址:

ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.31.tar.gz

12.Jpegsrc 下载地址:

http://www.ijg.org/files/jpegsrc.v6b.tar.gz

13.ZendOptimizer下载地址:

http://wt1.mycodes.net/soft/20071108/ZendOptimizer330a.tar.gz

二.软件包安装

1.卸载系统自带的软件包:

2.软件包安装顺序:

Apache->mysql->php

安装php需要安装的库文件

libxml2、libmcrypt、zlib、libpng、freetype、jpegsrc、gd2(支持gif、png、jpeg图片格式)

3.配置yum源

4.关闭selinux及iptables

三.安装部署

①安装库及依赖包

(1.)安装libxml2:

1
2
3
4
[root@lamp ~]# tar -xjvf libxml2-2.6.23.tar.bz2
[root@lamp ~]# cd libxml2-2.6.23
[root@lamp libxml2-2.6.23]# ./configure--prefix=/usr/local/libxml2
[root@lamp libxml2-2.6.23]# make &&make install

(2.)安装libmcrypt

1
2
3
4
[root@lamp ~]# tar -xzvflibmcrypt-2.5.7.tar.gz
[root@lamp ~]# cd libmcrypt-2.5.7
[root@lamp libmcrypt-2.5.7]# ./configure--prefix=/usr/local/libmcrypt
[root@lamp libmcrypt-2.5.7]# make &&make install

(3.) 安装zlib库

1
2
[root@lamp ~]# tar -xjvf zlib-1.2.3.tar.bz2
[root@lamp ~]# cd zlib-1.2.3

vi Makefile

找到 CFLAGS=-O3 -DUSE_MMAP

在后面加入-fPIC,即变成CFLAGS=-O3-DUSE_MMAP -fPIC

1
2
[root@lamp zlib-1.2.3]# ./configure--prefix=/usr/local/zlib
[root@lamp zlib-1.2.3]# make && makeinstall

(4.)安装libpng库

1
2
3
4
[root@lamp ~]# tar -xzvf libpng-1.0.60.tar.gz
[root@lamp ~]# cd libpng-1.0.60
[root@lamp libpng-1.0.60]# ./configure--prefix=/usr/local/libpng
[root@lamp libpng-1.0.60]# make &&make install

(5.) 安装jpeg8库

1
2
3
4
5
[root@lamp ~]# tar -xzvf jpegsrc.v8.tar.gz
[root@lamp ~]# cd jpeg-8/
[root@lamp jpeg-8]# mkdir -p/usr/local/jpeg8/{bin,lib,include,man/man1}
[root@lamp jpeg-8]# ./configure--prefix=/usr/local/jpeg8/ --enable-shared --enable-static
[root@lamp jpeg-8]# make && makeinstall

(6.) 安装freetype库

1
2
3
4
[root@lamp ~]# tar -xjvffreetype-2.3.9.tar.bz2
[root@lamp ~]# cd freetype-2.3.9
[root@lamp freetype-2.3.9]# ./configure--prefix=/usr/local/freetype
[root@lamp freetype-2.3.9]# make &&make install

(7.) 安装autoconf库

1
2
3
4
[root@lamp ~]# tar -xzvf autoconf-2.13.tar.gz
[root@lamp ~]# cd autoconf-2.13
[root@lamp autoconf-2.13]# ./configure
[root@lamp autoconf-2.13]# make &&make install

(8.) 安装GD库

1
2
3
[root@lamp ~]# tar -xzvf gd-2.0.32.tar.gz
[root@lamp gd-2.0.32]# ./configure--prefix=/usr/local/gd2/ --with-zlib=/usr/local/zlib/--with-jpeg=/usr/local/jpeg8/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/
[root@lamp ~]# make && make install

②安装APACHE

(1.)安装apr

1
2
3
[root@lamp~]# tar -xjvf apr-1.4.6.tar.bz2
root@lampapr-1.4.6]# ./configure --prefix=/usr/local/apr
[root@lampapr-1.4.6]# make && make install

(2.)安装apr-util

1
2
3
4
[root@lamp ~]#tar -xjvf apr-util-1.4.1.tar.bz2
[root@lamp~]# cd apr-util-1.4.1
[root@lampapr-util-1.4.1]# ./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr
[root@lampapr-util-1.4.1]# make && make install

(3.)安装pcre

1
2
3
4
[root@lamp~]# tar -xjvf pcre-7.9.tar.bz2
[root@lamp~]# cd pcre-7.9
[root@lamppcre-7.9]# ./configure --prefix=/usr/local/pcre
[root@lamppcre-7.9]# make && make install

(4.)安装apahce

1
2
3
4
5
6
[root@lamp~]# tar -xzvf httpd-2.4.3.tar.gz
[root@lamp~]# mv apr-1.4.6 httpd-2.4.3/srclib/apr
[root@lamp~]# mv apr-util-1.4.1 httpd-2.4.3/srclib/apr-util
[root@lamp~]# cd httpd-2.4.3
[root@lamphttpd-2.4.3]# [root@lamp httpd-2.4.3]# ./configure --prefix=/usr/local/apache2--sysconfdir=/etc/httpd --with-z=/usr/local/zlib/ --with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre--with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared--enable-rewrite=shared --enable-static-support --with-mpm=prefork
[root@lamphttpd-2.4.3]# make && make install

启动apache服务器:

1
[root@lamp~]# /usr/local/apache2/bin/apachectl start

测试访问:

1
[root@lamp~]# elinks http://127.0.0.1

增加开机启动:

1
[root@lamp~]# echo "/usr/local/apache2/bin/apachectl start" >>/etc/rc.d/rc.local

③安装Mysql

添加mysql用户组

1
[root@lamp~]# groupadd mysql

添加mysql用户

1
[root@lamp~]# useradd -g mysql mysql

编译安装mysql

1
2
3
4
[root@lamp~]# tar -xzvf mysql-5.0.56.tar.gz
[root@lamp~]# cd mysql-5.0.56
[root@lampmysql-5.0.56]# ./configure --prefix=/usr/local/mysql \
>--with-extra-charsets=all

创建Mysql数据库的配置文件

1
[root@lampmysql-5.0.56]# cp support-files/my-medium.cnf /etc/my.cnf

创建授权表

1
[root@lampmysql-5.0.56]# /usr/local/mysql/bin/mysql_install_db --user=mysql

将Mysql所有文件属主改为root

1
[root@lampmysql-5.0.56]# chown -R root /usr/local/mysql/

将数据目录的属主改为mysql用户

1
[root@lampmysql-5.0.56]# chown -R mysql /usr/local/mysql/var/

将mysql属组更改为:mysql组

1
[root@lampmysql-5.0.56]# chgrp -R mysql /usr/local/mysql

启动mysql数据库:

[root@lampmysql-5.0.56]# /usr/local/mysql/bin/mysqld_safe --user=mysql &

登陆mysql

1
[root@lampmysql-5.0.56]# /usr/local/mysql/bin/mysql -u root

删除空用户

1
DELETE FROMmysql.user WHERE Host='localhost' AND User='';

刷新授权表

1
FLUSHPRIVILEGES;

设置root用户密码(mysql)

1
SETPASSWORD FOR 'root'@'localhost'=PASSWORD('redkey');

④安装PHP

1
2
3
4
[root@lamp ~]# tar-xzvf php-5.3.18.tar.gz
[root@lamp~]#./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/jpeg8/--with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/--with-zlib-dir=/usr/local/zlib/ --with-mcrypt=/usr/local/libmcrypt/--with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap--enable-mbstring=all --enable-sockets --enable-thread-safe-client
[root@lampphp-5.3.18]# make && make install
[root@lampphp-5.3.18]# cp php.ini-development /usr/local/php/etc/php.ini

四.安装常见问题解决:

1.缺失 APR APR-util

configure: error:Bundled APR requested but not found at ./srclib/. Download and unpack thecorresponding apr and apr-util packages to ./srclib/.

 

解决办法:

将APR和APR-util源码下载,解压放到httpd-2.4.3/srclib里面,并去除版本号

cp -r apr-1.4.6httpd-2.4.3/srclib/apr

cp -r apr-util-1.4.1httpd-2.4.3/srclib/apr-util

2. 缺少pcre

configure: error:pcre-config for libpcre not found. PCRE is required and available from

解决办法:

下载pcre,编译

tar zxvfpcre-8.31.tar.gz

cd pcre-8.31

./configure &&make && make install

3. 缺失mod_ssl

checking whether toenable mod_ssl... configure: error: mod_ssl has been requested but can not bebuilt due to prerequisite failures

 

解决办法:yum installopenssl-devel

 

4.在Linux Redhat6下面安装apache server的时候,执行完./configure命令后在执行make命令的时候报如下错误:/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32against `.rodata' can not be used when making a shared object; recompile with-fPIC

/usr/local/lib/libz.a:could not read symbols: Bad value

collect2: ld returned1 exit status

make[4]: ***[mod_deflate.la] 错误 1

make[4]: Leavingdirectory `/usr/local/httpd-2.4.3/modules/filters'

make[3]: ***[shared-build-recursive] 错误 1

make[3]: Leavingdirectory `/usr/local/httpd-2.4.3/modules/filters'

make[2]: ***[shared-build-recursive] 错误 1

make[2]: Leavingdirectory `/usr/local/httpd-2.4.3/modules'

make[1]: ***[shared-build-recursive] 错误1

make[1]: Leavingdirectory `/usr/local/httpd-2.4.3'

make: ***[all-recursive] 错误 1

解决办法:下载zlib-1.2.3.tar.gz放在/usr/local目录下执行以下命令:

tar -zxvfzlib-1.2.3.tar.gz

cd zlib-1.2.3

./configure

vi Makefile

找到 CFLAGS=-O3-DUSE_MMAP

在后面加入-fPIC,即变成CFLAGS=-O3 -DUSE_MMAP -fPIC

make && makeinstall

5.安装编译php出现以下问题:

MySQL clientlibrary is not bundled anymore!

解决:

错误描述:

在安装php-5.3.3时,configure过程出现错误:

checking for externallibmbfl… no

checking for externaloniguruma… no

checking for mcryptsupport… no

checking for MSSQLsupport via FreeTDS… no

checking for MySQLsupport… yes

checking for specifiedlocation of the MySQL UNIX socket… no

configure:error: Cannot find libmysqlclient_r under /usr/local/mysql.

Note that the MySQLclient library is not bundled anymore!

 

原因:

这是因为编译apache时使用了–with-mpm模块。因为shibboleth项目的原因,编译apache时使用了–with-mpm=worker参数,以优化apache。

 

 

但是,PHP-5.2 & later做了一个改进,需要mysql启用安全线程,即在编译mysql时加上–enable-thread-safe-client参数,在PHP-5.2.0之前的版本都不需要MYSQL启用安全线程。

解决方案:

Step1:重新编译安装mysql,启用安全线程.

./configure –prefix=/usr/local/mysql–with-mysqld-user=root –with-extra-charsets=all–with-unix-socket-path=/usr/local/mysql/var/mysql.sock–enable-thread-safe-client && make clean && make &&make install

在原编译命令基础上添加红色部分,并强烈建议在执行make之前执行make clean。

 

本文出自 “[Redkey]_记录学习点滴…” 博客,请务必保留此出处

感谢您对【51运维网 http://www.51ou.com/】的支持,我们为您免费提供《最佳LAMP环境搭建》技术文章,《最佳LAMP环境搭建》详细使用和说明,有时《最佳LAMP环境搭建》可能不完善、敬请谅解!如果《最佳LAMP环境搭建》有错误请给我们留言,我们将尽快修复文章错误,如果您觉得本站不错,请分享给周围的朋友!谢谢!

顶一下
(0)
0%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
验证码:点击我更换图片