LAMP安装过程实录

LAMP安装过程实录

 

概述:Linux + Apache + MySql + PHP环境源码安装搭建全过程

 

Linux: Center OS 5.6

Apache: httpd-2.2.0.tar.gz

MySql: mysql-5.0.41.tar.gz

PHP: php-5.2.6.tar.gz

 

在安装前需要下载以下文件并解压:

 

源码安装程序的一般步聚:

>配置(configure)

>编译(make)

>安装(make install)

 

 

1.         安装gcc.

yum list|grep gcc

yum install gcc.i386

 

2.         测试本系统是否安装了相应的环境。

 rpm -qa|grep httpd

 rpm -qa|grep mysql

 rpm -qa|grep php

 

3.         删除已有的软件。

1)         删除httpd

rpm -e system-config-httpd-1.3.3.3-1.el5

rpm -e httpd-2.2.3-45.el5.centos --nodeps

rpm -e httpd-manual-2.2.3-45.el5.centos

cd /etc/httpd

rm -rf *

 

2)          删除mysql

rpm -e mysql-5.0.77-4.el5_5.4 --nodeps

 

3)         3.3 删除php

rpm -e php-5.1.6-27.el5_5.3 --nodeps

rpm -e php-common-5.1.6-27.el5_5.3 --nodeps

rpm -e php-cli-5.1.6-27.el5_5.3 --nodeps

rpm -e php-ldap-5.1.6-27.el5_5.3 --nodeps

 

4.         解压文件。

1)         tar zxvf php-5.2.6.tar.gz

...

 

5.         开始安装。 Apache --> MySql -->PHP

1)         libxml2-2.6.30.

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

make

make install

 

2)         libmcrypt-2.5.8

./configure --prefix=/usr/local/libmcrypt

make

make install

 

3)         安装zlib最新库文件。

 

./configure --prexfix=/usr/local/zlib

make

make install

 

注意:Zlib安装在特定目录时有时其它程序会找不到,所以最好采用默认参数构建再安装一次

./configure

make

make install

 

4)         安装libpng最新库文件

./configure --prefix=/usr/local/libpng

make && make install && make clean

Install Failure.

 

5)         安装jpeg6最新库文件。

mkdir /usr/local/jpeg6

mkdir /usr/local/jpeg6/bin

mkdir /usr/local/jpeg6/lib

mkdir /usr/local/jpeg6/include

mkdir -p /usr/local/jpeg6/man/manl

 

#mkdir /usr/local/jpeg6            //建立jpeg6软件安装目录

# mkdir /usr/local/jpeg6/bin    //建立存放命令的目录

# mkdir /usr/local/jpeg6/lib     //创建jpeg6库文件所在目录

# mkdir /usr/local/jpeg6/include      //建立存放头文件目录

# mkdir -p /usr/local/jpeg6/man/man1 //建立存放手册的目录

 

# ./configure  /

> --prefix=/usr/local/jpeg6/ /            

> --enable-shared /                     //建立共享库使用的GNUlibtool

> --enable-static                       //建立静态库使用的GNUlibtool

 

Make && make install

 

6)         安装freetype最新库文件

# ./configure --prefix=/usr/local/freetype

# make

# make install

 

7)         安装autoconfig最新的库文件

# ./configure

# make

# make install

 

 

8)         5.8 安装最新的GD库文件

 #./configure  /    //配置命令

> --prefix=/usr/local/gd2/  /               //指定软件安装的位置

> --with-zlib=/usr/local/zlib/  /             //指定到哪去找zlib库文件的位置

> --with-jpeg=/usr/local/jpeg6/  /         //指定到哪去找jpeg库文件的位置

> --with-png=/usr/local/libpng/  /         //指定到哪去找png库文件的位置

> --with-freetype=/usr/local/freetype/       //指定到哪去找freetype 2.x

 

体库的位置

 

Make && make install

 

错误处理:

 

编译gd-2.0.35.tar.gz时报错:gd_png.c:16:53: error: png.h: No such file

or directory

2011-03-04 21:40

编译gd-2.0.35.tar.gz时报错:

 

gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/local/freetype/include/freetype2 -

I/usr/local/freetype/include -I/usr/local/freetype/include -

I/usr/local/jpeg/include -g -O2 -MT gd_png.lo -MD -MP -MF

.deps/gd_png.Tpo -c gd_png.c -fPIC -DPIC -o .libs/gd_png.o

gd_png.c:16:53: error: png.h: No such file or directory

gd_png.c:47: error: expected specifier-qualifier-list before ‘jmp_buf’

gd_png.c:54: error: expected ‘)’ before ‘png_ptr’

gd_png.c:82: error: expected ‘)’ before ‘png_ptr’

gd_png.c:92: error: expected ‘)’ before ‘png_ptr’

 

解决办法:

 

vi gd_png.c

#include “png.h”              /* includes zlib.h and setjmp.h */

替换成:

#include “/usr/local/libpng/include/png.h”              /* includes zlib.h and

setjmp.h */

然后再make就可以了

 

注:include“”双引号里包含的是libpng安装的路径里的include文件夹里的

png.h文件

 

 

9)          安装Apache服务器。

#./configure  /   //执行当前目录下软件自代的配置命令

> --prefix=/usr/local/apache2 /       //指定Apache软件安装的位置

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

> --with-z=/usr/local/zlib/ /                //指定zlib库文件的位置

> --with-included-apr  /                 //使用捆绑APR/APR-Util的副本

> --enable-so /                          //以动态共享对象(DSO)编译

> --enable-deflate=shared /               //缩小传输编码的支持

> --enable-expires=shared /               //期满头控制

> --enable-rewrite=shared /               //基于规则的URL操控

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

 

# make && make install

 

测试Apache服务器:

 

检查安装目录

检查配置文件目录

 /usr/local/apache2/bin/apachectl start   

//启动Apache

 /usr/local/apache2/bin/apachectl stop   

//关闭Apache

# netstat -tnl|grep 80     //查看80端口是否开启

http://localhost/去访问Apache服务器

 echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local   

添加自启动

 

错误处理:

linux上安装有些东西时会出现 Permission denied 的情况:以下就是解

决它的办法之一

编辑/etc/selinux/config,找到这段:

 

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - SELinux is fully disabled.

SELINUX=enforcing

 

SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为

 

SELINUX=disabled

保存,关闭。

……

 

编辑/etc/sysconfig/selinux,找到:

 

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - SELinux is fully disabled.

SELINUX=enforcing

如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把

SELINUX=enforcing 注释掉,新加一行:

 

SELINUX=disabled

保存,退出。

 

如果你碰到其他类似提示:

cannot restore segment prot after reloc: Permission denied

哪应该是SELinux的问题,可以考虑把它关闭。

————————————————————————————-

郁闷的是.我把SELinux关闭后还是不行.于是到googlesearch.发现这个很

有用.

在你保证SElinux disable.还执行下

chcon -t texrel_shlib_t

: chcon -t texrel_shlib_t /路径/路径/名字.so (这个文件视具体执行文

.)

 

以上两步.已经解决了很多server的问题了.

 

关闭防火墙

service iptables stop

 

 

10)     MySql安装

创建MySQL数据库服务器的配置文件

# cp support-files/my-medium.cnf /etc/my.cnf

 bin/mysql_install_db --user=mysql 

//创建授权表

# chown -R root? .  //将文件的所有属性改为root用户

# chown -R mysql var  //将数据目录的所有属性改为mysql用户

# chgrp -R mysql .     //将组属性改为mysql

# /usr/local/mysql/bin/mysqld_safe --user=mysql &    启动数据库

# netstat -tnl|grep 3306     //查看3306端口是否开启

# bin/mysqladmin version   //简单的测试

# bin/mysqladmin variables       //查看所有mysql参数

# bin/mysql -u root  //没有密码可以直接登录本机服务器

mysql> DELETE FROM mysql.user WHERE Host='localhost' AND User='';

mysql> FLUSH PRIVILEGES;

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD

('123456');

# bin/mysql -u root -h localhost p  //回车进入MySQL客户端

# bin/mysqladmin -u root p shutdown  //关闭MySQL数据库

 

错误处理:

安装mysql, ./configure时出现错误:error: No curses/termcap library

found的解决办法

 

 

mysql版本:5.1.30

之前在tar./configuremakemake install 经典四步时,从来没有想过

其中的过程,只觉得像例行公事一样,做就是了。

不幸的是,这次在./configure后,make时出现以下错误:

make: *** No targets specified and no makefile found. stop.

 

于是,在网上找到相关资料,确认是./configure出了问题

 

最后几行出了错。完整错误信息如下:

 

checking for tgetent in -lncurses... no

 

checking for tgetent in -lcurses... no

 

checking for tgetent in -ltermcap... no

 

checking for tgetent in -ltinfo... no

 

checking for termcap functions library... configure: error: No

curses/termcap library found

 

 

 

原因:

 

缺少ncurses安装包

 

 

 

解决办法:

 

下载安装相应软件包

 

一、如果你的系统是RedHat系列:

 

yum list|grep ncurses

 

yum -y install ncurses-devel

 

yum install ncurses-devel

 

 

 

二、如果你的系统是UbuntuDebian

 

apt-cache search ncurses

 

apt-get install libncurses5-dev

 

 

 

待安装completed!之后,再./configure,顺利通过,然后make && make

install,成功安装.

 

11)     安装PHP

 

# ./configure /               //执行当前目录下软件自代的配置命令

> --prefix=/usr/local/php /                           //设置PHP5 的安装路径

> --with-config-file-path=/usr/local/php/etc /            //指定PHP5配置文件

 

存入的路径

> --with-apxs2=/usr/local/apache2/bin/apxs /            //告诉PHP查找

 

Apache 2的地方

> --with-mysql=/usr/local/mysql/ /                     //指定MySQL的安装目录

> --with-libxml-dir=/usr/local/libxml2/ /                //告诉PHP放置libxml2

 

的地方

> --with-png-dir=/usr/local/libpng/ /                   //告诉PHP放置libpng库的

 

地方

> --with-jpeg-dir=/usr/local/jpeg6/ /                   //告诉PHP放置jpeg库的

 

地方

> --with-freetype-dir=/usr/local/freetype/ /             //告诉PHP放置

 

freetype库的地方

> --with-gd=/usr/local/gd2/ /                         //告诉PHP放置gd库的地方

> --with-zlib-dir=/usr/local/zlib/ /                     //告诉PHP放置zlib库的地方

> --with-mcrypt=/usr/local/libmcrypt/ /                //告诉PHP放置

 

libmcrypt库的地方

> --with-mysqli=/usr/local/mysql/bin/mysql_config /     //变量激活新增加

 

MySQLi功能

> --enable-soap /                                   //变量激活SOAPWeb services

支持

> --enable-mbstring=all /                            //使多字节字符串支持

> --enable-sockets                                  //变量激活socket通讯特性

 

#make && make install

 

 

Command:

./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/jpeg6/ --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

 

7. 安装Zend加速器。

./install.sh  //执行安装

 

8. phpMyAdmin的安装

cp -a  phpMyAdmin-3.0.0-rc1-all-languages  /

/usr/local/apache2/htdocs/phpmyadmin  //拷贝目录到指定位置并改名为

 

phpmyadmin

cd /usr/local/apache2/htdocs/phpmyadmin/

cp config.sample.inc.php

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值