LAMP安装手册

运维 系统运维
Linux下安装LAMP:LAMP的意思是Linux、Apache、Mysql、PHP/Perl/Python,它是用来搭建动态网站或者服务器的一组组合软件。本身具有独立的几种程序,由于共同的功能组合在一起,形成高度兼容web应用平台。本文讲述的是Linux下安装LAMP

  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

  把以上所有软件包下载到: /root/Software/ 目录下 .

#p#

  二:安装 mysql

  1.   # tar -zvxf mysql-5.0.45-linux-i686-glibc23.tar.gz  
  2.  
  3.   # mkdir -p /usr/local/mysql  
  4.  
  5.   # cp -r mysql-5.0.45 /usr/local/mysql  
  6.  
  7.   # cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql // 开机启动 mysql  
  8.  
  9.   # cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf  
  10.  

  添加 mysql 用户及用户组

  1.   # groupadd mysql  
  2.  
  3.   # useradd -g mysql mysql  
  4.  

  修改 mysql 目录权限

  1.   # chown -R root /usr/local/mysql  
  2.  
  3.   # chgrp -R mysql /usr/local/mysql  
  4.  
  5.   # chown -R mysql /usr/local/mysql/data  
  6.  

  生成 mysql 系统数据库

  1.   # /usr/local/mysql/scripts/mysql_install_db --user=mysql& // 启动 mysql 服务  
  2.  
  3.   # /usr/local/mysql/bin/mysqld_safe --user=mysql&  
  4.  

  如出现 Starting mysqld daemon with databases from /usr/local/mysql/data 代表正常启动 mysql 服务了 .

  按 Ctrl + C 跳出修改 mysql 的 root 密码

  1.   # /usr/local/mysql/bin/mysqladmin -u root -p password "123456"  
  2.  

#p#

  三:安装 GD 库 ( 让 PHP 支持 GIF,PNG,JPEG)

  a. 安装 jpeg6 建立目录:

  1.   # mkdir -p /usr/local/jpeg6  
  2.  
  3.   # mkdir -p /usr/local/jpeg6/bin  
  4.  
  5.   # mkdir -p /usr/local/jpeg6/lib  
  6.  
  7.   # mkdir -p /usr/local/jpeg6/include  
  8.  
  9.   # mkdir -p /usr/local/jpeg6/man  
  10.  
  11.   # mkdir -p /usr/local/jpeg6/man1  
  12.  
  13.   # mkdir -p /usr/local/jpeg6/man/man1  
  14.  
  15.   # cd /root/Software/  
  16.  
  17.   # tar -zvxf jpegsrc.v6b.tar.gz  
  18.  
  19.   # cd jpeg6  
  20.  
  21.   # ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static  
  22.  
  23.   # make  
  24.  
  25.   # make install  
  26.  

  b.libpng 包 ( 支持 PNG)

  1.   # cd /root/Software/  
  2.  
  3.   # tar -zvxf libpng-(version).tar.gz  
  4.  
  5.   # cd libpng-(version)  
  6.  
  7.   # ./configure --prefix=/usr/local/libpng  
  8.  
  9.   # make  
  10.  
  11.   #> make install  
  12.  

  c. 安装 freetype

  1.   # cd /root/Software/  
  2.  
  3.   # tar -zvxf freetype-(version).tar.gz  
  4.  
  5.   # cd freetype-(version)  
  6.  
  7.   # mkdir -p /usr/local/freetype  
  8.  
  9.   # ./configure --prefix=/usr/local/freetype  
  10.  
  11.   # make  
  12.  
  13.   # make install  
  14.  

  d. 安装 zlib

  1.   # cd /root/Software/  
  2.  
  3.   # tar -zxvf zlib-1.2.3.tar.gz  
  4.  
  5.   # cd zlib.1.2.3  
  6.  
  7.   # mkdir /usr/local/zlib  
  8.  
  9.   # ./configure --prefix=/usr/local/zlib  
  10.  
  11.   # make  
  12.  
  13.   # make install  
  14.  

  e. 安装 GD 库

  1.   # cd /root/Software/  
  2.  
  3.   # tar -zvxf gd-(version).tar.gz  
  4.  
  5.   # mkdir -p /usr/local/gd2  
  6.  
  7.   # cd gd-(version)  
  8.  
  9.   # ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-zlib-dir=/usr/local/zlib --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype  
  10.  
  11.   # make  
  12.  
  13.   # make install  
  14.  

  e. 安装 Curl 库

  1.   # cd /root/Software/  
  2.  
  3.   # tar -zxf curl-(version).tar.gz  
  4.  
  5.   # mkdir -p /usr/local/curl  
  6.  
  7.   # ./configure --prefix=/usr/local/curl  
  8.  
  9.   # make  
  10.  
  11.   # make install  
  12.  

#p#

  四:安装 apache2

  1.   # cd /roo/Software/  
  2.  
  3.   # tar -zvxf httpd-2.2.6.tar.gz  
  4.  
  5.   # cd httpd-2.2.6  
  6.  
  7.   # mkdir -p /usr/local/apache2  
  8.  
  9.   # ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite  
  10.  
  11.   # make  
  12.  
  13.   # make install  
  14.  
  15.   # /usr/local/apache2/bin/apachectl -k start // 启动 apahce  
  16.  

  用浏览器查看 http://localhost, 得到 it works ,说明 apache 已经配置成功了 .

  1.   # /usr/local/apache2/bin/apachectl -k stop // 停止 apache  
  2.  

#p#

  五:安装 php5

    php5 必须有 libxml2 支持 !

  a. 安装 libxml2

  1.   # cd /root/Software/  
  2.  
  3.   # tar -zvxf libxml2-(version).tar.gz  
  4.  
  5.   # cd libxml2-(version)  
  6.  
  7.   # mkdir -p /usr/local/libxml2  
  8.  
  9.   # ./configure --prefix=/usr/local/libxml2  
  10.  
  11.   # make  
  12.  
  13.   # make install  
  14.  

  b. 安装 libxslt ( 可选安装,你可以不安装 )

  1.   # cd /root/Software/  
  2.  
  3.   # tar -zvxf libxslt-(version).tar.gz  
  4.  
  5.   # mkdir -p /usr/local/libxslt  
  6.  
  7.   # cd libxslt-(version)  
  8.  
  9.   # ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2  
  10.  
  11.   # make  
  12.  
  13.   # make install  
  14.  

  c. 安装 php5

  1.   # cd /root/Software/  
  2.  
  3.   # tar -zvxf php-(version).tar.gz  
  4.  
  5.   # mkdir -p /usr/local/php5  
  6.  
  7.   # cd php-(version)  
  8.  
  9.   # ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs \  
  10.  
  1.   >--with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg6 \  
  2.  
  3.   >--with-zlib-dir=/usr/local/zlib \  
  4.  
  5.   >--with-png-dir=/usr/local/libpng \  
  6.  
  7.   >--with-freetype-dir=/usr/local/freetype -\  
  8.  
  9.   >--enable-trace-vars --with-mysql=/usr/local/mysql \  
  10.  
  11.   >--enable-mbstring=all --with-curl=/usr/local/curl --enable-mbregex \  
  12.  
  13.   >--with-config-file-path=/usr/local/php5 --enable-ftp \  
  14.  
  15.   >--enable-soap --with-xsl=/usr/local/libxslt  
  16.  
  17.   # make  
  18.  
  19.   # make install  
  20.  
  21.   # cp php.ini-dist /usr/local/php5/php.ini   

#p#

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

  1.   # cd /usr/local/apache2/conf  
  2.  
  3.   # vim httpd.conf  
  4.  
  5.   在 LoadModule php5_module modules/libphp5.so  
  6.  

  添加 AddType application/x-httpd-php .php

  OK, 基本的安装已经完成 .

  重新起动 APACHE:

  1.   # /usr/local/apache2/bin/apachectl start  
  2.  

  如果重新起动 APACHE 出现 :

  1.   Syntax error on line 232 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server:  
  2.  
  3.   /usr/local/apache2/modules/libphp4.so: cannot restore segment prot after reloc: Permission denied  
  4.  

  那就要按照下面的方法解决 :

  1.chcon -t texrel_shlib_t /usr/local/apache2/modules/*.so

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

  1.   # This file controls the state of SELinux on the system.  
  2.  
  3.   # SELINUXcan take one of these three values:  
  4.  
  5.   # enforcing - SELinux security policy is enforced.  
  6.  
  7.   # permissive - SELinux prints warnings instead of enforcing.  
  8.  
  9.   # disabled - SELinux is fully disabled.  
  10.  
  11.   SELINUX=enforcing 
  12.  

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

  SELINUX=disabled

  保存,关闭。

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

  1.   # This file controls the state of SELinux on the system.  
  2.  
  3.   # SELINUXcan take one of these three values:  
  4.  
  5.   # enforcing - SELinux security policy is enforced.  
  6.  
  7.   # permissive - SELinux prints warnings instead of enforcing.  
  8.  
  9.   # disabled - SELinux is fully disabled.  
  10.  
  11.   SELINUX=enforcing 
  12.  

  如果 SELINUX 已经是 SELINUX=disabled ,那么就不用改了,否则就把 SELINUX=enforcing 注释掉,新加一行:

  1.   SELINUX=disabled 
  2.  

  保存,退出。

【编辑推荐】

  1. LAMP技术精解
  2. Red Hat下安装LAMP的过程
  3. 使用CentOS源安装LAMP全过程

 

责任编辑:zhaolei 来源: javaeye
相关推荐

2011-03-21 16:30:42

CentOSLAMP

2011-03-22 10:17:22

LAMP

2011-03-31 13:40:33

安装LAMP

2011-03-11 13:58:54

2011-03-23 15:55:41

LAMP

2011-03-14 13:07:23

Ubuntu安装LAMP

2011-03-10 09:31:02

LAMP安装

2011-03-29 14:44:24

LAMP安装

2011-03-09 09:30:45

Linux安装LAMP

2011-03-11 17:14:27

2011-03-31 15:06:12

lampcacti

2011-01-20 09:08:01

Postfixadmi

2011-03-10 08:59:04

Ubuntu安装LAMP

2011-03-10 15:44:18

CentOSLAMP安装

2011-03-10 15:44:18

CentOSLAMP安装

2011-03-11 16:42:38

Ubuntu安装LAMP

2011-03-21 11:08:15

LAMPMySQL

2011-03-10 09:53:35

LinuxLAMP安装

2011-03-21 10:15:07

LAMPLAMP安装LAMP配置

2011-03-09 14:27:25

点赞
收藏

51CTO技术栈公众号