LAMP安装步骤整理

一、要注意安装的顺序

Apahce   mysql    php 

 

二、LAMP安装前的准备

1、获取软件包

httpd-2.4.2.tar.gz                              http://httpd.apache.org/download.cgi

mysql-5.0.18.tar.gz                            http://dev.mysql.com/downloads/

php-5.4.3.tar.gz                               http://www.php.net/downloads.php

phpMyAdmin-3.5.1-all-languages.tar.gz            http://www.phpmyadmin.net/home_page/downloads.php

libxml2-2.7.2.tar.gz ftp://xmlsoft.org/libxml2/

libmcrypt-5.5.8.tar.gz                         http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/

gd-2.0.5.tar.gz                                 http://www.libgd.org

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

autoconf-2.69.tar.gz                            http://ftp.gnu.org/gnu/autoconf/

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

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

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

ZendGuard-5_5_0.tar.gz         http://www.zend.com/en/products/guard/thank-you-zend-guard?package=415l

 

2.【所有源码包打包下载:http://pan.baidu.com/share/link?shareid=343084&uk=1762525856 】

把上面下载的13个源代码包放到linux系统下的/usr/local/src/目录中

 

3. 确认当前的linux上,安装的有gcc编译器

gcc –v   //显示gcc版本则有安装

l 如果没有安装,可以使用下面的方法进行安装:

# From CentOS 5.8 - [DVD#1]

mkdir -p /media/cdrom

mount -r /dev/cdrom /media/cdrom

cd /media/cdrom/CentOS

rpm -Uvh glibc-devel-2.*

rpm -Uvh gcc-4.*

rpm -Uvh gcc-c++-4.*

rpm -Uvh libaio-devel-0.*

rpm -Uvh libstdc++-devel-4.*

如果上面安装的一某个RPM包还需要另外一个包时,可继续在光盘中查找,这里不在赘述。

 

4. 确认是否安装有 apache ,卸载那些低版本和路径不是我们想要的版本

rpm -qa | grep httpd           //用这个命令查看是否装有apache

 

如果有则删除

rpm –e     //这是删除命令

指令如下:

rpm -e httpd-manual

rpm -e httpd  --nodeps

 

--nodeps 表示不管依赖的关系,强行删除

 

l 看看是否安装的有mysql,同apache查看卸载方法一样。

rpm –qa | grep mysql

 

 

l 删除 php老版本

rpm –qa | grep mysql     //查看是否安装php

有则删除,删除命令:

 

 

三、开始搭建LAMP环境

1. 按照一定顺序来安装我们的源码包

基本步骤:

1. tar –zxvf 解压

2. 进入文件夹,然后使用 ./configure –prefix=路径来设置安装的路径

3. make  [编译]

4. make install [安装]

 

3.1 安装libxml2

step1:进入下载的软件源码包所在目录/usr/local/src/下,解压软件包libxml2-2.9.0.tar.gz到当前目录                                    libxml2-2.9.0下,并进入libxml2-2.9.0目录。命令如下行所示:

[root@localhost   ~]# cd /usr/local/src  //进入软件源码包所在目录

[root@localhost   src]# tar  -zxvf libxml2-2.9.0.tar.gz //解包解压

[root@localhost   src]# cd libxml2-2.9.0  //进入解包解压后的目录

step2:使用configure命令检查并配置安装需要的系统环境,并生成安装配置文件,命令行如下。

[root@localhost   libxml2-2.9.0]# ./configure --prefix=/usr/local /libxml2 //选项--prefix=/usr/local/libxml2 作用,是在安装时将软件安装到/usr/local/libxml2 目录下。

step3:使用make命令编译源代码文件并生成安装文件。命令行如下示。

      [root@localhost   libxml2-2.9.0]# make  //对软件源代码文件进行编译

step4:使用make install命令安装编译过的文件。命令行如下。

[root@localhost   libxml2-2.9.0]# make install  //开始安装libxml2库文件

 

        如果安装成功以后,在/usr/local/libxml2/目录下将生成bin,include,lib,share四个目录。在后面安装 PHP5         源代码的配置时,会通过在configure命令的选项中加上"--with-libxml-dir=/usr/local/libxml2"选 项,用             于指定安装libxml2库文件的位置。

 

3.2 安装libmcrypt

 

步骤:

Step1:  解压 libmcrypt-2.5.8.tar.gz 然后:进入到解压后目录

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

Step3:  make && make install

 

如果安装成功就会在/usr/local/libmcrypt/目录下生成 bin,include,lib,man,share五个目录。然后在安 装PHP5 源代码包的配置时,就可以通过configure命令加上“--with-mcrypt-dir=/usr/local/libmcrypt” 选项,指定这个 libmcrypt库文件的位置。

 

 

./configure时报错:configure: error: C++ compiler cannot create executables 

解决方案:

运行下面命令,然后重新configure(配置)

yum install gcc gcc-c++ gcc-g77

安装完成libmcrypt库以后,不同的linux系统版本有可能还要安装一下libltdl库。安装方法和前面的步骤相同,可以进入到解压缩的 目录/usr/local/src/libmcrypt-2.5.8下,找到libltdl库源代码所在的目录libltdl,进入这个目录按照下面几个 命令配置、编译、安装就可以了。

[root@localhost   libltdl]# pwd

/usr/local/src/libmcrypt-2.5.8/libltdl  //进入软件源代码目录

[root@localhost   libltdl]# ./configure  --enable-ltdl-install  //配置ltdl库的安装

[root@localhost   libltdl]# make  //编译

[root@localhost   libltdl]# make install  //安装

 

 

安装完成libmcrypt库以后,不同的linux系统版本有可能还要安装一下libltdl库。安装方法和前面的步骤相同,可以进入到解压缩的 目录/usr/local/src/libmcrypt-2.5.8下,找到libltdl库源代码所在的目录libltdl,进入这个目录按照下面几个 命令配置、编译、安装就可以了。

[root@localhost   libltdl]# pwd

/usr/local/src/libmcrypt-2.5.8/libltdl  //进入软件源代码目录

[root@localhost   libltdl]# ./configure --enable-ltdl-install  //配置ltdl库的安装

[root@localhost   libltdl]# make  //编译

[root@localhost   libltdl]# make install  //安装

 

3.3  安装zlib 

步骤:

Step1:  解压 zlib-1.2.3.tar.gz 然后:进入到解压文件

Step2:  ./configure --prefix=/usr/local/zlib

Step3:  make && make install

 

安装方法与前面安装libxml2的方法相同,要注意的地方就是路径/usr/local/zlib/。如果安装成功将会在/usr/local /zlib目录下生成include,lib,share三个目录。在安装PHP5配置时,在configure命令的选项中加上“--with- zlib-dir=/usr/local/libmcrypt”选项,用于指定zlib库文件位置。

 

 

3.3  安装libpng 库 (php支持libxml2)

步骤:

Step1:  解压 libpng-1.2.31.tar.gz 然后:进入到解压后的目录

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

Step3:  make && make install

 

 

./configure --prefix=/usr/local/libpng这步最后如果提示:configure: error: ZLib not installed

解决方法如下:

1.进入zlib的源文件目录,执行命令 make clean,清除zlib

2.重新配置 ./configure,后面不要接--prefix参数;

3.make && make install

4.进入libpng目录,执行命令 ./configure --prefix=/usr/local/libpng;

5.make && make install

6.安装成功.

 

如果安装成功将会在/usr/local/libpng目录下生成bin,include,libshare四个目录。在安装GD2库配置时,通 过在configure命令选项中加上“--with-png=/usr/local/libpng”选项,指定libpng库文件的位置。

 

3.4   安装jpeg8 库 

步骤:

Step1: 解压 jpegsrc.v6b.tar.gz 然后:该软件不会自动创建需要的目录,需要手动创建  

[root@localhost   ~]# mkdir /usr/local/jpeg8  //建立jpeg8软件安装目录

[root@localhost   ~]# mkdir /usr/local/jpeg8/bin //建立存放命令的目录

[root@localhost   ~]# mkdir /usr/local/jpeg8/lib  //创建jpeg8库文件所在目录

[root@localhost   ~]# mkdir /usr/local/jpeg8/include //建立存放头文件目录

[root@localhost   ~]# mkdir -p /usr/local/jpeg8/man/man1 //建立存放手册的目录

Step2:  [root@localhost   jpeg-8b]# ./configure  \

> --prefix=/usr/local/jpeg8/ \

> --enable-share \

> --enable-static

警告:configure: WARNING: unrecognized options: --enable-share

在安装GD2库配置时,可以在configure命令的选项中加上“--with-jpeg=/usr/local/jpeg8”选项,指定jpeg8 库文件的位置。安装PHP时也要指定该库文件的位置。

 

 

3.5  安装freetype 库 (php支持libxml2)

步骤:

Step1:  解压 freetype-2.4.10.tar.gz 然后:进入到解压目录

Step2:  ./configure --prefix=/usr/local/freetype

Step3:  make && make install

 

如果安装成功将会在/usr/local/freetype目录下存在bin,include,libshare四个目录。并在安装GD2库时, 通过configure命令选项中加上“--with-freetype=/usr/local/freetype/”选项,指定freetype库文件 位置。

 

3.6  安装autoconf 库 

步骤:

Step1:  解压  autoconf-2.61.tar.gz 

Step2:  ./configure                           //唯一注意的地方是configure时,不用指定路径。

Step3:  make && make install

 

3.7  安装gd

步骤:

Step1:  解压 gd-2.0.35.tar.gz ,进入到gd的文件夹

Step2: 

./configure \  //配置命令

--prefix=/usr/local/gd \  //指定安装软件的位置

--with-jpeg=/usr/local/jpeg8/ \  //指定去哪找jpeg库文件

--with-png=/usr/local/libpng/ \  //指定去哪找png库文件

--with-freetype=/usr/local/freetype/   //指定去哪找freetype 2.x字体库的位置

Step3:  make && make install

 

如果安装成功会在/usr/local/gd/目录下存在binincludelib这三个目录。在安装PHP5时,通过在configure命令选项中加上“--with-gd=/usr/local/gd”选项,指定GD库文件的位置。

 

如果报错:

make[2]: *** [gd_png.lo] Error 1

make[2]: Leaving directory `/tmp/gd-2.0.35'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/tmp/gd-2.0.35'

make: *** [all] Error 2

解决方案:

vi gd_png.c

找到#include "png.h"改成#include "/usr/local/libpng/include/png.h"

 

 

3.8 安装apache 

步骤:

Step1:  卸载aprapr-util

yum remove apr apr-util

下载安装:

http://apr.apache.org/download.cgi

apr-1.4.6.tar.gz

    ./configure --prefix=/usr/local/apr-httpd/ && make && make install

 

下载安装:

http://apr.apache.org/download.cgi

apr-util-1.5.1.tar.gz

    ./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/ && make && make install

 

    下载:http://sourceforge.net/projects/pcre

#unzip -o pcre-8.32.zip

#cd pcre-8.32

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

#make

#make install

 

Step2:   解压apache软件,进入到解压后的目录

 

Step3: [root@localhost   httpd-2.4.3]# ./configure \

> --prefix=/usr/local/apache243 \

> --enable-mods-shared=all \

> --enable-deflate \

> --enable-speling \

> --enable-cache \

> --enable-file-cache \

> --enable-disk-cache \

> --enable-mem-cache \

> --enable-so \

> --enable-expires=shared \

> --enable-rewrite=shared \

> --enable-static-support \

> --sysconfdir=/etc/httpd \

> --with-z=/usr/local/zlib/ \

> --with-apr=/usr/local/apr-httpd/ \

> --with-apr-util=/usr/local/apr-util-httpd/ \

> --with-pcre=/usr/local/pcre/ \

> --disable-userdir

Step3:  #make && make install

 

安装完成后,进入/usr/local/apache243/目录下,检查是否有以下文件:

bin  build  cgi-bin  error  htdocs  icons  include  logs  man  manual  modules

启动Apache服务器,并查端口是否开启,启动Apache服务器的命令行如下:

#/usr/local/apache243/bin/apachectl start

提示信息:

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message

解决方案:

vi /etc/httpd/httpd.conf

加上下面一行,重启apache

ServerName localhost:80

 

查看端口命令行如下:

#netstat -tnl|grep 80

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LIST

测试安装结果,打开浏览器,在地址栏中输入URL为:http://yourIp/

如果浏览器中出现It works!则表明Apache服务器可以使用。

每种服务器软件都有必要制成开机时自动启动,Apache服务器开机自动启动,只要在“/etc/rc.d/rc.local”文件,加上 Apache服务器的启动命令即可。可以直接打开“/etc/rc.d/rc.local”文件,在最后一行写入Apache启动命令,也可以用echo 命令追加进去,如下命令行示:

[root@localhost   apache243]# echo "/usr/local/apache243/bin/apachectl start" >> /etc/rc.d/rc.local

 

 

 

Linux系统下安装好apache(httpd)服务后,其他电脑无法访问的原因:

因为前段时间有知道过iptable(linux下防火墙)的限制,所以在想是不是因为iptable限制了80端口呢!

所以在网上找了下iptable的命令,并且把tcp80端口设置成允许任何IP都可以访问:

iptables -I INPUT -p TCP --dport 80 -j ACCEPT  

 

然后在windows下访问,网页正常显示。

 

 

 

 

3.9  安装mysql数据库

步骤:

1、增加用户名和用户组

#groupadd mysql

#useradd -g mysql mysql

 

2、进入源码包使用configure 检查并配置安装需要的系统环境,并生成安装配置文件

#./configure \

>--prefix=/usr/local/mysql \  //将软件安装在/usr/local/mysql目录下

>--enable-thread-safe-client \

>--with-extra-charsets=all  //在安装mysql时安装所有字符集

make

make install

 

如果遇到错误信息:

checking for tgetent in -lncurses... no

checking for tgetent in -lcurses... no

checking for tgetent in -ltermcap... no

checking for termcap functions library... configure: error: No curses/termcap library found

原因:缺少ncurses安装包

解决方案:

执行下面三行命令,执行完之后重新./configure(配置)

yum list|grep ncurses

yum -y install ncurses-devel

yum install ncurses-devel

接着#make && make install

 

3、创建mysql数据库服务器的配置文件,可以使用源码包support-files目录中的my-medium.cnf文件作为 模板,将其复制到/etc/目录下,命名为my.cnf文件即可。

[root@localhost   mysql-5.0.18]# cp support-files/my-medium.cnf   /etc/my.cnf

 

4、如果还没安装过MySQL,必须创建MySQL授权表。进入到安装目录/usr/local/mysql下,执行bin目录 下的mysql_install_db脚本,用来初始化MySQL数据库的授权表,其中存储了服务器访问允许。

[root@localhost   mysql-5.0.18]#cd /usr/local/mysql

[root@localhost   mysql]# bin/mysql_install_db --user=mysql  //创建授权表

如果使用root用户运行上面的命令,应当使用--user选项,选项的值应当与你在第一步为运行服务器所创建的登录账户(mysql用户)相同。 如果用mysql用户登录来运行上面的命令,可以省略--user选项。

mysql_install_db创建mysql授权表后,需要手动重新启动服务器。

 

5、将程序二进制的所有权改为root用户,数据目录的所有权改为运行mysqld程序的mysql用户。如果现在位于安装目录(/usr/local/mysql)下,命令行如下:

[root@localhost   mysql]# chown -R root .  (注意有点) //将文件的所有属性改为root用户

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

[root@localhost   mysql]# chgrp -R mysql .  (注意有点)//将组属性改为mysql

[root@localhost   mysql]# ls -l

total 40

drwxr-xr-x. 2 root  mysql 4096 Feb  7 20:50 bin

drwxr-xr-x. 3 root  mysql 4096 Feb  7 20:50 include

drwxr-xr-x. 2 root  mysql 4096 Feb  7 20:50 info

drwxr-xr-x. 3 root  mysql 4096 Feb  7 20:50 lib

drwxr-xr-x. 2 root  mysql 4096 Feb  7 20:50 libexec

drwxr-xr-x. 3 root  mysql 4096 Feb  7 20:50 man

drwxr-xr-x. 7 root  mysql 4096 Feb  7 20:50 mysql-test

drwxr-xr-x. 3 root  mysql 4096 Feb  7 20:50 share

drwxr-xr-x. 5 root  mysql 4096 Feb  7 20:50 sql-bench

drwx------. 4 mysql mysql 4096 Feb  7 20:53 var

 

6、在所需要的东西被安装完成后,应当使用下面的命令启动MySQL服务了,命令行如下:

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

报告信息(不理会):

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

[1] 4720

[root@localhost   mysql]# nohup: ignoring input and redirecting stderr to stdout

Starting mysqld daemon with databases from /usr/local/mysql/var

 

7MySQL数据库服务器启动之后,查看一下它的端口3306是否打开,如果看到以下结果表明mysql服务启动成功。命令行如下

[root@localhost   mysql]# netstat -tnl|grep 3306

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN

 

8、使用mysqladmin验证服务器在运行中。以下命令提供了简单的测试,可检查服务器是否已经开启并能响应连接。命令行如下:

[root@localhost   mysql]# bin/mysqladmin  version

Enter password:

bin/mysqladmin  Ver 8.41 Distrib 5.0.18, for pc-linux-gnu on i686

Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL license

Server version          5.0.18-log

Protocol version        10

Connection              Localhost via UNIX socket

UNIX socket             /tmp/mysql.sock

Uptime:                 18 min 59 sec

Threads: 1  Questions: 3  Slow queries: 0  Opens: 0  Flush tables: 1  Open tables: 6  Queries per second avg: 0.003

[root@localhost   mysql]# bin/mysqladmin variables //查看所有mysql参数

 

9、设置访问权限,在mysql安装过程中,使用mysql_install_db程序安装了mysql数据库授权表,表定义了初始mysql用户 账户和访问权限,所有初始化账户均没有密码。这些账户为超用户账户,可以执行任何操作。初始root账户的密码为空,因此任何人可以用root账户不用任 何密码来连接mysql服务器,并具有所有权限,这意味着mysql安装未受保护。如果你想要防止客户端不使用密码用匿名用户来连接,你应当为匿名账户指 定密码或删掉匿名帐户,应当为mysql root账户指定密码。使用mysql -u root启动mysql客户端控制台,连接mysql服务器。命 令行如下:

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

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 5 to server version: 5.0.18-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

 

10、如果有匿名账户存在,它拥有全部的权限,因此删掉它可以提高安全,在mysql客户端执行SQL语如下:

mysql> delete from mysql.user where host='localhost' and user='';

Query OK, 1 row affected (0.01 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

11、可以用几种方法为root账户指定密码,我们选择用其中的一种。mysql客户端命令行上使用set password指定密码,一定要使 用password()函数来加密密码。例如下面设置localhost域的密码为ios100。其他域可以使用同样的语句,使用的SQL语句如下。

mysql> set password for 'root'@'localhost'=password('你要设置的密码');

Query OK, 0 rows affected (0.00 sec)

 

12、如果想退出mysql客户端,可以在mysql客户端提示符下输入命令exit或者quit,还可以按键盘ctrl+c组合键,都可以从 mysql客户端退出。因为已经给mysql服务器的root账号设置了密码,所以再次登录mysql客户端就要提供密码才能进入。退出mysql客户端 和重新启动mysql客户端的控制台命令如下。

mysql> exit

Bye

[root@localhost   mysql]# bin/mysql -u root -h localhost -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6 to server version: 5.0.18-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

如果想关闭mysql服务器,在命令行使用mysql服务器的mysqladmin命令,通过-u参数给出mysql数据库管理员用户名root和通过-p参数给出密码,即可关闭mysql服务器。如下示:

[root@localhost   mysql]# bin/mysqladmin -u root -p shutdown

Enter password:

STOPPING server from pid file /usr/local/mysql/var/localhost.pid

130207 21:27:05  mysqld ended

[1]+  Done                    /usr/local/mysql/bin/mysqld_safe --user=mysql

 

13mysql服务器和apache服务器一样也有必要设置为开机自动运行,设置方法进入到mysql源代码目录/usr/local/src /mysql-5.0.18,将子目录support-files下的mysql.server文件复制到/etc/rc.d/init.d目录中,并重 命名为mysqld,命令行如下。

[root@localhost   mysql]# cd /usr/local/src/mysql-5.0.18

[root@localhost   mysql-5.0.18]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

修改一下权限

[root@localhost   mysql-5.0.18]# chown root.root /etc/rc.d/init.d/mysqld

[root@localhost   mysql-5.0.18]# chmod 755 /etc/rc.d/init.d/mysqld

mysqld添加到chkconfig

[root@localhost   mysql-5.0.18]# chkconfig --add mysqld

在图形和字符集界面下自动启动mysqld

[root@localhost   mysql-5.0.18]# chkconfig --level 3 mysqld on

[root@localhost   mysql-5.0.18]# chkconfig --level 5 mysqld on

再使用chkconfig --list命令检查设置

[root@localhost   mysql-5.0.18]# chkconfig --list mysqld

mysqld          0:off   1:off   2:on    3:on    4:off    5:on    6:off

 

 

 

4.0  安装最新版的PHP模块

步骤:

Step1: 解压进入php-5.4.11源码包编译

[root@localhost   php-5.4.11]# ./configure \

> --prefix=/usr/local/php \

> --with-config-file-path=/usr/local/php/etc \

> --with-apxs2=/usr/local/apache243/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/gd/ \

> --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

make(配置)

提示信息:

Build complete.

Don't forget to run 'make test'.

解决方案:

不要make test 直接make install

 

配置时可能会出现下面的错误:

    checking for MySQL support... yes

checking for specified location of the MySQL UNIX socket... no

checking for MySQL UNIX socket location... no

configure: error: Cannot find libmysqlclient_r under /usr/local/mysql. Note that the MySQL client library is not bundled anymore!

其实这跟PHP没有关系,那是因为在编译APACHE的时候,使用--with-mpm模块,所以就必须在编译MYSQL的时候加上 --enable-thread-safe-client.参数

这是PHP5.2的一个改进,在PHP5.2.0之前的版本都不需要MYSQL启用安全线程。关于--enable-thread-safe- client项的官方介绍如下:如何生成线程式客户端库总是线程安全的。最大的问题在于从套接字读取的net.c中的子程序并不是中断安全的。或许你可能 希望用自己的告警中断对服务器的长时间读取,以此来解决问题。如果为SIGPIPE中断安装了中断处理程序,套接字处理功能应是线程安全的。 SupeSite/X-为了避免连接中断时放弃程序,MySQL将在首次调用mysql_server_init()mysql_init()或 mysql_connect()时屏蔽SIGPIPE。如果你打算使用自己的SIGPIPE处理程序,首先应调用 mysql_server_init(),然后安装你的处理程序.

还有第二种解决方法比较方便 :编译之前,先处理一下mysql的库,默认查找libmysqlclient_r.so,可是mysql默认为libmysqlclient.so,内容完全一样,做个链接即可

# cd /usr/local/mysql/lib/mysql/

# ln -s libmysqlclient.so.15.0.0 libmysqlclient_r.so

(以上解决方法来自互联网!)

还会报make: *** [ext/gd/gd.lo] error

解决方法如下:

好像说这个错误算是php5.4bug,下面对应的两篇文章有对应的说明:

https://bugs.php.net/bug.php?id=55224

https://bugs.php.net/bug.php?id=60108

解决方法:

vi <gd_dir>/include/gd_io.h

gdIOCtx结构中增加void *data;

格式如下

typedef struct gdIOCtx

{

int (*getC) (struct gdIOCtx *);

int (*getBuf) (struct gdIOCtx *, void *, int);

 

void (*putC) (struct gdIOCtx *, int);

int (*putBuf) (struct gdIOCtx *, const void *, int);

 

/* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */

int (*seek) (struct gdIOCtx *, const int);

 

long (*tell) (struct gdIOCtx *);

 

void (*gd_free) (struct gdIOCtx *);

void (*data);

}

gdIOCtx;

我的GD安装在/usr/local/gd2目录下,所以是#vi vi /usr/local/gd/include/gd_io.h

libltdl.so.3: cannot open shared object file: No such file or directory

make: *** [ext/phar/phar.php] Error 127

解决方法:

ln -s /usr/local/lib/libltdl.so.3 /usr/lib/libltdl.so.3

[root@localhost   ~]# cd /usr/local/libpng/lib/

[root@localhost   lib]# ls

libpng15.a   libpng15.so     libpng15.so.15.10.0  libpng.la  pkgconfig

libpng15.la  libpng15.so.15  libpng.a             libpng.so

可以看到libpng15.so.15

然后修改/etc/ld.so.conf 文件:vi /etc/ld.so.conf

在第一行下面追加/usr/local/libpng/lib这个路径。

然后重新编译安装即可。

提示信息:

=====================================================================

=====================================================================

WARNED TEST SUMMARY

---------------------------------------------------------------------

Bug #52062 (large timestamps with DateTime::getTimestamp and DateTime::setTimestamp) (32 bit) [ext/date/tests/bug52062.phpt] (warn: XFAIL section but test passes)

=====================================================================

You may have found a problem in PHP.

This report can be automatically sent to the PHP QA team at

http://qa.php.net/reports and http://news.php.net/php.qa.reports

This gives us a better understanding of PHP's behavior.

If you don't want to send the report immediately you can choose

option "s" to save it.  You can then email it to qa-reports@lists.php.net later.

Do you want to send this report now? [Yns]:

解决方案:

不要make test 直接make install

 

 

 

4.1  apache  和 php的整合

 

Step1: 将源码包下面的php.ini-development 文件复制到/usr/local /php/etc/中,并改名为php.ini即可,如下示:

[root@localhost   php-5.4.11]# cp php.ini-development /usr/local/php/etc/php.ini

 

Step2: 修改php.ini ;date.timezone 前面的分号去掉,改成date.timezone ="Asia/Shanghai "

 

Step3: 整合ApachePHP,上面编译之前,我们使用configure命令安装配置时,使用--with-apxs2=/usr/local /apache242/bin/apxs选项以使Apache 2PHP作为功能模块使用。但我们还要修改Apahce配置文件,添加PHP的支持,告诉Apache将哪些后缀作为PHP解析。

例如,让Apache.php.phtml后缀名解析为PHP.使用vi打开Apache的配置文件 /etc/httpd/httpd.conf,找到AddType application/x-gzip .gz .tgz指令选项,并在其下方添加一 条指令AddType application/x-httpd-php .php .phtml。也可以将任何后缀的文件解析为PHP,只要在添加的语 句中加入并用空格分开,这里以多添加一个.phtml来示例,如下示:

# If the AddEncoding directives above are commented-out, then you

# probably should define those extensions to indicate media types:

#

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

AddType application/x-httpd-php .php .phtml

修改完成后必须重启Apache服务器,才能重新加载配置文件使修改生效。

[root@localhost   php-5.4.11]#/usr/local/apache243/bin/apachectl stop

[root@localhost   php-5.4.11]#/usr/local/apache243/bin/apachectl start

最后一步重新启动apache报如下错误:
  httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
  
  原因:是Linux有一个SELinux保护模式引起的。
  
  解决办法:
  
  1关闭SELINUX的方法:
  vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled 需要重启
  这个方法可能会对服务器带来风险。
  2不关闭SELINUX的方法:
  # setenforce 0
  # chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
  
  # service httpd restart
  # setenforce 1

 

Step4: 测试PHP环境是否可以正常运行,在/usr/local/apache243/htdocs目录下建一个test.phptest.phtml的文件,内容如下示:

<?php

phpinfo();

?>

打开浏览器,在地址栏输入http://yourip/test.php来运行该文件,如果出现下图内容,说明LAMP环境安装成功。

posted @ 2013-05-09 12:01  SallyBin  阅读(647)  评论(0编辑  收藏  举报