LAMP安装

安装apache2。
# cd /home/xiutuo/software/
进入目录/home/xiutuo/software/
# tar -zvxf httpd-2.2.0.tar.gz
解压httpd-2.2.0.tar.gz
# cd httpd-2.2.0
进入httpd-2.2.0目录
# mkdir -p /usr/local/apache2
生成/usr/local/apache2目录
# ./configure --prefix=/usr/local/apache
或者
# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
# make; make install
安装apache
# vi /usr/local/apache/conf/httpd.conf
#ServerName www.example.com:80
在其下增加
ServerName www.xiutuo.com:80

保存退出,现在就这么简单配置apache。

# /usr/local/apache/bin/apachectl -k start
启动apahce,
用浏览器查看http://www.xiutuo.com
,得到it works,说明apache已经配置成功了。
# /usr/local/apache/bin/apachectl -k stop
停止apache。

三:安装mysql
# cd /home/xiutuo/software/
# tar -zvxf mysql-max-5.0.21-linux-i686-glibc23.tar.gz
# mkdir -p /usr/local/mysql (省略也可)
# cp -r mysql-max-5.0.21-linux-i686-glibc23.tar.gz /usr/local/mysql
# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

添加mysql用户及用户组
# groupadd mysql
# useradd -g mysql mysql
修改mysql目录权限
# chown -R root /usr/local/mysql
# chgrp -R mysql /usr/local/mysql
# chown -R mysql /usr/local/mysql/data
生成mysql系统数据库
dao mysql mulu yunxing
# ./scripts/mysql_install_db --user=mysql&
启动mysql服务
# /usr/local/mysql/bin/mysqld_safe --user=mysql&
如出现 Starting mysqld daemon with databases from /usr/local/mysql/data
代表正常启动mysql服务了, 按Ctrl + C 跳出
修改 mysql 的 root 密码
# /usr/local/mysql/bin/mysqladmin -u root -p password "123456"
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

四:安装GD库(让PHP支持GIF,PNG,JPEG)
a.安装 jpeg6
建立目录:
# mkdir -p /usr/local/jpeg6
# mkdir -p /usr/local/jpeg6/bin
# mkdir -p /usr/local/jpeg6/lib
# mkdir -p /usr/local/jpeg6/include
# mkdir -p /usr/local/jpeg6/man
# mkdir -p /usr/local/jpeg6/man1
# mkdir -p /usr/local/jpeg6/man/man1

# cd /home/xiutuo/software/
# tar -zvxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make; make install

b.安装libpng
# cd /home/xiutuo/software/
# tar -zvxf libpng-1.2.8.tar.gz
# cd libpng-1.2.8
# cp scripts/makefile.std makefile
# make; make install

c.安装 freetype
# cd /home/xiutuo/software/
# tar -zvxf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# mkdir -p /usr/local/freetype
# ./configure --prefix=/usr/local/freetype
# make;make install

d.:安装zlib
# cd /home/xiutuo/software/
#tar -zxvf zlib-1.2.3.tar.gz
#cd zlib.1.2.3
# ./configure
# make;make install

e.安装GD库
# cd /home/xiutuo/software/
# tar -zvxf gd-2.0.33.tar.gz
# mkdir -p /usr/local/gd2
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/lib/ --with-zlib=/usr/local/lib/ --with-freetype=/usr/local/freetype/
# make; make install

e.安装Curl库
# cd /home/xiutuo/software/
# tar -zxf curl-7.15.0.tar.gz
# mkdir -p /usr/local/curl
# ./configure --prefix=/usr/local/curl
# make; make install

五:安装php5,php5必须有libxml2支持!
a.安装libxml2
# cd /home/xiutuo/software/
# tar -zxf libxml2-2.6.19.tar.gz
# cd libxml2-2.6.19
# mkdir -p /usr/local/libxml2
# ./configure --prefix=/usr/local/libxml2
# make; make install

b.安装 libxslt(可选安装,你可以不安装)
# cd /home/xiutuo/software/
# tar -zxf libxslt-1.1.15.tar.gz
# mkdir -p /usr/local/libxslt
# cd libxslt-1.1.15
# ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
# make; make install

c.安装php5
# cd /home/xiutuo/software/
# tar -zvxf php-5.1.2.tar.gz
# mkdir -p /usr/local/php
# cd php-5.05
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql-dir=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-png=/usr/local/lib --with-zlib-dir=/usr/lib/ --with-freetype-dir=/usr/local/freetype --with-curl=/usr/local/curl/ --enable-ftp --enable-soap --with-xsl=/usr/local/libxslt --enable-xslt --enable-sockets --enable-mbstring
# make
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini (别忘记了呵呵)

其中./configure 后的
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql/
--with-libxml-dir=/usr/local/libxml2
是必要的选项

--with-gd=/usr/local/gd2/
--with-jpeg-dir=/usr/local/jpeg6/
--with-png=/usr/local/lib
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype
这是让PHP支持GD库的配置选项

--with-curl=/usr/local/curl 支持CURL库
--enable-ftp 打开FTP库函数支持

--enable-soap --with-xsl=/usr/local/libxslt --enable-xslt
让PHP支持SOAP, 上面这些一般用得少, 可以去掉

 

六:重新配置apache2让他支持php。

配置 httpd.conf 让apache支持PHP
# vi /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

重启apache
# /usr/local/apache/bin/apachectl restart
在htdocs目录里建一内容为 PHP文件, 输入URL地址查看PHP配置是否正确

ok,web环境apache2+mysql5+php5就介绍到这里。
更详细的apache2的配置和mysql配置和php.ini的配置参考相应文档。
--------------------------------------------------------
安装时候遇到的问题:

由于本人的系统是redhat9,自定义安装了php,mysql,apache。
所以在安装最新的php,mysql,apache版本时候,本人对相关的rpm进行了
卸载,忽略依赖关系强制卸载apache;由于php,mysql与perl的bt依赖关系,
一气之下删除了所有的相关文件。

问题

1.当你看到mysql有很多版本,如:
mysql-max-5.0.21-linux-i686-glibc23.tar.gz和
mysql-max-5.0.21-linux-i686.tar.gz
这俩个到底选哪个呢,请你使用如下命令来决定
# rpm -qa | grep glibc
glibc-kernheaders-2.4-8.10
glibc-common-2.3.2-11.9
glibc-2.3.2-11.9
glibc-devel-2.3.2-11.9
如果出现以上信息,请选择mysql-max-5.0.21-linux-i686-glibc23.tar.gz版本

2:编译php时出现

./configure: /usr/local/apache2/bin/apxs: /replace/with/path/to/perl/interpreter:
bad interpreter: No such file or directory
这是找不到perl解释器的缘故。
修改/usr/local/apache2/bin/apxs文件中:
/replace/with/path/to/perl/interpreter
把他替换成perl所在的路径如/opt/ActivePerl-5.8/bin/perl,
(如果你下载的是active perl5.8的rpm,他默认安装路径是/opt/ActivePerl-5.8/bin/perl)

3.安装了perl后,发现所有的文本编辑器都不能用了。
运行vi或者gedit时候,提示找不到libperl.so
到perl的安装目录下找一个libperl.so放到/usr/lib目录下就解决问题了
我的libperl.so在/opt/ActivePerl-5.8/lib/5.8.8/i686-linux-thread-multi-CORE/目录下。
如果不知道libperl.so在什么地方,可以用
# locate libperl.so
查找,或者用find命令

4.当我使用mysql-standard-5.0.20,编译php时出现mysql错误:

checking for mSQL support... no
checking for MSSQL support via FreeTDS... no
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... /tmp/mysql.sock
checking for mysql_close in -lmysqlclient... no
checking for mysql_error in -lmysqlclient... no
configure: error: mysql configure failed. Please check config.log for more information.

网查找说:安装PHP的时候没有指定一下mysql的安装目录。但是我已经指定了,所以这个说法是错误的,其实主要原因是 mysql-level没有装,也就是mysql的版本不对,应该换
mysql-max-5.0.21版本(包含所有mysql相关内容的软件包)

5.编译php时出现
configure: error: freetype2 not found!
没有安装freetype-level

configure: error: libpng.(a|so) not found.
没有安装libpng-devel

6忘了mysql的root口令怎么办
# /usr/local/mysql/support-files/mysql.server stop
# cd /usr/local/mysql/bin/
# mysqld_safe --skip-grant-tables &
# mysqladmin -u user password 'newpassword'
# mysqladmin flush-privileges

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

#!/bin/sh

# http://lfs.linuxsir.org/htdocs/blfscvs/general/libxslt.html

# http://curl.haxx.se/

 

#- a.安装 jpeg6
#- 建立目录:
mkdir -p /usr/local/jpeg6
mkdir -p /usr/local/jpeg6/bin
mkdir -p /usr/local/jpeg6/lib
mkdir -p /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man
mkdir -p /usr/local/jpeg6/man1
mkdir -p /usr/local/jpeg6/man/man1

cd jpeg-6b
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make; make install

#-----------------------------------------------------
#- b.install libpng
cd ../libpng
cp scripts/makefile.std makefile
make; make install

#-----------------------------------------------------
#- c.install freetype
cd ../freetype
mkdir -p /usr/local/freetype
./configure --prefix=/usr/local/freetype
make;make install

#-----------------------------------------------------
#- d.:install zlib
cd ../zlib
./configure
make;make install

#-----------------------------------------------------
#- e.install gd lib
mkdir -p /usr/local/gd2
cd ../gd2
./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/lib/ --with-zlib=/usr/local/lib/ --with-freetype=/usr/local/freetype/
make; make install

#- install cUrl lib
mkdir -p /usr/local/curl
cd ../curl
./configure --prefix=/usr/local/curl
make; make install

#- a.install libxml2
cd ../libxml2
mkdir -p /usr/local/libxml2
./configure --prefix=/usr/local/libxml2
make; make install

#- b.install libxslt
mkdir -p /usr/local/libxslt
cd ../libxslt
./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
make; make install

#- install php5
mkdir -p /usr/local/php
cd ../php
./configure --prefix=/usr/local/php --with-apxs2=/usr/sbin/apxs --with-mysql-dir=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-png=/usr/local/lib --with-zlib-dir=/usr/lib/ --with-freetype-dir=/usr/local/freetype --with-curl=/usr/local/curl/ --enable-ftp --enable-soap --with-xsl=/usr/local/libxslt --enable-xslt --enable-sockets --enable-mbstring
make
make install
#- cp php.ini-dist /usr/local/php/lib/php.ini (别忘记了呵呵)

此条目发表在article分类目录,贴了标签。将固定链接加入收藏夹。