LAMP安装手册
    主要软件包,
1. httpd-2.2.6.tar.gz
2. mysql-5.0.45-linux-i686-glibc23.tar.gz ( 这个版本是已编译好的压缩包,解压后稍做配置即可使用 )
3. php-5.2.5.tar.gz
 
安装 php 所需的软件包(其中 libxml2 是安装 php5 必须的 .
1. libxml2-(version).tar.gz ---> http://ftp.gnome.org/pub/GNOME/sources/libxm2
2. libxslt-(version).tar.gz ---> http://ftp.gnome.org/pub/GNOME/sources/libxslt
3. curl-(version).tar.gz   ---> http://curl.haxx.se/download
 
GD 库所需要软件包(有人说 PHP 源码包里自带了 GD2.0.28 zlib ,只要安装 GD 的三个支持包: jpg,png freetype ,但是我们还是下载)
1. gd-(version).tar.gz     ---> http://www.libgd.org/Main_Page or http://www.libgd.org/releases/
2. freetype-(version).tar.gz ---> http://sourceforge.net/projects/freetype
3. jpegsrc.v6b.tar.gz     ---> http://ijg.org/files/jpegsrc.v6b.tar.gz
4. libpng-(version).tar.gz   ---> http://www.libpng.org/pub/png/libpng.html
5. zlib-1.2.3.tar.gz       ---> http://www.zlib.net
6. gettext-0.18.1.1.tar.gz     --->http://www.gnu.org/software/gettext/#TOCdownloading
 
把以上所有软件包下载到: /tmp/lamp/ 目录下 .
 
二:安装 mysql
 
#wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
# tar xvzf cmake-2.8.4.tar.gz
# ./configure 
# make & make install
#tar xvfz mysql-5.5.9.tar.gz
#cd mysql-5.5.9
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql5.5.9/data/mysql.sock
# gmake
# gmake install
# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql // 开机启动 mysql
# cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf
#vi /etc/my.cnf #将数据目录和套接字文件修改为实际值.
 
添加 mysql 用户及用户组
# groupadd mysql
# useradd -r -g mysql mysql
修改 mysql 目录权限
# chown mysql:mysql /etc/my.cnf
# chown -R mysql:mysql /usr/local/mysql
#chown -R mysql:mysql /usr/local/mysql/
# chgrp -R mysql /usr/local/mysql
生成 mysql 系统数据库
# /usr/local/mysql/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"
添加mysql开机自启动
 #cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
 #chmod +x /etc/init.d/mysql
 #chkconfig --add mysql
测试
 # cd /usr/local/mysql/bin/mysqlshow
 如果可以看到数据说明mysql已经自启动了,现在你可以在终端使用service mysql stop来停止mysql服务,使用service mysql start 来启动mysql服务
 /usr/local/mysql/bin/mysqladmin --help(功能很多)
 
 
三:安装 GD ( PHP 支持 GIF,PNG,JPEG)
a. 安装 jpeg6 建立目录:
 
# cd /root/Software/
# tar -zvxf jpegsrc.v6b.tar.gz
# cd jpeg6
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make
# make install
 
b.libpng ( 支持 PNG)
# cd /root/Software/
# tar -zvxf libpng-(version).tar.gz
# cd libpng-(version)
# ./configure --prefix=/usr/local/libpng
# make
#> make install
 
c. 安装 freetype
# cd /root/Software/
# tar -zvxf freetype-(version).tar.gz
# cd freetype-(version)
# mkdir -p /usr/local/freetype
# ./configure --prefix=/usr/local/freetype
# make
# make install
 
d. 安装 zlib
# cd /root/Software/
# tar -zxvf zlib-1.2.3.tar.gz
# cd zlib.1.2.3
# mkdir /usr/local/zlib
# ./configure --prefix=/usr/local/zlib
# make
# make install
 
e.安装gettext
#cd /root/Software/
#tar -zxvf gettext-0.18.1.1.tar.gz
#cd gettext-0.18.1.1
#./configure
#make
#make install
 
f. 安装 GD
# cd /root/Software/
# tar -zvxf gd-(version).tar.gz
# mkdir -p /usr/local/gd2
# cd gd-(version)
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-zlib=/usr/local/zlib --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
# make
# make install
在编译gd-*.tar.gz时报错:gd_png.c:16:53: error: png.h: No such file or directory2011-03-04 21:40编译gd-2.0.35.tar.gz时报错:
解决办法: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 */
 
g. 安装 Curl
# cd /root/Software/
# tar -zxf curl-(version).tar.gz
# mkdir -p /usr/local/curl
# ./configure --prefix=/usr/local/curl
# make
# make install
 
四:安装 apache2
# cd /roo/Software/
# tar -zvxf httpd-2.2.6.tar.gz
# cd httpd-2.2.6
# mkdir -p /usr/local/apache2
# ./configure --prefix=/usr/local/apache2 --enable-modules=so --enable-rewrite
# make
# make install
# /usr/local/apache2/bin/apachectl -k start // 启动 apahce
用浏览器查看 http://localhost, 得到 it works ,说明 apache 已经配置成功了 .
# /usr/local/apache2/bin/apachectl -k stop // 停止 apache
 
五:安装 php5 php5 必须有 libxml2 支持 !
a. 安装 libxml2
# cd /root/Software/
# tar -zvxf libxml2-(version).tar.gz
# cd libxml2-(version)
# mkdir -p /usr/local/libxml2
# ./configure --prefix=/usr/local/libxml2
# make
# make install
 
b. 安装 libxslt ( 可选安装,你可以不安装 )
# cd /root/Software/
# tar -zvxf libxslt-(version).tar.gz
# mkdir -p /usr/local/libxslt
# cd libxslt-(version)
# ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
# make
# make install
 
c. 安装 php5
# cd /root/Software/
# tar -zvxf php-(version).tar.gz
# mkdir -p /usr/local/php5
# cd php-(version)
# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs \
--with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg8 \
--with-zlib-dir=/usr/local/zlib \
--with-png-dir=/usr/local/libpng \
--with-freetype-dir=/usr/local/freetype \
--with-mysql=/usr/local/mysql \
--enable-mbstring=all --with-curl=/usr/local/curl --enable-mbregex \
--with-config-file-path=/usr/local/php5 --enable-ftp \
--enable-soap --with-xsl=/usr/local/libxslt
选项--with-mysql的作用非常重要,如果不加这个,以后在使用web管理工具postfixadmin时将出现不能连接数据库的错误。  --with-apxs2的作用是与 apache的工具apxs配合,产生模块文件到目录/usr/local/apache/modules/,同时在apache的配置文件中写入一行 "LoadModule php5_module        modules/libphp5.so";
# make
# make install
#cp php.ini-development /usr/local/lib/php.ini
    or
 #cp php.ini-production  /usr/local/lib/php.ini
((((((((# cp php.ini-dist /usr/local/php5/php.ini (新版的php没这个东东了) ))))))))))
 
六:重新配置 apache2 让他支持 php
 
# cd /usr/local/apache2/conf
# vi httpd.conf
LoadModule php5_module modules/libphp5.so
添加 AddType application/x-httpd-php .php
OK, 基本的安装已经完成 .
在目录/usr/local/apache/htdocs下创建一个最简单的php测试文件,其内容为:
vi test.php
<?
phpinfo();
?>
重新起动 APACHE:
# /usr/local/apache2/bin/apachectl start
((((((如果重新起动 APACHE 出现 :
Syntax error on line 232 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server:
/usr/local/apache2/modules/libphp4.so: cannot restore segment prot after reloc: Permission denied
那就要按照下面的方法解决  
1.chcon -t texrel_shlib_t /usr/local/apache2/modules/*.so  
2. 编辑 /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
保存,退出。 )))))))))
 

(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
毫无疑问,是权限拒绝,但之前为什么是好的呢

突然发现当前运行的账号是普通账号,而非管理员,这难怪,普通账号默认无权启动监听80端口的,su一下,输入密码,很顺利的正常启动了,当然这一行错误还是有的: