哪位朋友能发套wcf分布式架构项目源码 给我学习下?

IT技术博客IT技术博客,精选各种精华文章供您阅读,是您学习各种IT技术的博客优选之地评论&&
&&&&& 最近一直在忙项目的事情,今天有点空,刚好山东的一个源码学习者,问我怎么配置、安装、运行通用权限管理系统,WCF技术在通用权限管理系统中的处理方式。大约折腾了一个小时多,才让那位山东的朋友有点明白,现将配置的详细步骤发布出来,同时将通用权限管理系统的试用版也发布出来,大家体会体会,共同提高。
1.打开通用权限管理系统解决方案,默认的时候,WCFHOST与WCFClient两个项目没有添加到解决方案中。咱们先把这两个项目添进去。
主要的配置代码为:
&service name="DotNet.Service.ExceptionService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/ExceptionService/" binding="netTcpBinding" contract="DotNet.IService.IExceptionService"&
&/endpoint&
&/service&
&service name="DotNet.Service.FileService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/FileService/" binding="netTcpBinding" contract="DotNet.IService.IFileService"&
&/endpoint&
&/service&
&service name="DotNet.Service.FolderService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/FolderService/" binding="netTcpBinding" contract="DotNet.IService.IFolderService"&
&/endpoint&
&/service&
&service name="DotNet.Service.ItemDetailsService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/ItemDetailsService/" binding="netTcpBinding" contract="DotNet.IService.IItemDetailsService"&
&/endpoint&
&/service&
&service name="DotNet.Service.ItemsService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/ItemsService/" binding="netTcpBinding" contract="DotNet.IService.IItemsService"&
&/endpoint&
&/service&
&service name="DotNet.Service.LogOnService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/LogOnService/" binding="netTcpBinding" contract="DotNet.IService.ILogOnService"&
&/endpoint&
&/service&
&service name="DotNet.Service.LogService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/LogService/" binding="netTcpBinding" contract="DotNet.IService.ILogService"&
&/endpoint&
&/service&
&service name="DotNet.Service.MessageService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/MessageService/" binding="netTcpBinding" contract="DotNet.IService.IMessageService"&
&/endpoint&
&/service&
&service name="DotNet.Service.ModuleService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/ModuleService/" binding="netTcpBinding" contract="DotNet.IService.IModuleService"&
&/endpoint&
&/service&
&service name="DotNet.Service.OrganizeService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/OrganizeService/" binding="netTcpBinding" contract="DotNet.IService.IOrganizeService"&
&/endpoint&
&/service&
&service name="DotNet.Service.ParameterService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/ParameterService/" binding="netTcpBinding" contract="DotNet.IService.IParameterService"&
&/endpoint&
&/service&
&service name="DotNet.Service.PermissionItemService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/PermissionItemService/" binding="netTcpBinding" contract="DotNet.IService.IPermissionItemService"&
&/endpoint&
&/service&
&service name="DotNet.Service.PermissionService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/PermissionService/" binding="netTcpBinding" contract="DotNet.IService.IPermissionService"&
&/endpoint&
&/service&
&service name="DotNet.Service.RoleService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/RoleService/" binding="netTcpBinding" contract="DotNet.IService.IRoleService"&
&/endpoint&
&/service&
&service name="DotNet.Service.SequenceService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/SequenceService/" binding="netTcpBinding" contract="DotNet.IService.ISequenceService"&
&/endpoint&
&/service&
&service name="DotNet.Service.StaffService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/StaffService/" binding="netTcpBinding" contract="DotNet.IService.IStaffService"&
&/endpoint&
&/service&
&service name="DotNet.Service.UserService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/UserService/" binding="netTcpBinding" contract="DotNet.IService.IUserService"&
&/endpoint&
&/service&
&service name="DotNet.Service.UserCenterDbHelperService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/UserCenterDbHelperService/" binding="netTcpBinding" contract="DotNet.IService.IDbHelperService"&
&/endpoint&
&/service&
&service name="DotNet.Service.BusinessDbHelperService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/BusinessDbHelperService/" binding="netTcpBinding" contract="DotNet.IService.IDbHelperService"&
&/endpoint&
&/service&
&service name="DotNet.Service.WorkFlowActivityAdminService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/WorkFlowActivityAdminService/" binding="netTcpBinding" contract="DotNet.IService.IWorkFlowActivityAdminService"&
&/endpoint&
&/service&
&service name="DotNet.Service.WorkFlowCurrentService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/WorkFlowCurrentService/" binding="netTcpBinding" contract="DotNet.IService.IWorkFlowCurrentService"&
&/endpoint&
&/service&
&service name="DotNet.Service.WorkFlowProcessAdminService" behaviorConfiguration="Internet"&
&endpoint address="net.tcp://localhost:8888/DotNet.Service/WorkFlowProcessAdminService/" binding="netTcpBinding" contract="DotNet.IService.IWorkFlowProcessAdminService"&
&/endpoint&
&/service&
&/services&
以下主要是用来身证份验证的,x509证书自己配置一下。
&behavior name="Internet"&
&serviceCredentials&
&serviceCertificate storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName" findValue="pp-pc" /&
&/serviceCredentials&
&/behavior&
&在WCFHOST项目中配置好Config.Xml 数据库连接字符串
以上为服务端配置完成
运行效果如图所示:
客户端配置
都写好了的,自己要的话,无须任何编码实现。
红色的位置配置好了,这样我们就可以运行客户端了(将服务端开着,双击客户端)。
客户端登录完毕,界面效果图之一:
此时服务端依次显出那些服务被调用了,如下图所示:
文档下载QQ群共享中:
本着互相学习,共同提高的原则,不接受过分的喷。作者:
16:27 推荐.NET配套的通用数据层ORM框架:"文章分类 (8504) (2370) (1192) (135)文章档案 (1) (7) (23) (3) (834) (988) (1834) (1604) (735) (891) (688) (572) (283) (38)最新文章阅读排行榜友情链接当前位置: >
WCF技术剖析(卷1)之推荐序
时间: 11:58 来源: 作者: 浏览:
【推荐序一】
Windows Communication Foundation (WCF)是用来在不同应用间进行互通信的一个编程框架,它是.Net Framework中偏重于通信的重要组成部分。原代码名为Indigo的这个编程框架,在其Beta2 版本正式更名为WCF,于2006年12月作为.Net Framework 3.0的四套API之一,一起发布。
从Native Win32到Managed的世界,应用进程间的通信机制一直是开发者最为关注的方面,在.Net Framework 2.0(2005年11月发布)以及以前的CLR版本中,微软提供了若干套相互分开的APIs,来支持应用间的互通信:有相对基础的Managed Socket机制;有可为二进制优化而设计的.Net Remoting(同时支持TCP/HTTP/Pipline);有可支持事务的通信机制Distributed Transactions;还有为使互操作能力最大化而设计的Soap-based通信机制XML Web Services;也有可以与老式遗留系统(COM/COM+/MTS等)异步通信机制Message Queues。由于这些这种各样的通信机制的设计方法不同,而且彼此间也有重叠性,对于开发者来说,不同的选择需要学习掌握不同的程序设计模型,非常的不方便。另外SOA(Service-Oriented Architecture)也开始盛行,随着技术的推进,微软重新审视了.Net中的这些通信机制,设计实现了一个统一化的通信编程开发模型,这就是WCF,对.Net平台上的数据通信提供了最基本最富有弹性和一致性的基础设施。
WCF是被按照SOA的架构原则而设计的分布式计算基础环境,在其上开发人员可以实现各种Services提供给客户端消费者来调用。WCF提供了各种各样的基础结构来最大程度地为开发人员提供方便性和灵活性,快速有效地构建Web Service应用。
WCF的魅力除了来自于它为我们开发人员所提供的模型和基础外,还来自于它自身的设计和实现。记得,当第一次了解到WinFx中Indigo的使命时,就对它充满了期待,同时也有几分的悬疑;当2002年得知Don Box加入微软负责Indigo的架构时,悬疑彻底被转化为更多的期待,更加关注它每个版本的成长,到2006年WCF随.Net 3.0发布时,呈现在我们面前的WCF堪称经典。其中恰到好处的抽象、分层和模块关系,简妙高效的运行时模型与框架机理,以及各部分丰满实在的内在实现,还有它相当彻底的可扩展性设计,都是我们学习架构设计的绝佳范本。可以说,WCF是微软SOA思维的第一轮近乎完美的演绎。自WCF发布以来,它迅速成为微软技术体系下企业级应用开发的首选平台,时间证明了它在微软SOA战略中的基石地位。
国内WCF的应用正稳步成长中,其中一些WCF技术先行者对广大社区的带动和推进作用是不可忽略的。本书的作者蒋金楠(Artech)就是其中走在前面的一位。他在博客园中关于WCF的博文成为许多WCF开发人员的第一手学习资料。
这里还要说一个小故事。去年,和TerryLee还有武汉博文的编辑朋友一起小聚,其中谈到技术写作,我向两位谈了自己关于“WCF三部曲(应用实践篇、技术内幕分析篇和扩展篇)”的写作计划,编辑朋友告诉我已经有作者在WCF上先期开始了,我马上就猜到了是Artech。随后通过TerryLee联络得知,Artech的书稿已经完成近半了。在拿到了Artech 新书的目录稿后,基于我对Artech博文写作的判断,我大胆做了决定,暂时搁置自己WCF首篇的写作计划,转而期待Artech新书的完稿。
直到最近看了Artech的整部书稿,通篇读后的感觉,书如己出,不亚于当年得知Don Box去了微软负责Indigo架构的消息时的感觉,事实证明,我当时搁置写作计划的决定是正确的。
知识结构全面、论述准确逻辑严密是本书的写作特点,是一本各个层次开发人员都可以从中受益的书:对于WCF的初、中级开发人员,这本书可以帮助你获得WCF全方位的知识,全面系统地帮你梳理关于WCF的知识结构,提升动手实施能力;对于WCF的高级开发人员,这本书即可以有效弥补你WCF相关知识结构的中盲点,又可以领略关于自己熟悉知识点的来自作者的看法和理解。
当然,读完本书,也不是完全没有疑惑,我最大的疑惑就是本书含有“卷一”字样的书名,难道这又是一个暗示?暗示我又要考虑搁置我关于WCF三部曲后续两篇的写作计划?亦或是可能的合作机会?我当然希望是后者,不过无论是哪一个,显然都是很值得我期待的!
资深架构师 曲春雨
2009年6月 于北京
【推荐序二】
随着核心Web服务标准(SOAP和WSDL)逐渐被广泛采纳和应用,高度异构的软件系统之间的互操作性取得了前所未有的进步,同时也在安全性、事务性、可靠性方面提出了新的要求,以至于后来又推出了大量的Web服务补充标准。在.NET平台下做过分布式开发的朋友,想必对以下技术都不会陌生:ASP.NET服务、Web服务增强、.NET Remoting、MSMQ等,这些技术各自独立,编程模型差别较大,无法用一种统一的编程模型进行分布式应用程序开发。
在2003年时,微软启动了一个代码名为Indigo的项目,微软试图实现一个宏伟的计划,用一套统一的API完成上述各模型的功能,同时支持良好的扩展性,便于出现新的Web服务标准、协议时,无需再开发另外一套模型,这听起来有些不可思议,但微软却做到了,2005年Indigo发展为一个稳定的版本,同时更名为Windows Communication Foundation(简称WCF),并且作为.NET Framework 3.0的一部分发布,.NET Framework 3.5中,WCF得到了进一步增强,在开发REST服务方面也提供了支持。可以说WCF是一个统一的、可配置、可扩展的分布式应用程序开发框架,使用它可以非常轻松高效的构建分布式应用程序。
目前WCF技术已经得到了广泛的应用,但国内在这方面的资料却非常少,据我所知,迄今为止还没有一本WCF的原创中文书籍,Artech的《WCF技术剖析》是国内第一本,非常荣幸,我能在第一时间阅读本书书稿,本书内容涵盖了WCF技术的方方面面,有知识讲解,也有案例演示,从使用的角度阐释了WCF。
Artech在WCF方面的造诣和写作功底不容置疑,这一点从他在个人博客上发表的WCF技术文章就可以看得出来,他的《WCF之旅》和《WCF后续之旅》两个系列深受广大读者好评。在读完本书后,只想对Artech说,上市后多送我几本吧,我要把它送给身边的朋友。
软件架构师 李会军
2009年6月于北京
【推荐序三】
十五年前,当我还在用C++和汇编在Win 3.1平台上写桌面程序的时候,我考虑的内容可以说很具体、也可以说很全面。说具体是因为我要关心存储、提取、进程间互斥、界面展现等众多技术实现内容;说全面是因为我大概要关心这些应用几乎全部的开发内容。
现在,时代变了。计算已经从桌面搬移到我们视野外部,计算可能发生在太平洋海底某个探测传感器上、太空中北斗卫星阵上、家里的洗衣机里、Windows Azure的SQL Services…。而我们自己除了专注于自己的开发工作外,也要多多“借他山之石”,根据需要把其他计算系统的资源“粘”到我们自己的成果上,并对外提供必要的服务和支持。
以前,为完成这些我们不得不面对众多技术,多种“方言”的结果往往造成工作成果无法重用;WCF的出现使得全球的.NET开发者可以用一种、而且是唯一的一种“语言”很好的把各种计算系统“黏合”在一起,同时我们的成果也可以被操着各种“方言”的用户分享,无论他信仰COM+、.NET、Java、REST还是其他。
感谢蒋先生的辛勤工作,《WCF技术剖析》为我们解读了WCF这个被国内、外同行普遍好评的技术。不过,由于WCF框架自身的延展性和灵活性,系统学习WCF本身也是一个较为艰苦的过程,蒋先生此次的第一卷相信会成为您入门并实际完成大部分项目的良好基础。
祝您用WCF飞跃更为广阔的分布式计算平台。
作者:出处: 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
由源码搜藏网整理,转载请注明出处
猜你也喜欢看这些 ??????
其他类型的网站教程 ??????尚未添加关注。
近日有不法分子利用新浪评论向用户散布虚假获奖消息。在此新浪网郑重申明:新浪网不会使用除 .cn 后缀以外的其他域名的页面来公布中奖结果,也不会使用
以外的任何电话号码作为咨询电话;如果您参与了新浪网的活动并中奖,我们不会以任何方式收取费用。如果您有任何疑问,请您拨打新浪网唯一客服热线: 进行咨询和举报。
还可以输入300个汉字
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。&?xml version="1.0" encoding="utf-8" ?&&configuration&&system.web&&compilation debug="true"/&&/system.web&&system.serviceModel&&services&&service name="Sample.WCF.HelloTimeForJava.Service" behaviorConfiguration="MyServiceTypeBehaviors"&&endpoint address="HelloTimeService" binding="wsHttpBinding" contract="Sample.WCF.HelloTimeForJava.IService"&&identity&&dns value="localhost"/&&/identity&&/endpoint&&endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&&host&&baseAddresses&&add baseAddress="http://localhost:8000/"/&&/baseAddresses&&/host&&/service&&/services&&behaviors&&serviceBehaviors&&behavior name="MyServiceTypeBehaviors"&&serviceMetadata httpGetEnabled="True" httpGetUrl=""/&&serviceDebug includeExceptionDetailInFaults="False"/&&/behavior&&/serviceBehaviors&&/behaviors&&/system.serviceModel&&/configuration&
相关链接:
&&&&如果您喜欢IT行业或者对IT行业感兴趣,欢迎加入本站官方QQ群:,在群里认识新朋友和交流技术^_^
Java与WCF交互(一)补充:用WSImport生成WSDL的Java客户端代码
在《Java与WCF交互(一):Java客户端调用WCF服务》一文中,我描述了用axis2的一个Eclipse控件生成WCF的Java客户端代理类,后来有朋友建议用Xfire、CXF,一直没有尝试,今天有朋友指出JDK6可以用java自带的一个WSImport工具,试了下,果然很爽,这是一个exe文件,位于%JAVA_HOME%\bin下,它的官方使用说明,见:http://download-/javase/6/docs/technotes/tools/share/wsimport.html,主要参数:
Description
-d &directory&
Specify where to place generated output files
Specify external JAX-WS or JAXB binding files (Each &file& must have its own -b)
-B &jaxbOption&
Pass this option to JAXB schema compiler
Specify catalog file to resolve external entity references, it supports TR9401, XCatalog, and OASIS XML Catalog format. Please read the documentation of catalog and see catalog sample.
-extension
Allow vendor extensions (functionality not specified by the specification). Use of extensions may result in applications that are not portable or may not interoperate with other implementations
Display help
-httpproxy:&host&:&port&
Specify an HTTP proxy server (port defaults to 8080)
Keep generated files
Specifying a target package via this command-line option, overrides any wsdl and schema binding customization for package name and the default package name algorithm defined in the specification
-s &directory&
Specify where to place generated source files
Output messages about what the compiler is doing
Print version information
-wsdllocation &location&
@WebServiceClient.wsdlLocation value
Generate code as per the given JAX-WS specification version. version 2.0 will generate compliant code for JAX-WS 2.0 spec.
Suppress wsimport output
示例:wsimport -s JavaSrc http://stockquote.xyz/quote?wsdl
将在当前路径的JavaSrc下生成相关的Java类,直接复制到项目的Src目录下即可使用。下面还是以上次创建的http://localhost:8000/HelloTimeService?wsdl为类,测试过程如下:
新建一java Project,如图:
将上面生成的java文件复制到Src目录下,项目结构如图:
测试代码也很简洁:
小结:这种方式与Axis2生成的Stub方式其实非常类似,只不过没有生成测试代码。结构还算清晰。
&&&&如果您喜欢IT行业或者对IT行业感兴趣,欢迎加入本站官方QQ群:,在群里认识新朋友和交流技术^_^
LAMMP架构的企业级应用
& & & & & & & LAMMP架构的企业级应用=========================================LAMMP是什么LAMMP的实现LAMMP适用的生产环境==========================================一、LAMMP是什么& & &LAMMP,是几个英文单词首字母的缩写。& & &L是Linux的缩写,Linux操作系统,Linux以稳定、安全、且开源著称的操作系统,适用于做 &服务器。& & &A是Apache的缩写,Apache是一款提供Web服务器的开源软件,Apache是一个极具稳定安全、高度模块化、支持模块动态扩展的Web服务器,是搭建Web服务器的首选之一,据统计全球有50%左右的Web服务器是用Apache搭建的。/&这个网站,是对全球web服务器的排名。& & & M是Mysql的缩写,Mysql是数据库管理系统,数据库管理软件,也是开源软件。& & & M是Memcached的缩写,Memcached是一款开源、高性能、分布式内存对象缓存系统,可应用各种需要缓存的场景,其主要目的是通过降低对Database的访问来加速web应用程序。它是一个基于内存的&#8220;键值对&#8221;存储,用于存储数据库调用、API调用或页面引用结果的直接数据,如字符串、对象等。& & &Memcached是一款开发工具,它既不是一个代码加速器,也不是数据库中间件。其设计哲学思想主要反映在如下方面:& & 1. 简单key/value存储:服务器不关心数据本身的意义及结构,只要是可序列化数据即可。存储项由&#8220;键、过期时间、可选的标志及数据&#8221;四个部分组成;& & 2. 功能的实现一半依赖于客户端,一半基于服务器端:客户负责发送存储项至服务器端、从服务端获取数据以及无法连接至服务器时采用相应的动作;服务端负责接收、存储数据,并负责数据项的超时过期;& & 3. 各服务器间彼此之间不互相通信:不在服务器间进行数据同步;服务器宕机,存储的数据立即丢失& & 4. O(1)的执行效率& & 5. 清理超期数据:默认情况下,Memcached是一个LRU缓存,同时,它按事先预订的时长清理超期数据;但事实上,memcached不会删除任何已缓存数据,只是在其过期之后不再为客户所见;而且,memcached也不会真正按期限清理缓存,而仅是当get命令到达时检查其时长;& & P是PHP的缩写,是一种面向对象的编程语言。LAMMP的架构拓扑图:此LAMMP架构是分别搭建在不同的服务器上面,在生产环境中,更是应该如此,一台服务器提供多种应用,服务器会很消耗资源,提供服务的性能也会降低。此架构中各服务器的工作& & & Apache在此架构中,响应回复用户html的请求& & & FastCGI是把php程序执行的结果响应给Apache& & & Memcached是根据用户请求的动态网页文件中是否需要Memcached服务器缓存数据,Memcache是把数据存储在内存中的,速度可想而知了。& & & Mysql是响应用户是否需写入查询数据用户的请求资源到获取资源的过程& & &1、当用户只需要请求web服务器的html页面时,Apache直接响应请求,所经过的过程为1---&8& & &2、当用户需请求一个web服务器的动态的页面时,Apache把用户请求的php执行程序发送给FastCGI服务器执行,FastCGI把执行的结果返回给Apache服务器,服务器把程序生成的的静态页面响应给客户端。所经过的过程1---&2---&7---&8& & &3、当用户需要请求的web服务器资源中需要数据时,Apache把用户请求的php执行 &程序给FastCGI执行,执行过程中需要对数据进行操作时且Memcached中没有缓存时,FastCGI去请求Mysql服务器的资源,mysql服务器把数据响应给FastCGI,如果此数据需要缓存则FastCGI把数据缓存到Memcached服务器上,然后把数据响应给Apache,Apache生成静态的页面响应给客户端。所经过的过程1---&2---&5---&6[---&3]---&7---&8(如果需要缓存则会经过3过程)& & &4、当用户需要请求的web服务器资源中需要数据时,Apache把用户请求的php执行程序给&FastCGI执行,执行过程中需要对数据进行操作时Memcached中有缓存时,Memcached直接把&数据响应给FastCGI,然后把数据响应给Apache,Apache生成静态的页面响应给客户端。所经过的过程1---&2---&3---&4---&7---&8二、LAMMP的实现Apache服务器所需的软件包& & &apr-1.4.6.tar.bz2/apache/apr/apr-1.4.6.tar.bz2& & apr-util-1.5.2.tar.bz2 &/apache/apr/apr-util-1.5.2.tar.bz2& & httpd-2.4.6.tar.bz2(提供Web服务器的软件包)/apache/httpd/httpd-2.4.6.tar.bz2& & 由于httpd-2.4的包linux系统中的apr版本不够新,所以需要下载更新的apr相关的包,直接下载源码包进行安装。FastCGI服务器所需的软件包& & & & & libmcrypt &/fedora-epel/6Server/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm& & & & libmcypt-devel/fedora-epel/6Server/x86_64/libmcrypt-devel-2.5.8-9.el6.x86_64.rpm& & & & & xcache-3.0.3.tar.bz2 (缓存php执行好的代码,加速opcode)http://xcache.lighttpd.net/pub/Releases/3.0.3/xcache-3.0.3.tar.bz2& & & & & php-5.4.19.tar.bz2 &(提供php-fpm(FastCGI)服务的软件包)http://downloads.php.net/stas/php-5.4.19.tar.bz2& & & & & memcache-2.2.7.tgz &(FastCGI连接Memcache服务器的软件包)http://pecl.php.net/get/memcache-2.2.7.tgzMemcached服务器所需的软件包& & & & &libevent-2.0.21-stable.tar.gzhttp://nchc.dl.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.21-stable.tar.gz& & & & &memcached-1.4.15.tar.gz (安装Memcached服务器的软件包)/files/memcached-1.4.15.tar.gzMysql服务器所需的软件包& & & &mysql-5.5.33-linux2.6-x86_64.tar.gz/archives/mysql-5.5/mysql-5.5.33-linux2.6-x86_64.tar.gz& & 安装的是mysql的通用二进制程序包,此软件包解压之后就可以使用思路:1、每个服务器的安装操作都是独立,但是最后需要建立关系2、解决WEB怎么连接PHP-FPM(FastCGI)3、解决PHP-FPM(FastCGI)怎么连接Memcached4、解决PHP-FPM(FastCGI)怎么连接MysqlApache服务器的配置安装:123456789101112131415161718192021222324252627282930313233343536373839404142434445[root@jie1 ~]# lsanaconda-ks.cfg&&& apr-util-1.5.2.tar.bz2&&install.logapr-1.4.6.tar.bz2& httpd-2.4.6.tar.bz2&&&&&install.log.syslog##1、解压下载的软件包######[root@jie1 ~]# tar xf apr-1.4.6.tar.bz2[root@jie1 ~]# tar xf apr-util-1.5.2.tar.bz2[root@jie1 ~]# tar xf httpd-2.4.6.tar.bz2###2、安装开发库,和依赖性包######[root@jie1 ~]# yum -y groupinstall "Development tools" "Server Platform Development"[root@jie1 ~]# yum -y install pcre-devel& #安装依赖性包[root@jie1 ~]# rpm -qa | grep httpd&&& #检查系统是否安装httpd的rpm包httpd-tools-2.2.15-26.el6.centos.x86_64####3、编译安装apr软件#######[root@jie1 ~]# cd apr-1.4.6[root@jie1 apr-1.4.6]# ./configure --prefix=/usr/local/apr && make && make install###4、编译安装apr-util软件包######[root@jie1 ~]# cd apr-util-1.5.2[root@jie1 apr-util-1.5.2]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install####5、编译安装httpd的软件包#####[root@jie1 ~]# cd httpd-2.4.6[root@jie1 httpd-2.4.6]# ./configure --prefix=/usr/local/apache& --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event& && make && make install[root@jie1 ~]# cp httpd-2.4.6/build/rpm/httpd.init& /etc/rc.d/init.d/httpd&&& #复制源码包里面提供的httpd的SystemV脚本[root@jie1 ~]# vim /etc/rc.d/init.d/httpd###6、需要改动httpd的SystemV脚本的一些内容###################vim /etc/rc.d/init.d/httpd ########################prog=httpdhttpd=${HTTPD-/usr/local/apache/bin/httpd}pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid}lockfile=${LOCKFILE-/var/lock/subsys/${prog}}RETVAL=0# check for 1.3 configurationcheck13 () {&&&&&&&&CONFFILE=/usr/local/apache/conf/httpd.conf###################################################################[root@jie1 ~]# vim /usr/local/apache/conf/httpd.confServerName 172.16.22.1:80&#在配置文件中找到ServerName改成服务器的IP:端口#这样启动的时候就不会报错[root@jie1 ~]# service httpd start& #启动服务Starting httpd:&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& [& OK& ]###7、使系统能识别源码包安装的软件############[root@jie1 apache]# echo "PATH=/usr/local/apache/bin/:$PATH" &/etc/profile.d/httpd.sh[root@jie1 apache]# source /etc/profile.d/httpd.sh[root@jie1 apache]# ln -sv /usr/local/apache/include/& /usr/include/httpd[root@jie1 apache]# chkconfig --add httpd #把服务加到开机自动启动的列表[root@jie1 apache]# chkconfig --level 35 httpd& onFastCGI(php-fpm)服务器的配置安装:12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364[root@jie2 ~]# lsanaconda-ks.cfg&&&& xcache-3.0.3.tar.bz2&&install.log&&memcache-2.2.7.tgz& php-5.4.19.tar.bz2&&&install.log.syslog###1、解压下载的源码包[root@jie2 ~]#tar xf php-5.4.19.tar.bz2[root@jie2 ~]#tar xf memcache-2.2.7.tgz[root@jie2 ~]#tar xf xcache-3.0.3.tar.bz2###2、安装开发包和安装依赖性包,由于我的编译参数只指定了这些,所以只需这些依赖性包,如果指定的参数不一样,则需要的依赖性包也不尽相同[root@jie2 ~]#yum -y groupinstall "Server Platform Development" "Development tools"[root@jie2 ~]#yum -y install libxml2-devel bzip2-devel& libmcrypt-devel#libmcrypt-devel在光盘里面是没有提供相应的包,镜像站点的#epel源里面有此包,各位可以搭建一个epel的yum源,直接安装此包,我就是直接#搭建的sohu的光盘yum源和epel& yum源[root@jie2 ~]# cd php-5.4.19###编译参数--enable-fpm,支持FastCGI PHP模块,此参数决定是否能把PHP安装成#FastCGI服务器[root@jie2 php-5.4.19]#./configure --prefix=/usr/local/php& --enable-fpm --with-openssl --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml& --enable-sockets& --with-mcrypt& --with-bz2 --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd && make && make install###3、建立php的配置文件,此配置文件在php的解压包中[root@jie2 php-5.4.19]# cp php.ini-production&& /etc/php.ini[root@jie2 php]#cd /usr/local/php/###4、使系统能够识别源码包安装的软件[root@jie2 php]# echo "PATH=/usr/local/php/bin:/usr/local/php/sbin:$PATH" &/etc/profile.d/php-fpm.sh[root@jie2 php]# source /etc/profile.d/php-fpm.sh[root@jie2 php]#cd /usr/local/php/etc###5、建立php-fpm服务的配置文件,此配置文件的路径 /usr/local/php/etc[root@jie2 etc]# mv php-fpm.conf.default php-fpm.conf##修改php-fpm服务配置文件的监听的IP地址改为本地IP地址&### vim /usr/local/php/etc/php-fpm.conf####&&&&&&&&&&&&&&Listen 172.16.22.2:9000&############################################[root@jie2 fpm]# pwd/root/php-5.4.19/sapi/fpm###6、建立php-fpm的systemV脚本,此脚本的路径是在php解压包的php-5.4.19/sapi/fpm路径下[root@jie2 fpm]# cp init.d.php-fpm /etc/rc.d/init.d/php-fpm###7、把服务脚本加执行权限,开启服务,把服务加到开机自启动列表中[root@jie2 fpm]# chmod +x /etc/rc.d/init.d/php-fpm[root@jie2 fpm]# service php-fpm start[root@jie2 fpm]# chkconfig --add php-fpm[root@jie2 fpm]# chkconfig --level 35 php-fpm on###8、安装FastCGI与memcached服务连接的接口的一个软件[root@jie2 ~]# cd /root/memcache-2.2.7[root@jie2 memcache-2.2.7]# /usr/local/php/bin/phpize[root@jie2 memcache-2.2.7]# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache&& && make && make install####==============================================================######Installing shared extensions:&/usr/local/php/lib/php/extensions/no-debug-non-zts-/#编译安装完成后最后为提示这样一句###=================================================================#######9、在php的配置文件里面装载memcache.so的模块路径###vim /etc/php.ini##########extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-/memcache.so##########################################[root@jie2 ~]# cd xcache-3.0.3###10、安装FastCGI加速opcode代码的软件[root@jie2 xcache-3.0.3]# /usr/local/php/bin/phpize[root@jie2 xcache-3.0.3]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config && make && make install####==============================================================######Installing shared extensions:&/usr/local/php/lib/php/extensions/no-debug-non-zts-/#编译安装完成后最后为会提示这样一句###=================================================================#######11、建立xcache的配置文件,在xcache的解压的源码包里面[root@jie2 xcache-3.0.3]# mkdir /etc/php.d[root@jie2 xcache-3.0.3]# cp xcache.ini /etc/php.d/##建立这个xcache的配置文件,则可以把xcache.so的模块装载进去,不建立xcache的配置文件,则也可以把xcache.so的模块装载到php.ini的配置文件中,装载方法和装载memcache.so模块的方法一样[root@jie2 xcache-3.0.3]# service php-fpm restart& #重启php-fpm服务Gracefully shutting down php-fpm .&doneStarting php-fpm&&doneMemcached服务器的配置安装123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899<div number100="" index99=""
alt1"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number101="" index100=""
alt2"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number102="" index101=""
alt1"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number103="" index102=""
alt2"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number104="" index103=""
alt1"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number105="" index104=""
alt2"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number106="" index105=""
alt1"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number107="" index106=""
alt2"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number108="" index107=""
alt1"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number109="" index108=""
alt2"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number110="" index109=""
alt1"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number111="" index110=""
alt2"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number112="" index111=""
alt1"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #<div number113="" index112=""
alt2"="" style="word-wrap: padding: 0px 0.5em 0px 1em ! margin: 0px ! border-top-left-radius: 0px ! border-top-right-radius: 0px ! border-bottom-right-radius: 0px ! border-bottom-left-radius: 0px ! background-image: none ! border-width: 0px 3px 0px 0px ! border-right-style: solid ! border-right-color: #6ce26c ! bottom: auto ! float: none ! left: auto ! line-height: 1.1em ! outline: 0px ! overflow: visible ! position: static ! right: auto ! text-align: right ! top: auto ! vertical-align: baseline ! width: auto ! box-sizing: content-box ! font-size: 1em ! min-height: inherit ! white-space: pre ! border-top-style: border-bottom-style: border-left-style: border-top-color: #0099 border-bottom-color: #0099 border-left-color: #[root@jie3 ~]#yum -y groupinstall "Server Platform Development" "Development tools" #安装开发包[root@jie3 ~]# lsanaconda-ks.cfg&&install.log.syslog&&&&&&&&&&&& memcached-1.4.15.tar.gzinstall.log&&&&& libevent-2.0.21-stable.tar.gz###1、解压下载的软件[root@jie3 ~]# tar xf libevent-2.0.21-stable.tar.gz[root@jie3 ~]# tar xf memcached-1.4.15.tar.gz###2、编译安装libevent软件[root@jie3 ~]# cd libevent-2.0.21-stable[root@jie3 libevent-2.0.21-stable]# ./configure --prefix=/usr/local/libevent && make && make install[root@jie3 ~]# cd /usr/local/libevent/###3、使系统识别libevent的库文件和头文件[root@jie3 libevent]# echo "/usr/local/libevent/lib" &/etc/ld.so.conf.d/libevent.conf[root@jie3 libevent]# ldconfig -v | grep libevent/usr/local/libevent/lib:&&&&libevent_core-2.0.so.5 -& libevent_core.so&&&&libevent_openssl-2.0.so.5 -& libevent_openssl.so&&&&libevent_pthreads-2.0.so.5 -& libevent_pthreads.so&&&&libevent-2.0.so.5 -& libevent.so&&&&libevent_extra-2.0.so.5 -& libevent_extra.so&&&&libevent-1.4.so.2 -& libevent-1.4.so.2.1.3&&&&libevent_extra-1.4.so.2 -& libevent_extra-1.4.so.2.1.3&&&&libevent_core-1.4.so.2 -& libevent_core-1.4.so.2.1.3[root@jie3 libevent]# ln -sv /usr/local/libevent/ /usr/include/libevent`/usr/include/libevent' -& `/usr/local/libevent/'###4、编译安装memcached软件包[root@jie3 ~]#cd memcached-1.4.15[root@jie3 ~]#./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/ && make && make install###5、建立memcached的systemV脚本,copy下面的脚本为服务脚本#############vim& /etc/init.d/memcached########################!/bin/bash## Init file for memcached## chkconfig: - 86 14# description: Distributed memory caching daemon## processname: memcached# config: /etc/sysconfig/memcached.&/etc/rc.d/init.d/functions## Default variablesPORT="11211"USER="nobody"MAXCONN="1024"CACHESIZE="64"IP="172.16.22.3"RETVAL=0prog="/usr/local/memcached/bin/memcached"desc="Distributed memory caching"lockfile="/var/lock/subsys/memcached"start() {&&&&&&&&echo&-n $"Starting $desc (memcached): "&&&&&&&&daemon $prog -d -p $PORT -u $USER -c $MAXCONN -m $CACHESIZE -l $IP&&&&&&&&RETVAL=$?&&&&&&&&[ $RETVAL -eq&0 ] && success &&&touch&$lockfile || failure&&&&&&&&echo&&&&&&&&return&$RETVAL}stop() {&&&&&&&&echo&-n $"Shutting down $desc (memcached): "&&&&&&&&killproc $prog&&&&&&&&RETVAL=$?&&&&&&&&[ $RETVAL -eq&0 ] && success &&&rm&-f $lockfile || failure&&&&&&&&echo&&&&&&&&return&$RETVAL}restart() {&&&&&&&&stop&&&&&&&&start}reload() {&&&&&&&&echo&-n $"Reloading $desc ($prog): "&&&&&&&&killproc $prog -HUP&&&&&&&&RETVAL=$?&&&&&&&&[ $RETVAL -eq&0 ] && success || failure&&&&&&&&echo&&&&&&&&return&$RETVAL}case&"$1"&in&&start)&&&&&&&&start&&&&&&&&;;&&stop)&&&&&&&&stop&&&&&&&&;;&&restart)&&&&&&&&restart&&&&&&&&;;&&condrestart)&&&&&&&&[ -e $lockfile ] && restart&&&&&&&&RETVAL=$?&&&&&&&&;;&&&&reload)&&&&&&&&reload&&&&&&&&;;&&status)&&&&&&&&status $prog&&&&&&&&RETVAL=$?&&&&&&&&;;&&&*)&&&&&&&&echo&$"Usage: $0 {start|stop|restart|condrestart|status}"&&&&&&&&RETVAL=1esacexit&$RETVAL#######################################################################6、把服务脚本给予执行权限,然后把服务加到开机启动列表中[root@jie3 memcached]# chmod +x /etc/init.d/memcached[root@jie3 memcached]# chkconfig --add memcached[root@jie3 memcached]# chkconfig --level 35 memcached on[root@jie3 /]# service memcached startStarting Distributed memory caching (memcached):&&&&&&&&&& [& OK& ][root@jie3 /]# netstat -pant | grep memcachedtcp&&&&&&& 0&&&&& 0 172.16.22.3:11211&&&&&&&&&& 0.0.0.0:*&&&&&&&&&&&&&&&&&& LISTEN&&&&& 9802/memcachedMysql服务器的配置安装:12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788[root@jie4 ~]# lsanaconda-ks.cfg&&install.log.sysloginstall.log&&&&& mysql-5.5.33-linux2.6-x86_64.tar.gz###1、解压下载的mysql的通用二进制软件包[root@jie4 ~]#tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz -C /usr/local/[root@jie4 ~]# cd /usr/local/[root@jie4&local]# mv mysql-5.5.33-linux2.6-x86_64/ mysql###2、创建存放数据库的文件,生产环境数据库存放在独立的建LVM的硬盘上面[root@jie4&local]# mkdir -pv /mysql/datamkdir: created directory `/mysql'mkdir: created directory `/mysql/data'###3、创建用户,和设置文件的属主和权限[root@jie4&local]# useradd -r mysql[root@jie4&local]# chown -R mysql:mysql /mysql/data[root@jie4&local]# chmod -R 755 /mysql/data/[root@jie4&local]# cd /usr/local/mysql/[root@jie4 mysql]# cd support-files/###4、建立mysql的配置文件[root@jie4 support-files]# cp f /fcp: overwrite `/etc/my.cnf'? y###5、建立mysql的systemV服务脚本[root@jie4 support-files]# cp mysql.server& /etc/rc.d/init.d/mysqld[root@jie4 ~]# vim /f###6、修改mysql的配置文件,修改或添加这两行#############vim /f###############thread_concurrency = 4datadir =&/mysql/data##############################################7、初始化mysql的脚本[root@jie4 support-files]# cd /usr/local/mysql/scripts/[root@jie4 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data###8、开启mysql服务和把mysql的服务加入到开机自启的列表中[root@jie4 scripts]# service mysqld startStarting MySQL...........&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& [& OK& ][root@jie4&local]# chkconfig& --add mysqld[root@jie4&local]# chkconfig --level 35 mysqld on[root@jie4 scripts]# cd /usr/local/mysql/###9、使系统能识别源码包安装的软件################1)修改环境变量PATH的路径####2)链接头文件的路径####3)连接库文件####4)提供man帮助文档[root@jie4 mysql]# echo "PATH=/usr/local/mysql/bin:$PATH" &/etc/profile.d/mysqld.sh[root@jie4 mysql]# source /etc/profile.d/mysqld.sh[root@jie4 mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysqld`/usr/include/mysqld' -& `/usr/local/mysql/include/'[root@jie4 mysql]# echo "/usr/local/mysql/lib/" &/etc/ld.so.conf.d/mysqld.conf[root@jie4 mysql]# ldconfig -v | grep mysql####10、创建登录数据库的用户的密码[root@jie4&local]# mysqladmin -u root password redhat[root@jie4&local]# mysql -u root -pmysql&&select&user,password,host from mysql.#查询mysql数据库中user表的用户,密码和host+------+-------------------------------------------+-----------+| user | password&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | host&&&&& |+------+-------------------------------------------+-----------+| root | *84BB5DFBBF86CE6EEE9 | localhost || root |&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | & || root |&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | 127.0.0.1 || root |&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | ::1&&&&&& ||&&&&& |&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | localhost ||&&&&& |&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | & |+------+-------------------------------------------+-----------+6 rows&in&set&(0.00 sec)#删除数据库的安全隐患的用户mysql& drop user root@'::1';Query OK, 0 rows affected (0.00 sec)mysql& drop user root@'';Query OK, 0 rows affected (0.00 sec)mysql& drop user&''@'';Query OK, 0 rows affected (0.00 sec)mysql& drop user&''@'localhost';Query OK, 0 rows affected (0.00 sec)#创建指定网段能访问数据库的用户名和密码mysql& create user root@'172.16.%.%'&identified by&'mypass';Query OK, 0 rows affected (0.00 sec)mysql&&select&user,password,host from mysql.+------+-------------------------------------------+------------+| user | password&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | host&&&&&& |+------+-------------------------------------------+------------+| root | *84BB5DFBBF86CE6EEE9 | localhost& || root |&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& | 127.0.0.1& || root | *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4 | 172.16.%.% |+------+-------------------------------------------+------------+3 rows&in&set&(0.01 sec)mysql&&&#重读授权表,及时生效Query OK, 0 rows affected (0.00 sec)mysql& \q& &到此为止每个服务器独立提供的服务已经安装搭建完成,现在需要让他们协同一起工作,用户的体验就好像是工作在一台机器上面1)解决Apache与FastCGI的协同工作& &a)Apache服务器的操作1234567891011121314151617181920212223242526272829303132333435363738[root@jie1 ~]# vim /usr/local/apache/conf/httpd.conf###########vim /usr/local/apache/conf/httpd.conf ############DocumentRoot "/usr/local/apache/htdocs"& #注释这行LoadModule proxy_module modules/mod_proxy.so&&#开启代理的模块LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so#开启连接fastcgi的模块Include conf/extra/httpd-vhosts.conf&#开启让主配置文件载入虚拟主机的配置文件############################################################[root@jie1 ~]# vim /usr/local/apache/conf/extra/httpd-vhosts.conf#####vim& /usr/local/apache/conf/extra/httpd-vhosts.conf#############开启一个虚拟主机即可&VirtualHost *:80&&&&&DocumentRoot&"/web/htdocs/"&&#Apache服务器存放网页的目录&&&&ServerName &&&&Directory&"/web/htdocs"&&&&&&&&AllowOverride None&&&&&&&Options None&&&&&Require all granted&&&&/Directory&&&&&ProxyRequests Off&&#关闭代理请求&&&&ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.22.2:9000/website/$1&&&#把接收客户端来着php的请求,转到FastCGI服务器上面去执行,website是指#FastCGI服务存放php网页的目录&/VirtualHost&#####################################################################[root@jie1 ~]# mkdir -pv /web/htdocsmkdir: created directory `/web'mkdir: created directory `/web/htdocs'[root@jie1 ~]# vim /web/htdocs/test.php####vim /web/htdocs/test.php#####测试php网页的页面&?php&&&&phpinfo();?&#####################################[root@jie1 htdocs]# service httpd restartStopping httpd:&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& [& OK& ]Starting httpd:&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& [& OK& ][root@jie1 htdocs]#&b)FastCGI服务器的操作12345[root@jie2 ~]# mkdir /website& #建立存放网页的目录[root@jie2 website]# scp 172.16.22.1:/web/htdocs/test.php& ./& #把Apache服务器上面的网页文件copy到FastCGI服务器上面,且存放在website目录下[root@jie2 website]# service php-fpm restart& #重启FastCGI服务器Gracefully shutting down php-fpm .&doneStarting php-fpm&&done& &c)测试结果2、解决PHP-FPM(FastCGI)怎么连接Memcached因为我们之前已经在FastCGI安装了连接memcached的软件包memcache且把memcache.so模块装载到php的配置文件中了,这样就实现了PH-FPM(FastCGI)连接Memcached。a)在Apache服务器上网页存放路径下新建mem.php的测试页面& &[root@jie1 htdocs]# cat /web/htdocs/mem.php& &&?php& &$mem = new M& &$mem-&connect("172.16.22.3", 11211);& &$mem-&set('key','test info');& &print_r($mem-&get('key'));& &print_r($mem-&getstats());& &?&b)在FastCGI服务器上面copy mem.php的测试页面[root@jie2 website]# scp 172.16.22.1:/web/htdocs/mem.php &./c)测试结果在生产环境中是否要用memcached服务器缓存数据,取决于客户请求的php程序,当用户请求的php程序中,开发人员将此程序开发需要请求memcached服务器则会用到memcached服务器来缓存客户的数据。在此仅供测试FastCGI服务器是否能连接memcached服务器。3、解决PHP-FPM(FastCGI)怎么连接MysqlPHP-FPM连接mysql,在编译的时候可以加这三个参数,然后PHP-FPM服务器上也可以不用安装mysql也可以连接mysqld服务器。--with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnda)在Apache服务器上网页存放路径下新建testdb.php的测试页面& & & &[root@jie1 htdocs]# cat testdb.php& & & &&?php& & & &$link=mysql_connect('172.16.22.4','root','mypass');& & & &if($link) echo "mysql test success!!";& & & &else echo "mysql test failed!!!";& & & &mysql_close();& & & &?&b)在FastCGI服务器上面copy testdb.php的测试页面& & [root@jie2 website]# scp 172.16.22.1:/web/htdocs/testdb.php &./c)测试结果& & 自此,已经解决WEB怎么连接PHP-FPM(FastCGI),解决PHP-FPM(FastCGI)怎么连接Memcached,解决PHP-FPM(FastCGI)怎么连接Mysql,LAMMP分别搭建在不同的服务器上且可以协同工作已经完成。三、LAMMP适用的生产环境& & 由于memcached只是把数据缓存到内存中,当memcached服务器宕机之后,memcached保存的数据就丢失了,所以在电商站点对session的数据要求严格是memcached服务器不能适用于此生成环境,如果不是电商站点,只是想加快客户访问自己的网站的速度,那memcached所能提供的速度还是很大的,因为数据时直接缓存在内存中了,那速度就可以而知,&#8220;尽情期待能保存电商站点的session回话中的数据之Redis架构的搭建&#8221;。本文出自 &#8220;技术之路---桀&#8221; 博客,请务必保留此出处http://litaotao./2360
&&&&如果您喜欢IT行业或者对IT行业感兴趣,欢迎加入本站官方QQ群:,在群里认识新朋友和交流技术^_^
更多内容如下:
Powered by
& 2013 &&&

我要回帖

更多关于 wcf 分布式系统 的文章

 

随机推荐