您的位置:首页 > 运维架构 > 网站架构

LAMP架构

2013-04-24 15:48 441 查看
LAMP架构

Linux+Apache+Mysql+Perl/PHP/Python
一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个IT界的关注。从网站的流量上来说,70%以上的访问流量是LAMP来提供的,LAMP是最强大的网站解决方案.

LAMP介绍
LAMP 指的Linux (操作系统)、 ApacheHTTP 服务器, MySQL (数据库软件) 和PHP (有时也是指Perl 或 Python) 的第一个字母,一般用来建立的web 服务器

软件组件
Linux
Linux 是免费开源软件,这意味着源代码可用的操作系统。
Apache
Apache 是使用中最受欢迎的一个开放源码的WEB服务器软件。
MySQL
MySQL 是多线程、多用户的SQL数据库管理系统。
MySQL 已拥有由Oracle 公司自 2010 年 1 月 27 日通过SUN 购买。SUN 最初于 2008 年 2 月 26 日收购 MySQL。
PHP,Perl 或 Python
PHP 是一种编程语言最初设计生产动态网站。PHP 是主要用于服务器端的应用程序软件。Perl 和 Python 类似。

部署lamp需要安装以下软件包

linux apache mysql [jpeg png]

软件包
httpd-2.2.16.tar apache

mysql-5.1.44.tar database

php-5.2.5.tar php

jpegsrc.v8b.tar jpeg
libpng-1.4.4.tar png

freetype-2.1.10.tar font

gd-2.0.36RC1.tar GD[graphic device,图像工具库]

FreeType
FreeType库是一个完全免费(开源)的、高质量的且可移植的字体引擎,它提供统一的接口来访问多种字体格式文件,包括TrueType, OpenType, Type1, CID, CFF, Windows FON/FNT, X11 PCF等。支持单色位图、反走样位图的渲染。FreeType库是高度模块化的程序库,虽然它是使用ANSI C开发,但是采用面向对象的思想,因此,FreeType的用户可以灵活地对它进行裁剪。

GD
graphic device,图像工具库
gd库是php处理图形的扩展库,gd库提供了一系列用来处理图片的API,使用GD库可以处理图片,或者生成图片。 在网站上GD库通常用来生成缩略图或者用来对图片加水印或者对网站数据生成报表。

###开始部署
实验步骤

1.安装apache

[root@localhost src]# tar jxf httpd-2.2.16.tar.bz2
[root@localhost src]# cd httpd-2.2.16
[root@localhost httpd-2.2.16]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --with-mpm=worker

enable-so 允许apache支持动态模块 enable-rewrite 支持URL重定向 with-mpm=worker apache进程模型为worker 默认为prefork

[root@localhost httpd-2.2.16]# make && make install

Installing configuration files
[PRESERVING EXISTING HTDOCS SUBDIR: /usr/local/httpd/htdocs]
[PRESERVING EXISTING ERROR SUBDIR: /usr/local/httpd/error]
[PRESERVING EXISTING ICONS SUBDIR: /usr/local/httpd/icons]
[PRESERVING EXISTING CGI SUBDIR: /usr/local/httpd/cgi-bin]
Installing header files
Installing build system files
Installing man pages and online manual
make[1]: Leaving directory `/usr/src/httpd-2.2.16'

支持的静态模块
[root@localhost bin]# ./apachectl -l
Compiled in modules:
core.c
mod_authn_file.c
mod_authn_default.c
mod_authz_host.c
mod_authz_groupfile.c
mod_authz_user.c
mod_authz_default.c
mod_auth_basic.c
mod_include.c
mod_filter.c
mod_log_config.c
mod_env.c
mod_setenvif.c
mod_version.c
worker.c
http_core.c
mod_mime.c
mod_status.c
mod_autoindex.c
mod_asis.c
mod_cgid.c
mod_negotiation.c
mod_dir.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_rewrite.c
mod_so.c
启动方式:

[root@localhost httpd]# ./bin/httpd
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[root@localhost httpd]# ./bin/apachectl start
httpd (pid 2701) already running
[root@localhost httpd]#
这是分别以服务的形式和脚本的形式启动

[root@localhost httpd]# pstree -p |grep httpd
|-httpd(2701)-+-httpd(2702)
| |-httpd(2703)-+-{httpd}(2709)
| | |-{httpd}(2710)
| | |-{httpd}(2711)
| | |-{httpd}(2714)
| | |-{httpd}(2715)
| | |-{httpd}(2716)
| | |-{httpd}(2717)
| | |-{httpd}(2718)
| | |-{httpd}(2719)
| | |-{httpd}(2720)
| | |-{httpd}(2735)
| | |-{httpd}(2736)
| | |-{httpd}(2737)
| | |-{httpd}(2738)
| | |-{httpd}(2739)
| | |-{httpd}(2740)
| | |-{httpd}(2741)
| | |-{httpd}(2757)
| | |-{httpd}(2758)
| | |-{httpd}(2759)
| | |-{httpd}(2760)

测试好不好使:

[root@localhost httpd]# ./bin/apachectl -S 检查配置虚拟主机配置是否正确[root@localhost src]# tar zxf mysql-5.1.44.tar.gz

VirtualHost configuration:
Syntax OK
[root@localhost httpd]# ./bin/apachectl -t 检查主配置文件配置是否正确
Syntax OK

[root@localhost ~]# elinks http://localhost --dump
It works!

2.安装mysql

[root@localhost ~]# useradd -r mysql

[root@localhost src]# tar zxf mysql-5.1.44.tar.gz
[root@localhost src]#cd mysql-5.1.44

[root@localhost mysql-5.1.44]# ./configure --prefix=/usr/local/mysql --with-extra-charsets=gbk,gb2312,utf8 --with-mysqld-user=mysql ---prefix=/usr/local/mysql 安装路径
--with-extra-charsets=gbk,gb2312,utf8 字符集
--with-mysqld-user=mysql 以mysql用户来管理mysql
--enable-thread-safe-client 支持线程-enable-thread-safe-client

[root@localhost mysql-5.1.44]# make && make install

chown -R mysql mysql
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

启动数据库
./mysqld_safe &

验证数据库

/usr/local/mysql/bin/mysql
mysql>
/usr/local/mysql/bin/mysqladmin -u root password "123456"

3.安装freetype

[root@localhost src]# tar zxf jpegsrc.v8b.tar.gz
[root@localhost src]# cd freetype-2.1.10

[root@localhost freetype-2.1.10]# ./configure --prefix=/usr/local/freetype
[root@localhost freetype-2.1.10]#make && make install

/usr/bin/install -c -m 644 ./builds/unix/ft2unix.h \
/usr/local/freetype/include/ft2build.h
/usr/bin/install -c -m 644 ./builds/unix/ftconfig.h \
/usr/local/freetype/include/freetype2/freetype/config/ftconfig.h
/usr/bin/install -c -m 755 ./builds/unix/freetype-config \
/usr/local/freetype/bin/freetype-config
/usr/bin/install -c -m 644 ./builds/unix/freetype2.m4 \
/usr/local/freetype/share/aclocal/freetype2.m4
/usr/bin/install -c -m 644 ./builds/unix/freetype2.pc \
/usr/local/freetype/lib/pkgconfig/freetype2.pc

4.安装jpegsrc
[root@localhost src]#tar zxf jpegsrc.v8b.tar.gz
[root@localhost src]# cd jpeg-8b/

[root@localhost jpeg-8b]# ./configure --prefix=/usr/local/jpeg

[root@localhost jpeg-8b]#make && makeinstall

5.安装libpng
[root@localhost src]#tar jxf libpng-1.4.4.tar.bz2
[root@localhost src]#cd libpng-1.4.4
[root@localhost libpng-1.4.4]# ./configure --prefix=/usr/local/libpng
[root@localhost libpng-1.4.4]#make && make install

make install-data-hook
make[2]: Entering directory `/usr/src/libpng-1.4.4'
cd /usr/local/libpng/include; rm -f png.h pngconf.h
cd /usr/local/libpng/include; ln -s libpng14/png.h png.h
cd /usr/local/libpng/include; ln -s libpng14/pngconf.h \
pngconf.h
cd /usr/local/libpng/lib/pkgconfig; rm -f libpng.pc
cd /usr/local/libpng/lib/pkgconfig; ln -s libpng14.pc libpng.pc
make[2]: Leaving directory `/usr/src/libpng-1.4.4'
make[1]: Leaving directory `/usr/src/libpng-1.4.4'

6.安装libxm12
[root@localhost src]# tar zxf libxml2-2.6.30.tar.gz
[root@localhost src]# cd libxml2-2.6.30
[root@localhost libxml2-2.6.30]# ./configure --prefix=/usr/local/libxm12

config.status: creating include/libxml/xmlversion.h
config.status: creating xml2-config
config.status: creating libxml-2.0.pc
config.status: creating libxml-2.0-uninstalled.pc
config.status: creating python/setup.py
config.status: creating config.h
config.status: executing depfiles commands
Done configuring

[root@localhost libxml2-2.6.30]# make && make install

make[1]: Entering directory `/usr/src/libxml2-2.6.30/example'
make[2]: Entering directory `/usr/src/libxml2-2.6.30/example'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/usr/src/libxml2-2.6.30/example'
make[1]: Leaving directory `/usr/src/libxml2-2.6.30/example'
Making install in xstc
make[1]: Entering directory `/usr/src/libxml2-2.6.30/xstc'
make[2]: Entering directory `/usr/src/libxml2-2.6.30/xstc'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/usr/src/libxml2-2.6.30/xstc'
make[1]: Leaving directory `/usr/src/libxml2-2.6.30/xstc'

7.安装gd
[root@localhost src]# tar -zxf gd-2.0.36RC1.tar.gz
[root@localhost src]#cd cd gd-2.0.36RC1

[root@localhost gd-2.0.36RC1]# ./configure --prefix=/usr/local/gd --with-png=/usr/local/libpng --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-libxml2=/usr/local/libxm12

[root@localhost gd-2.0.36RC1]#make && make install

8.安装php

636 cd /usr/src/php-5.2.5
637 ./configure --prefix=/usr/local/php --enable-mbstring --with-apxs2=/usr/local/http/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php --with-libxml-dir=/usr/local/libxm12 --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype --with-gd=/usr/local/gd --enable-soap --enable-gd-native-ttf --enable-ftp --enable-exif --enable-xml --enable-sockets --enable-ucd-snmp-hack

--prefix=/usr/local/php
--enable-mbstring 启用mbstring功能
--with-apxs2=/usr/local/http/bin/apxs
--with-mysql=/usr/local/mysql
--with-config-file-path=/usr/local/php
--with-libxml-dir=/usr/local/libxml2
--with-jpeg-dir=/usr/local/jpeg
--with-png-dir=/usr/local/libpng
--with-freetype-dir=/usr/local/freetype
--with-gd=/usr/local/gd
--enable-soap 允许soap模块
--enable-gd-native-ttf ####Enable TrueType string function
--enable-ftp
--enable-exif ###Enable EXIF (metadata from images) support
--enable-xml
--enable-sockets ###Enable sockets support
--enable-ucd-snmp-hack ### SNMP: Enable UCD SNMP hack

+--------------------------------------------------------------------+
| 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.

然后再 #make && make install

[PEAR] Console_Getopt - already installed: 1.3.0
[PEAR] Archive_Tar - already installed: 1.3.7
[PEAR] Structures_Graph- already installed: 1.0.4
[PEAR] PEAR - already installed: 1.9.4
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
Installing PDO headers: /usr/local/php/include/php/ext/pdo/

9. apache php整合

vim /usr/local/http/conf/httpd.conf

LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php

<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>

step 11 test php
echo "<? phpinfo(); ?>" > /usr/local/http/htdocs/index.php

PHP配置过程历时记录:

702 cp web.zip /usr/local/httpd/htdocs/
703 cd /usr/local/httpd/htdocs/
704 ls
705 ll
706 chmod 777 web.zip
707 unzip web.zip
708 clear
709 ls
710 rm -rf readme/
711 cp -r upload/* ./
712 ls
713 chmod -R 757 config.inc.php
714 chmod -R 757 attachments
715 chmod -R 757 forumdata/
716 chmod -R 757 uc_client/
717 clear
718 cd /usr/local/mysql/bin/
719 ./mysqladmin -u root password "123456"
720 ./mysql -u root -p

测试:













实验完成。。。。。。。。。。。。。。。。。。。。。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  lamp lamp架构