益友网(http://www.1uu2.com) 做linux用户的良师益友、linux操作系统命令教程

当前位置: 益友网 > Linux服务器 > 文章正文

LAMP安装指南 LSUN

发表于 2010-03-26 23:22 | 来源: | 阅读 5,029 次

一、简介

使用LAMP(Linux + Apache + MySQL + PHP)来搭建中等级别的应用(尤其是电子商务)已经是一种流行的方式,因为全部是开源

和免费的软件,所以成本非常低廉。在搭建平台时,也可以直接使用RPM 包来安装,但是由于使用RPM 包在一些系统上不支持,因此我们使用

更通用的方法:直接从源代码来装。

Apache 是世界排名第一的Web 服务器, 根据Netcraf(www.netsraft.co.uk)所作的调查,世界上百分之五十以上的Web 服务器在使用Apache。

尤其是现在,使用LAMP(Linux + Apache + MySQL + PHP)来搭建中等级别的应用已经是一种流行的方式,因此,掌握Apache 的配置是系统工

程师必备的技能之一。

Apache 的特性:

1) 几乎可以运行在所有的计算机平台上.

2) 支持最新的HTTP/1.1 协议

3) 简单而且强有力的基于文件的配置(HTTPD.CONF)

4) 支持通用网关接口(CGI)

5) 支持虚拟主机.

6) 支持HTTP 认证.

7) 集成PERL.

8) 集成的代理服务器

9) 可以通过WEB 浏览器监视服务器的状态, 可以自定义日志.

10) 支持服务器端包含命令(SSI).

11) 支持安全SOCKET 层(SSL).

12) 具有用户会话过程的跟踪能力.

13) 支持FASTCGI

14) 支持JAVA SERVLETS.

***************************************************************************************************
rhel4 as中selinux默认是开启的,安装mysql时会造成初始化数据失败,应先关闭。
RHEL4上关掉SELinux的正确方法为:修改/etc/selinux/config文件中的SELINUX=”" 为 disabled,然后reboot。
***************************************************************************************************

二、相关信息

1.系统:

Red Hat Enterprise Linux AS release 4 (Nahant Update 5)

ip: 121.10.106.179

域名:http://www.linuxsun.cn

2.软件列表:

├─rar
│      apr-1.2.7.tar.gz
│      apr-util-1.2.7.tar.gz
│      cacti-cactid-0.8.6k.zip
│      Discuz6.0.0-UTF8.zip
│      Discuz_6.1.0_SC_GBK.zip
│      freetype-2.1.10.tar.bz2
│      freetype-2.2.1.tar.gz
│      gd-2.0.33.tar.gz
│      gd-2.0.35.tar.gz
│      GD-2.32.tar.gz
│      GD-2.41.tar.tar
│      httpd-2.2.10.tar.bz2
│      httpd-2.2.10.tar.gz
│      httpd-2.2.4.tar.gz
│      httpd-2.2.9.tar.bz2
│      jpegsrc.v6b.tar.gz
│      LAMP-conf.zip
│      libiconv-1.10.tar.gz
│      libiconv-1.9.2.tar.gz
│      libpng-1.2.10.tar.bz2
│      libpng-1.2.35.tar.gz
│      libxml-1.8.17.tar.gz
│      libxml2-2.6.24.tar.bz2
│      libXpm-3.5.5.tar.tar
│      libxslt-1.1.15.tar.bz2
│      mysql-4.0.26.tar.gz
│      mysql-5.0.26.tar.gz
│      mysql-5.0.40.tar.gz
│      mysql-5.1.30-linux-i686-icc-glibc23.tar.gz
│      mysql-5.1.30.tar.gz
│      MySQLBackup-v1.0.tar.gz
│      openssl-0.9.8e.tar.gz
│      php-4.4.9.tar.bz2
│      php-5.2.4.tar.gz
│      php-5.2.6.tar.bz2
│      phpMyAdmin-3.0.1.1-all-languages.tar.bz2
│      phpmyadmin-config.rar
│      re2c-0.9.11.rc1.tar.gz
│      soft.tar.gz
│      UCenter_1.0.0_SC_GBK.zip
│      ZendOptimizer-3.0.0-freebsd6.0-i386.tar.gz
│      ZendOptimizer-3.0.0-linux-glibc21-i386.tar.gz
│      ZendOptimizer-3.0.0-linux-glibc23-x86_64.tar.gz
│      ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
│      数据库镜像相关文档.rar

├─sh

ftp下载地址:ftp://121.10.106.179

帐号:linuxsun

密码:linuxsun.cn

http下载地址:http://ftp.linuxsun.cn:8080/

三、安装步骤:

1.mysql

tat -zxvf mysql-5.0.40.tar.gz

cd mysql-5.0.40.
./configure –localstatedir=/date/mysql –prefix=/usr/local/mysql–with-charset=gb2312 –with-extra-charsets=all–enable-thread-safe-client –with-mysql-server –with-libdbi-dbd-mysql–with-DBD-mysql –with-big-tables

make

make install

确认安装过程没有错误,如果出错可以试下./configure 的一些非必选项去掉再编译安装。

数据库初始化
/usr/local/mysql/bin/mysql_install_db –user=mysql

创建mysql用户,并复制mysql配置文件

useradd -M -o -r -d /var/lib/mysql -s /bin/bash -c “MySQL Server” -u 27 mysql
cp /usr/local/mysql/share/mysql/my-large.cnf /etc/my.cnf

将数据库的所有者和所有组为mysql

chown -R mysql:mysql /var/lib/mysql

创建mysqld服务

cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
chkconfig –add mysqld
service mysqld start

将mysql的root用户密码改为yourpasswd

/usr/local/mysql/bin/mysqladmin -uroot password yourpasswd

详细可以看解压包下的帮助文档:

[root@localhost mysql-5.0.40]# more INSTALL-SOURCE

2.          openssl-0.9.8e.tar.gz

tar -zxvf openssl-0.9.8e.tar.gz

cd openssl-0.9.8e
./config –prefix=/usr/local/openssl –shared
make&make install

find /usr/local/openssl/include/openssl/”.h .a”  in NO
cp -r –prefix=/” /openssl/include/openssl/*.h *.a” /usr/local/openssl/include/openssl/
ln –s /usr/local/openssl/lib/libcrypto.so.0.9.8 /lib/libcrypto.so.4
ln –s /usr/local/openssl/lib/libcrypto.so.0.9.8 /lib/libcrypto.so
ln –s /usr/local/openssl/lib/libssl.so.0.9.8 /lib/libssl.so
ln –s /usr/local/openssl/lib/libssl.so.0.9.8 /lib/libssl.so.4
echo /usr/local/openssl/lib >> /etc/ld.so.conf
ldconfig –v
/etc/init.d/sshd restart
ssh -v or openssl version

3.        apr-1.2.7.tar.gz  apr-util-1.2.7.tar.gz

tar -zxvf apr-1.2.7.tar.gz
cd apr-1.2.7
./configure –prefix=/usr/local/apr –enable-threads –enable-other-child USE=ipv6
make && make install

cd ../apr-util
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr/ –with-mysql=/usr/local/mysql
make && make install

4.         httpd-2.2.10.tar.bz2

tar -zxvf httpd-2.2.10.tar.bz2

cd httpd-2.2.10

./configure –prefix=/usr/local/apache –enable-mods-shared=all–enable-deflate=shared –enable-suexec–with-mpm=worker  –with-mysql=/usr/local/mysql–with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util

make

make install

vi /usr/local/apache/conf/httpd.conf
查找 AddType application/x-tar .tgz  做如下修改:

AddType application/x-tar .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php-source .phps

查找 “DirectoryIndex” 做如下修改:

DirectoryIndex index.html index.html.var index.php

:wq  #保存退出vi

/usr/local/apache/bin/apachectl start

[root@localhost httpd-2.2.10]# netstat -na |grep LISTEN

tcp        0      0 :::80                       :::*                        LISTEN

apache以经正常启动了。

5.              jpegsrc.v6b.tar.gz

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
tar -zvxf jpegsrc.v6b.tar.gz

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

6.                  libpng-1.2.10.tar.bz2

tar -jxvf libpng-1.2.10.tar.bz2
cd libpng-1.2.10
./configure –prefix=/usr/local/libpng
cp scripts/makefile.std makefile
make
make install

7.           gd-2.0.35.tar.gz

tar zxvf gd-2.0.35.tar.gz

cd gd-2.0.35

./configure –prefix=/usr/local/gd2 –with-jpeg=/usr/local/jpeg6 –with-png=/usr/local/libpng –with-zlib=/usr/local/lib/
make; make install

8.           libxml2-2.6.24.tar.bz2

tar -jxvf libxml2-2.6.24.tar.bz2

# cd libxml2-2.6.24
# ./configure –prefix=/usr/local/libxml2
# make && make install

9.             libxslt-1.1.15.tar.bz2

tar jxvf libxslt-1.1.15.tar.bz2

cd libxslt-1.1.15

./configure –prefix=/usr/local/libxslt –with-libxml-prefix=/usr/local/libxml2
make; make install

10.          freetype-2.1.10.tar.bz2

tar jxvf freetype-2.1.10.tar.bz2

cd freetype-2.1.10

./configure –prefix=/usr/local/freetype

make && make install

11.         php-5.2.6.tar.bz2

tar jxvf php-5.2.6.tar.bz2

cd php-5.2.6

./configure –prefix=/usr/local/php–with-apxs2=/usr/local/apache/bin/apxs –with-mysql=/usr/local/mysql–with-libxml-dir=/usr/local/libxml2 –with-jpeg-dir=/usr/local/jpeg6–with-png-dir=/usr/local/libpng –with-gd=/usr/local/gd2–with-zlib-dir=/usr/local/zlib –enable-ftp –enable-soap–enable-snmp –enable-mbstring –enable-sockets–with-xsl=/usr/local/libxslt –with-freetype-dir=/usr/local/freetype

提示如下:

creating main/internal_functions_cli.c
+——————————————————————–+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+——————————————————————–+

Thank you for using PHP.

Notice: Following unknown configure options were used:

–enable-snmp

Check ‘./configure –help’ for available options

#这里要确认下libpng gpeg 等等都被正确支持。”–enable-snmp”这个影响不,删掉再编译过.

make

make install

cp php.ini-dist /usr/local/php/lib/php.ini #要记得路径到时候安装ZendOptimizer-3.0.0-linux-glibc21-i386.tar.gz要用到

12.         写个test.php放到apache的目录:

vi /usr/local/apachectl/htdocs/test.php

<?php
phpinfo();
?>

:wq #保存退出

chown -R daemon:daemon /usr/local/apache/htocs

chmod -R 777 /usr/local/apache/htdocs

http://121.10.106.179:8080/test.php

调整下权限,可以看到成果了。 ^O^

想方便的管理mysql还要做些调整:

13.          phpMyAdmin-3.0.1.1-all-languages.tar.bz2

tar -jxvf phpMyAdmin-3.0.1.1-all-languages.tar.bz2 -C /usr/local/apache/htdocs

cd /usr/local/apache/htdocs

mv -f phpMyAdmin-3.0.1.1-all-languages phpmyadmin

chown -R daemon:daemon /usr/local/apache/htocs

chmod -R 777 /usr/local/apache/htdocs

vi config.inc.php

$cfg['Servers'][$i]['auth_type'] = ‘config’; 将config 改为 http

:wq #保存退出

http://121.10.106.179:8080/phpmyadmin

14.         ZendOptimizer-3.0.0-linux-glibc21-i386.tar.gz

tar -zxvf ZendOptimizer-3.0.0-linux-glibc21-i386.tar.gz

cd ZendOptimizer-3.0.0-linux-glibc21-i386

./install.sh

Zend Optimizer Installation
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq

lqqqqqqqqqqqqqqqqqqqq Zend Optimizer 3.3.0a qqqqqqqqqqqqqqqqqqqqk
x                                                               x
x Welcome to the Zend Optimizer 3.3.0a Installation!            x
x                                                               x
x For more information regarding this procedure, please see the x
x Zend Optimizer Installation Guide.                            x
x                                                               x
x                                                               x
tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu
x                           <  OK  >                            x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

……

四、结束

参考资料:

http://www.linuxsun.cn

http://bbs.linuxsun.cn

http://www.chinaunix.net

关键字: ,
喜欢益友网的文章,那就通过 RSS Feed 功能订阅阅读吧!

才1个评论

  1. cokacora 说:

    SELINUX关闭了之后,安装好没有再打开啊,没有防火墙裸奔不好吧

我要评论

*

* 绝不会泄露



返回首页 | 关于我们 | 联系我们 | 广告合作 | 网站地图 | 友情链接 | 版权声明 |