LAMP(Linux-
Apache-MySQL-PHP) 站架构是目前国际流行的Web框架,该框架包括:Linux操作系统,Apache 络服务器,MySQL数据
库,Perl、PHP或者Python编程语言,所有组成产品均是开源软件,是国际上成熟的架构框架,很多流行的商业应用都是采取这个架构,和
Java/J2EE架构相比,LAMP具有Web资源丰富、轻量、快速开发等特点,微软的.NET架构相比,LAMP具有通用、跨平台、高性能、低价格的
优势,因此LAMP无论是性能、质量还是价格都是企业搭建 站的首选平台。
对于大流量、大并发量的 站系统架构来说,除了硬件上使用高
性能的服务器、负载均衡、CDN等之外,在软件架构上需要重点关注下面几个环节:使用高性能的操作系统(OS)、高性能的 页服务器(Web
Server)、高性能的数据库(Database)、高效率的编程语言等。
环境:
CentOS6.4 x86_64位 采用最小化安装,系统经过了基本优化
selinux为关闭状态,iptables为无限制模式
ip:192.168.1.113/24
apache版本:httpd-2.4.6
apr版本:apr-1.4.8
apr-util版本:apr-util-1.5.2
pcre版本:pcre-7.8
源码包存放位置:/server/tools
源码包编译安装位置:/etc/local/软件名称
一、安装前准备
1、开发环境部署
因为本次实验中系统是最小化安装的,所以在安装apache之前需要先安装开发环境和依赖包。
[root@c64-web ~]# yum groupinstall “Development tools” “Server Platform Development” -y
#安装这两个开发环境的软件包组
[root@c64-web ~]# yum install pcre* -y #安装pcre兼容的正则表达式
由于我们安装的httpd-2.4.6版本比较新,因此默认开发环境包中自带的apr包版本比较低,只能支持2.2.x系列的httpd版本,而这里至少要1.4版本以上的apr才被支持。因此我们需要先编译安装apr才行。
注意:apache2.2.x版本,只要安装了系统的默认开发环境包组,就不需要再安装apr了。
apr介绍
Apache可移植运行时( Apache Portable Runtime,简称APR),它是Apache
HTTP服务器的支持库,提供了一组映射到下层操作系统的API。APR的目标则是希望安全合并所有的能够合并的代码而不需要牺牲性能,因此Apache
使用这个之后可以有效的提高Apache的静态页面的处理能力。
apr安装,
[root@c64-web ~]# cd /server/tools/ #首先我们要先进到存放源码的目录
[root@c64-web tools]# wget http://apache.dataguru.cn/apr/apr-1.4.8.tar.gz #下载apr源码包
[root@c64-web tools]# tar zxf apr-1.4.8.tar.gz #解压源码包
[root@c64-web tools]# cd apr-1.4.8
[root@c64-web apr-1.4.8]# ./configure –prefix=/usr/local/apr #编译前配置,
#并指定安装目录,方便维护
[root@c64-web apr-1.4.8]# make #执行编译
[root@c64-web apr-1.4.8]# make install #执行安装
执行编译和安装的过程我们可以缩减为下面一条命令即可
[root@c64-web tools]# make&&make install #该命令表示,当执行make编译
#成功后接着执行make install进行安装
仅仅装了apr是不够的,这里还需要安装apr-util这个开发包。
[root@c64-web apr-1.4.8]# cd ..
[root@c64-web tools]# wget http://apache.dataguru.cn/apr/apr-util-1.5.2.tar.gz
[root@c64-web tools]# tar zxf apr-util-1.5.2.tar.gz
[root@c64-web tools]# cd apr-util-1.5.2
[root@c64-web apr-util-1.5.2]# ./configure –prefix=/usr/local/apr-util
–with-apr=/usr/local/apr #因为apr-util依赖于apr,因此这里需要指定apr的安装路径
[root@c64-web apr-util-1.5.2]# make&&make install #这里用上面提到的快捷命令
2、源码包验证
开发环境搞定之后,就要准备apache的源码包了。我们可以从apache的官 或者镜像站点进行下载。同时我们还需要下载apache的公钥和数字签名文件,以便实现对源码包一致性的验证,确保包的安全性。
[root@c64-web apr-util-1.5.2]# cd ..
[root@c64-web tools]# wget http://www.eu.apache.org/dist/httpd/httpd-2.4.6.tar.gz
[root@c64-web tools]# wget http://www.eu.apache.org/dist/httpd/httpd-2.4.6.tar.gz.asc
[root@c64-web tools]# wget http://www.apache.org/dist/httpd/KEYS
这里我们采用下面这种方式来进行包验证
% gpg –import KEYS
% gpg –verify httpd-2.2.8.tar.gz.asc
验证结果如下:
[root@c64-web tools]# gpg –import KEYS #用gpg命令导入公钥
gpg: key 2719AF35: “Ben Laurie ” not changed
gpg: key A99F75DD: “Rodent of Unusual Size ” not changed
……
gpg: key 6D5954FA: “Eric Covener ” not changed
gpg: Total number processed: 64
gpg: w/o user IDs: 4
gpg: unchanged: 60
[root@c64-web tools]# gpg –verify httpd-2.4.6.tar.gz.asc #验证httpd-2.4.6.tar.gz.asc
gpg: Signature made Tue 16 Jul 2013 12:44:25 AM CST using RSA key ID 791485A8
gpg: Good signature from “Jim Jagielski (Release Signing Key) “
#出现这一行说明这个签名是有效的
gpg: aka “Jim Jagielski “
gpg: aka “Jim Jagielski “
gpg: WARNING: This key is not certified with a trusted signature!
#这个警告是因为本地密钥库不信任该公钥
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: A93D 62EC C3C8 EA12 DB22 0EC9 34EA 76E6 7914 85A8
如果 gpg
–verify的命令输出信息和上面相似,就可以确信http-2.4.6.tar.gz确实来自Apache。这里可以忽略上面表明公钥不可信的警告。因为保证公共密钥签名来自所有者的惟一方法是,密钥的所有者亲自把磁盘上的密钥交给你。不过,采取上面的步骤后,我们已经可以在某种程度上确信下载的
http-2.4.6.tar.gz可信了。
二、开始安装
所有准备工作都做好了,下面开始安装apache
[root@c64-web tools]# tar zxf httpd-2.4.6.tar.gz
[root@c64-web tools]# cd httpd-2.4.6
[root@c64-web httpd-2.4.6]# ./configure
–prefix=/usr/local/apache-2.4.6 #配置文件目录
–with-apr=/usr/local/apr #指定apr安装路径
–with-apr-util=/usr/local/apr-util #指定apr-util安装路径
–with-pcre #支持perl的正则表达式
–enable-so #启用动态模块加载
–enable-ssl #基于ssl加密传输
–enable-cgi #开启CGI脚本
–enable-rewrite #允许URL重写
–with-zlib #支持压缩
–enable-deflate #支持 页压缩
–enable-expires #支持 页缓存
–enable-headers #提供允许对HTTP请求头的控制
–enable-modules=most #支持大多数模块
–enable-mpms-shared=all #mpm模块的动态切换
–with-mpm=worker #让apache以worker方式运行
以上是生产环境中常用的一些编译参数 ,可以根据需求进行调整
[root@c64-web httpd-2.4.6]# ./configure –prefix=/usr/local/apache-2.4.6
–with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –with-pcre
–enable-so –enable-ssl –enable-cgi –enable-rewrite –with-zlib
–enable-deflate –enable-expires –enable-headers –enable-modules=most
–enable-mpms-shared=all –with-mpm=worker #此处为方便你们复制执行用的,如执行了上面的就不要再执行这个了
[root@c64-web tools]# make&&make install
三、启动配置
1、创建目录软链接
[root@c64-web httpd-2.4.6]# ln -s /usr/local/apache-2.4.6 /usr/local/apache
2、启动服务
如果我们是yum或者rpm安装的话,我们可以直接用service httpd
start来进行服务启动。因为我们是编译安装的,所以此处我们要这样启动。
[root@c64-web /]# /usr/local/apache/bin/apachectl -t #首先我们要检查语法
[root@c64-web /]# /usr/local/apache/bin/apachectl start
3、优化启动
第一种:拷贝命令
我们也可以拷贝apache的启动命令apachectl到系统启动目录下
[root@c64-web /]# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
第二种:添加软链接
我们还可以通过添加软链接的方式,将apache启动命令目录添加一条软链接到/etc/init.d/系统启动目录下
[root@c64-web /]# ln -s /usr/local/apache/bin/apachectl
/etc/init.d/httpd
4、开机自启动
下面,我们就要实现apache服务的开机自启动了。开机自启动的实现也是有两种方式的
首先我需要对/etc/init.d/httpd文件稍作修改
#chkconfig:2345 10 90
#descrption:Activates/Deactivates Apache Web Server
添加完成之后,
[root@c64-web /]# chkconfig –add httpd #添加httpd服务到系统开机启动服务列表
[root@c64-web /]# chkconfig httpd on #设置httpd服务开机自启动
[root@c64-web /]# chkconfig –list httpd #从列表中查看httpd在不同级别的启动情况
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
第二种:添加到开机启动配置文件/etc/rc.d/rc.local下
本方法对优化启动的3种方法都有效,不过你要注意你设置的httpd命令的路径。本例以优化启动的第二种方法为前提
[root@c64-web /]# echo ‘#httpd start by sunsky in 20131104’ >> /etc/rc.d/rc.local
#添加注释,方便以后查看
[root@c64-web /]# echo ‘/etc/init.d/httpd start >/dev/null 2>&1’ >> /etc/rc.d/rc.local
[root@c64-web /]# tail -2 /etc/rc.d/rc.local
#添加完成后一定要看是否添加成功
#httpd start by sunsky in 20131104
/etc/init.d/httpd start >/dev/null 2>&1
Apache服务器的部署到这里就彻底完工了!
文章知识点与官方知识档案匹配,可进一步学习相关知识CS入门技能树Linux入门在线安装软件24715 人正在系统学习中 相关资源:顺丰快递单打印软件2.7可支持自定义快递模板-物流工具类资源-CSDN…
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!