Centos下安装LAMP

本文是根据网上一个安装LAMP教程,经过自己亲身试验后修改而成,参考原文地址因为忘了,在这边就无法贴出来了,在这对那位作者表示抱歉。


一、LAMP安装前的准备

1、获取软件包
httpd-2.4.2.tar.gz    http://httpd.apache.org/download.cgi
(使用浏览器下载,用wget下的下到的是html的页面)
mysql-5.0.96.tar.gz  http://dev.mysql.com/downloads/
(使用浏览器下载,选择MySQL Community Server,点击Mysql Community Server 5.0,
进入5.0.96,选择Source and other files下的mysql-5.0.96. tar.gz的包进行下载)
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
(点击相应链接,进入downloads下载相应的包,此种下载在桌面模式下下载,放到相应位置处)
zlib-1.2.5.tar.gz  http://www.zlib.net
(进入该网站后,找到Pick a mirror,点击进行下载)
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
把上面下载的13个源代码包放到linux系统下的/usr/local/src/目录中


2、检查安装时使用的编译工具是否存在
gcc -v
如果不显示任何信息,说明未安装gcc,使用
yum install gcc
安装


3、检查并卸载低版本环境
rpm -qa | grep -i httd
rpm -qa | grep -i mysql
rpm -qa | grep -i php
如果不显示任何信息,则说明没有安装过LAMP环境,否则就安装过了,需要卸载,卸载的方法自己网上找


Linux下LAMP环境的安装之编译安装过程(一)
搭建LAMP环境时,需要安装的所有软件都要按照一定的顺序安装,我们按照Apache->MySQL->PHP的顺序安装。
但是在安装PHP之前,应先安装PHP5需要的最新版本库文件,例如libxml2、libmcrypt,以及GD2库等文件。
安装GD2库是为了让PHP5支持GIF、PNG和JPEG图片格式,所以在安装GD2库之前还要先安装最新的zlib、libpng、freetype和jpegsrc等库文件。
而且中间还会穿插安装一些软件。


1、解压tar.gz为后缀的压缩包软件
LAMP环境搭建所需要的每个软件的源代码文件,都是以.tar.gz提供给我们的打包压缩文件,所以我们必须将其解压再解包。
可通过命令#tar zxvf tarfile.tar.gz达到目的。


2、在linux系统中源代码包安装过程
进行解压后的目录,LAMP环境搭建所需要的软件都使用C语言开发的,所以安装源代码文件最少需要配置(configure)、编译(make)、
安装(make install)三个步骤。(在此补充一句,configure、make、make install都需要gcc的支出)


安装libxml2最新库文件
step1:进入下载的软件源码包所在目录/usr/local/src/下,解压软件包libxml2-2.7.2.tar.gz到当前目录libxml2-2.7.2下,并进入libxml2-2.7.2目录。命令如下行所示:
[root@discuz ~]# cd /usr/local/src  //进入软件源码包所在目录 
[root@discuz src]# tar zxvf libxml2-2.7.2.tar.gz //解包解压
[root@discuz src]# cd libxml2-2.7.2  //进入解包解压后的目录
step2:使用configure命令检查并配置安装需要的系统环境,并生成安装配置文件,命令行如下。
[root@discuz libxml2-2.7.2]# ./configure --prefix=/usr/local/libxml2 //选项--prefix=/usr/local/libxml2作用,是在安装时将软件安装到/usr/local/libxml2目录下。
step3:使用make命令编译源代码文件并生成安装文件。命令行如下示。
[root@discuz libxml2-2.7.2]# make  //对软件源代码文件进行编译
step4:使用make install命令安装编译过的文件。命令行如下。
[root@discuz libxml2-2.7.2]# make install  //开始安装libxml2库文件
如果安装成功以后,在/usr/local/libxml2/目录下将生成bin,include,lib,share四个目录。在后面安装PHP5源代码的配置时,
会通过在configure命令的选项中加上"--with-libxml-dir=/usr/local/libxml2"选项,用于指定安装libxml2库文件的位置。


安装libmcrypt最新库文件
安装方法与上面安装libxml2方法相同,注意configure时的路径/usr/local/libmcrypt
(注:安装libmcrypt组件包时,当我进行./configure编译时出现报错:configure: error: C++ compiler cannot create executables 。
          yum install gcc gcc-c++ gcc-g77
          导致这个问题是由于gcc组件安装不完整。。
          如果按照上面执行操作还是不行的话,请执行:
          yum clear all  //清除yum所有缓存
          yum update   //更新yum
          yum install gcc gcc-c++ gcc-g77
          即可。。

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


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


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


安装libpng最新库文件
安装方法与前面安装libxml2的方法相同,要注意路径/usr/local/libpng/
在./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,lib和share四个目录。在安装GD2库配置时,通过在configure命令选项中加上“--with-png=/usr/local/libpng”选项,
指定libpng库文件的位置。


安装jpeg8最新库文件
step1:安装GD2库前所需的jpeg8库文件,需要自己手动创建安装需要的目录,它们在安装时不能自动创建。命令行如下。
[root@discuz ~]# mkdir /usr/local/jpeg8  //建立jpeg8软件安装目录
[root@discuz ~]# mkdir /usr/local/jpeg8/bin //建立存放命令的目录
[root@discuz ~]# mkdir /usr/local/jpeg8/lib  //创建jpeg8库文件所在目录
[root@discuz ~]# mkdir /usr/local/jpeg8/include //建立存放头文件目录
[root@discuz ~]# mkdir -p /usr/local/jpeg8/man/man1 //建立存放手册的目录
step2:configure有点不一样,如下命令行示:
[root@discuz jpeg-8b]# ./configure \
> --prefix=/usr/local/jpeg8/ \
> --enable-share \
> --enable-static
在安装GD2库配置时,可以在configure命令的选项中加上“--with-jpeg=/usr/local/jpeg8”选项,
指定jpeg8库文件的位置。安装PHP时也要指定该库文件的位置。


安装freetype最新库文件
step1:进入软件源码包所在目录/usr/local/src/中,解压软件包freetype-2.4.9到当前目录freetype-2.4.9下,并进入freetype-2.4.9目录。命令行如下:
#cd /usr/local/src/   //进入软件源码包所在目录
#tar zxvf freetype-2.4.9.tar.gz  //解压包到freetype-2.4.9目录 
#cd freetype-2.4.9 //进入目录freetype-2.4.9中
step2:使用configure命令检查并配置安装需要的系统环境,并生成安装配置文件。命令行如下:
#./configure --prefix=/usr/local/freetype //选项--prefix=/usr/local/freetype,是在安装时将软件安装到/usr/local/freetype目录下
step3:使用make命令编译源代码文件并生成安装文件,命令行如下:
#make  //对软件源代码文件进行编译
step4:使用make install命令进行安装,命令行如下:
#make install //开始安装freetype库文件
如果安装成功将会在/usr/local/freetype目录下存在bin,include,lib和share四个目录。
并在安装GD2库时,通过configure命令选项中加上“--with-freetype=/usr/local/freetype/”选项,指定freetype库文件位置。


安装atuoconf最新的库文件
其方法与上面安装freetype相同。唯一注意的地方是configure时,不用指定路径。


安装最新的GD库文件
安装方法大致与freetype相同。唯一注意的地方是configure时的路径,命令行如下:
#./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字体库的位置
(注:报错: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
        找到“png.h”改成“/usr/local/libpng/include/png.h”)  
)
如果安装成功会在/usr/local/gd/目录下存在bin、include和lib这三个目录。
在安装PHP5时,通过在configure命令选项中加上“--with-gd=/usr/local/gd”选项,指定GD库文件的位置。


安装新版本的apache服务器
1、卸载apr、apr-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.4.1.tar.gz
(使用浏览器下载)
./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/ && make && make install


下载:http://sourceforge.net/projects/pcre
(使用浏览器下载pcre-8.10)
#unzip -o pcre-8.10.zip
#cd pcre-8.10
#./configure --prefix=/usr/local/pcre
#make
#make install


[root@discuz httpd-2.4.2]# ./configure \
>  --prefix=/usr/local/apache242 \
>  --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 
(报errror:Size of "woid *" is less than size of "long"
解决办法:--with-pcre=/usr/local/pcre/ 去掉
)
#make && make install
安装完成后,进入/usr/local/apache242/目录下,检查是否有以下文件:
bin  build  cgi-bin  error  htdocs  icons  include  logs  man  manual  modules
启动Apache服务器,并查端口是否开启,启动Apache服务器的命令行如下:
#/usr/local/apache242/bin/apachectl start
(出现错误提示:could not reliably determin the server's fully qualified .....)
(解决办法:whereis httpd.conf;进入该目录下,找到ServerName www.example.com:80
在下面加上ServerName localhost:80)
查看端口命令行如下:
#netstat -tnl|grep 80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LIST
测试安装结果,打开浏览器,在地址栏中输入URL为:http://172.30.8.240
如果浏览器中出现It works!则表明Apache服务器可以使用
每种服务器软件都有必要制成开机时自动启动,Apache服务器开机自动启动,只要在“/etc/rc.d/rc.local”文件,加上Apache服务器的启动命令即可。可以直接打开“/etc/rc.d/rc.local”文件,在最后一行写入Apache启动命令,也可以用echo命令追加进去,如下命令行示:
[root@discuz apache242]# echo "/usr/local/apache242/bin/apachectl start" >> /etc/rc.d/rc.local


安装MySQL数据库管理系统
1、增加用户名和用户组
#groupadd mysql
#useradd -g mysql mysql


2、进入源码包使用configure 检查并配置安装需要的系统环境,并生成安装配置文件
#./configure \
>--prefix=/usr/local/mysql \  //将软件安装在/usr/local/mysql目录下
>--with-extra-charsets=all  //在安装mysql时安装所有字符集
(报错:error: No curses/termcap library found
   原因:缺少ncurses安装包
   解决办法:
   下载安装相应软件包
   一、如果你的系统是RedHat系列:
    yum list|grep ncurses
    yum -y install ncurses-devel
    yum install ncurses-devel
   二、如果你的系统是Ubuntu或Debian:
    apt-cache search ncurses
    apt-get install libncurses5-dev
  待安装completed!之后,再./configure,顺利通过,
  然后make && make install,成功安装,一切OK!~~~)
接着#make && make install


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


4、如果还没安装过MySQL,必须创建MySQL授权表。进入到安装目录/usr/local/mysql下,
执行bin目录下的mysql_install_db脚本,用来初始化MySQL数据库的授权表,
其中存储了服务器访问允许。
[root@discuz mysql-5.0.96]#cd /usr/local/mysql
[root@discuz mysql]# bin/mysql_install_db --user=mysql  //创建授权表
如果使用root用户运行上面的命令,应当使用--user选项,选项的值应当与你在第一步
为运行服务器所创建的登录账户(mysql用户)相同。如果用mysql用户登录来运行上面的
命令,可以省略--user选项。用mysql_install_db创建mysql授权表后,需要手动重新启
动服务器。


5、将程序二进制的所有权改为root用户,数据目录的所有权改为运行mysqld程序的mysql用户。如果现在位于安装目录(/usr/local/mysql)下,命令行如下:
[root@discuz mysql]# chown -R root .(注意有点)  //将文件的所有属性改为root用户
[root@discuz mysql]# chown -R mysql var  //将数据目录的所有属性改为mysql用户
[root@discuz mysql]# chgrp -R mysql .  //将组属性改为mysql组


[root@discuz mysql]# ls -l
total 32
drwxr-xr-x 2 root  mysql 4096 May 15 10:41 bin
drwxr-xr-x 3 root  mysql 4096 May 15 10:40 include
drwxr-xr-x 3 root  mysql 4096 May 15 10:40 lib
drwxr-xr-x 2 root  mysql 4096 May 15 10:41 libexec
drwxr-xr-x 9 root  mysql 4096 May 15 10:41 mysql-test
drwxr-xr-x 5 root  mysql 4096 May 15 10:41 share
drwxr-xr-x 5 root  mysql 4096 May 15 10:41 sql-bench
drwx------ 4 mysql mysql 4096 May 15 11:53 var


6、在所需要的东西被安装完成后,应当使用下面的命令启动MySQL服务了,命令行如下:
[root@discuz mysql]#/usr/local/mysql/bin/mysqld_safe --user=mysql &


7、MySQL数据库服务器启动之后,查看一下它的端口3306是否打开,如果看到以下结果
表明mysql服务启动成功。命令行如下
[root@discuz mysql]# netstat -tnl|grep 3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN


8、使用mysqladmin验证服务器在运行中。以下命令提供了简单的测试,可检查服务器是否已经开启并能响应连接。命令行如下:
[root@discuz mysql]# bin/mysqladmin  version
Enter password: 
bin/mysqladmin  Ver 8.41 Distrib 5.0.96, for pc-linux-gnu on i686
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version          5.0.96-log
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /tmp/mysql.sock
Uptime:                 3 hours 31 min 23 sec
Threads: 1  Questions: 1  Slow queries: 0  Opens: 12  Flush tables: 1  Open tables: 6  Queries per second avg: 0.000
[root@discuz mysql]# bin/mysqladmin variables //查看所有mysql参数


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


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


Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.96-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>


10、如果有匿名账户存在,它拥有全部的权限,因此删掉它可以提高安全,在mysql
客户端执行SQL语如下:
mysql> delete from mysql.user where host='localhost' and user='';
Query OK, 1 row affected (0.07 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


11、可以用几种方法为root账户指定密码,我们选择用其中的一种。在mysql客户端
命令行上使用set password指定密码,一定要使用password()函数来加密密码。
例如下面设置localhost域的密码为comsenz。其他域可以使用同样的语句,使用的
SQL语句如下。
mysql> set password for 'root'@'localhost'=password('comsenz');
Query OK, 0 rows affected (0.03 sec)


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


[root@discuz 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
Server version: 5.0.96-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> 


如果想关闭mysql服务器,在命令行使用mysql服务器的mysqladmin命令,通过-u参数给
出mysql数据库管理员用户名root和通过-p参数给出密码,即可关闭mysql服务器。
如下示:
[root@discuz mysql]# bin/mysqladmin -u root -p shutdown
Enter password: 
STOPPING server from pid file /usr/local/mysql/var/discuz.pid
120515 11:45:52  mysqld ended
[1]+  Done                    bin/mysqld_safe --user=mysql
[root@discuz mysql]# 


13、mysql服务器和apache服务器一样也有必要设置为开机自动运行,设置方法进入到mysql源
代码目录/usr/local/src/mysql-5.0.96,将子目录support-files下的mysql.server文件复制
到/etc/rc.d/init.d目录中,并重命名为mysqld,命令行如下。
[root@discuz mysql]# cd /usr/local/src/mysql-5.0.96
[root@discuz mysql-5.0.96]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
修改一下权限
[root@discuz mysql-5.0.96]# chown root.root /etc/rc.d/init.d/mysqld 
[root@discuz mysql-5.0.96]# chmod 755 /etc/rc.d/init.d/mysqld 
[root@discuz mysql-5.0.96]# 
把mysqld添加到chkconfig中
[root@discuz mysql-5.0.96]# chkconfig --add mysqld
在图形和字符集界面下自动启动mysqld
[root@discuz mysql-5.0.96]# chkconfig --level 3 mysqld on
[root@discuz mysql-5.0.96]# chkconfig --level 5 mysqld on
[root@discuz mysql-5.0.96]# 
再使用chkconfig --list命令检查设置
[root@discuz mysql-5.0.96]# chkconfig --list mysqld
mysqld          0:off   1:off   2:on    3:on    4:off    5:on    6:off




安装最新版的PHP模块
进入php-5.4.3源码包编译
[root@discuz php-5.4.3]# ./configure \
> --prefix=/usr/local/php \
> --with-config-file-path=/usr/local/php/etc \
> --with-apxs2=/usr/local/apache242/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


<注:make前下面的问题先解决了>


make
配置时可能会出现下面的错误:
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.4的bug,下面对应的两篇文章有对应的说明:
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 (*data);


我的GD安装在/usr/local/gd2目录下,所以是#vi /usr/local/gd2//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@discuz ~]# cd /usr/local/libpng/lib/
[root@discuz 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这个路径。
然后重新编译安装即可。


安装完成后,需要建立PHP配置文件。在使用configure命令安装配置时使用“--with-config-file-path=/usr/local/php/etc/”选项,指定了配置文件的位置。将源码包下面的php.ini-development 文件复制到/usr/local/php/etc/中,并改名为php.ini即可,如下示:
[root@discuz php-5.4.3]# cp php.ini-development /usr/local/php/etc/php.ini


整合Apache与PHP,上面编译之前,我们使用configure命令安装配置时,使用--with-apxs2=/usr/local/apache242/bin/apxs选项以使Apache 2将PHP作为功能模块使用。但我们还要修改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@discuz php-5.4.3]#/usr/local/apache242/bin/apachectl stop
[root@discuz php-5.4.3]#/usr/local/apache242/bin/apachectl start



测试PHP环境是否可以正常运行,在/usr/local/apache242/htdocs目录下建一个test.php或test.phtml的文件,内容如下示:
<?php
          phpinfo();
?>
打开浏览器,在地址栏输入http://172.30.8.240/test.php来运行该文件,如果出现下图内容,说明LAMP环境安装成功。
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值