fdeli 发表于 2013-9-18 08:55:18

最佳LAMP环境搭建[Linux+Apache+Mysql+Php]

最佳LAMP环境搭建
--Linux+Apache+Mysql+Php
[参照LAMP兄弟连PPT]
一.软件包&下载地址[来自兄弟连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:


# tar -xjvf libxml2-2.6.23.tar.bz2
# cd libxml2-2.6.23
# ./configure--prefix=/usr/local/libxml2
# make &&make install
(2.)安装libmcrypt


# tar -xzvflibmcrypt-2.5.7.tar.gz
# cd libmcrypt-2.5.7
# ./configure--prefix=/usr/local/libmcrypt
# make &&make install
(3.) 安装zlib库


# tar -xjvf zlib-1.2.3.tar.bz2
# cd zlib-1.2.3
vi Makefile
找到 CFLAGS=-O3 -DUSE_MMAP
在后面加入-fPIC,即变成CFLAGS=-O3-DUSE_MMAP -fPIC


# ./configure--prefix=/usr/local/zlib
# make && makeinstall
(4.)安装libpng库


# tar -xzvf libpng-1.0.60.tar.gz
# cd libpng-1.0.60
# ./configure--prefix=/usr/local/libpng
# make &&make install
(5.) 安装jpeg8库


# tar -xzvf jpegsrc.v8.tar.gz
# cd jpeg-8/
# mkdir -p/usr/local/jpeg8/{bin,lib,include,man/man1}
# ./configure--prefix=/usr/local/jpeg8/ --enable-shared --enable-static
# make && makeinstall
(6.) 安装freetype库


# tar -xjvffreetype-2.3.9.tar.bz2
# cd freetype-2.3.9
# ./configure--prefix=/usr/local/freetype
# make &&make install
(7.) 安装autoconf库


# tar -xzvf autoconf-2.13.tar.gz
# cd autoconf-2.13
# ./configure
# make &&make install
(8.) 安装GD库


# tar -xzvf gd-2.0.32.tar.gz
# ./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/
# make && make install
②安装APACHE
(1.)安装apr


# 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


#tar -xjvf apr-util-1.4.1.tar.bz2
# 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


# tar -xjvf pcre-7.9.tar.bz2
# cd pcre-7.9
[root@lamppcre-7.9]# ./configure --prefix=/usr/local/pcre
[root@lamppcre-7.9]# make && make install
(4.)安装apahce


# tar -xzvf httpd-2.4.3.tar.gz
# mv apr-1.4.6 httpd-2.4.3/srclib/apr
# mv apr-util-1.4.1 httpd-2.4.3/srclib/apr-util
# cd httpd-2.4.3
[root@lamphttpd-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服务器:

# /usr/local/apache2/bin/apachectl start
测试访问:

# elinks http://127.0.0.1
增加开机启动:

# echo "/usr/local/apache2/bin/apachectl start" >>/etc/rc.d/rc.local
③安装Mysql
添加mysql用户组

# groupadd mysql
添加mysql用户

# useradd -g mysql mysql
编译安装mysql
# tar -xzvf mysql-5.0.56.tar.gz
# cd mysql-5.0.56
[root@lampmysql-5.0.56]# ./configure --prefix=/usr/local/mysql \
>--with-extra-charsets=all
创建Mysql数据库的配置文件

[root@lampmysql-5.0.56]# cp support-files/my-medium.cnf /etc/my.cnf
创建授权表

[root@lampmysql-5.0.56]# /usr/local/mysql/bin/mysql_install_db --user=mysql
将Mysql所有文件属主改为root

[root@lampmysql-5.0.56]# chown -R root /usr/local/mysql/
将数据目录的属主改为mysql用户

[root@lampmysql-5.0.56]# chown -R mysql /usr/local/mysql/var/
将mysql属组更改为:mysql组

[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

[root@lampmysql-5.0.56]# /usr/local/mysql/bin/mysql -u root
删除空用户

DELETE FROMmysql.user WHERE Host='localhost' AND User='';
刷新授权表

FLUSHPRIVILEGES;
设置root用户密码(mysql)

SETPASSWORD FOR 'root'@'localhost'=PASSWORD('redkey');
④安装PHP


# tar-xzvf php-5.3.18.tar.gz
#./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: *** 错误 1
make: Leavingdirectory `/usr/local/httpd-2.4.3/modules/filters'
make: *** 错误 1
make: Leavingdirectory `/usr/local/httpd-2.4.3/modules/filters'
make: *** 错误 1
make: Leavingdirectory `/usr/local/httpd-2.4.3/modules'
make: *** 错误1
make: Leavingdirectory `/usr/local/httpd-2.4.3'
make: *** 错误 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。

搜索泥称 发表于 2013-11-27 23:07:04

男人,那有一个不好色的。

542179528 发表于 2013-11-30 01:48:04

帮你顶下哈!!

寂寞大萝卜 发表于 2013-12-3 17:02:33

爱着的东西,真让人琢磨不清。

ct38 发表于 2013-12-6 17:00:23

花.飞彼岸花.只为找到心爱德人.用黑暗来祭奠悲伤德残泪.花开花落.

12343052 发表于 2013-12-8 16:02:35

丶 爱情不是占有一个人 而是征服一颗心。

hyytaojunming 发表于 2013-12-10 18:19:28

-至少涐扪中还有人快乐,这样就已足够了,
页: [1]
查看完整版本: 最佳LAMP环境搭建[Linux+Apache+Mysql+Php]