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 p_w_picpaths) 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 p_w_uploads
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
測試:
實驗完成。。。。。。。。。。。。。。。。。。。。。。。