您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 销售管理 > Ubuntu-Server最佳方案03
第3333章用Apache做Web服务器最佳方案523.2Apache的安装、配置3.2.1Apache的安装$sudoapt-getinstallapache23.2.2Apache的配置2.Apache模块$sudoa2enmodWhichmodulewouldyouliketoenable?Yourchoicesare:actionsaliasasisauth_basicauth_digestauthn_aliasauthn_anonauthn_dbdauthn_dbmauthn_defaultauthn_fileauthnz_ldapauthz_dbmauthz_defaultauthz_groupfileauthz_hostauthz_ownerauthz_userautoindexcachecern_metacgidcgicharset_litedav_fsdavdav_lockdbddeflatedirdisk_cachedump_ioenvexpiresext_filterfile_cachefilterheadersidentimagemapincludeinfoldaplog_forensicmem_cachemimemime_magicnegotiationphp5proxy_ajpproxy_balancerproxy_connectproxy_ftpproxy_httpproxyrewritesetenvifspelingsslstatussubstitutesuexecunique_iduserdirusertrackversionvhost_aliasModulename?$sudoa2dismodWhichmodulewouldyouliketodisable?Yourchoicesare:aliasauth_basicauthn_fileauthz_defaultauthz_groupfileauthz_hostauthz_userautoindexcgidirenvmimenegotiationphp5rewritesetenvifstatusModulename?第3章用Apache做Web服务器533.2.3Apache虚拟主机1.创建一个新的虚拟主机$sudocp/etc/apache2/sites-available/default/etc/apache2/sites-available/blog.mytest.com$sudonano/etc/apache2/sites-available/blog.mytest.com$sudomkdir/var/~/h1|sudotee/var/.虚拟主机配置详解NameVirtualHost*VirtualHost*ServerAdminwebmaster@localhostDocumentRoot/var/:debug,info,notice,warn,error,crit,#alert,emerg.LogLevelwarnCustomLog/var/log/apache2/access.logcombinedServerSignatureOnAlias/doc//usr/share/doc/最佳方案54Directory/usr/share/doc/OptionsIndexesMultiViewsFollowSymLinksAllowOverrideNoneOrderdeny,allowDenyfromallAllowfrom127.0.0.0/255.0.0.0::1/128/Directory/VirtualHost(1)NameVirtualHost指令NameVirtualHost192.168.1.10:8080NameVirtualHost*(2)VirtualHost/VirtualHost指令VirtualHostIP地址[:端口号][IP地址[:端口号]]....../VirtualHostVirtualHost192.168.1.10ServerAdminwebmaster@mytest.comDocumentRoot/(3)ServerAdmin指令ServerAdminE-mail地址ServerAdminwebmaster@hiweed.com(4)DocumentRoot指令DocumentRoot/var/(5)Directory/Directory指令Directory/var/*.mytest.com...#将匹配/var/目录下所有以.mytest.com结尾的目录/DirectoryDirectory~^/var/*/[0-9]{3}...#将匹配/var/目录下所有由3位数字构成的目录/Directory(6)Options指令Directory/var/第3章用Apache做Web服务器55Directory/var/(7)AllowOverride指令AllowOverrideAll|None|directive-type[directive-type]...(9)Allow指令Allowfromall|host|env=env-variable[host|env=env-variable]...Allowfromapache.orgAllowfrom.netexample.eduAllowfrom10.1.2.3Allowfrom192.168.1.104192.168.1.205Allowfrom10.1Allowfrom10172.20192.168.2Allowfrom10.1.0.0/255.255.0.0Allowfrom10.1.0.0/16(11)ErrorLog指令ErrorLog/var/log/apache/error_logErrorLog|/usr/local/bin/httpd_errors(13)CustomLog指令CustomLogfile|pipeformat|nickname[env=[!]environment-variable]#使用nicknameLogFormat%h%l%u%t\%r\%s%bcommonCustomLoglogs/access_logcommon#使用格式字符串CustomLoglogs/access_log%h%l%u%t\%r\%s%b(14)ServerSignature指令最佳方案56Apache/2.2.8(Ubuntu)Serveratblog.mytest.comPort80(15)Alias指令AliasURL-pathfile-path|directory-pathAlias/doc//usr/share/doc/3.HTTPS的实现$sudoa2enmodssl$sudoapt-getinstallopenssl$opensslgenrsa-des3-outserver.key1024GeneratingRSAprivatekey,1024bitlongmodulus.........................++++++......++++++eis65537(0x10001)Enterpassphraseforserver.key:(在这里输入密码,越复杂就越安全)Verifying-Enterpassphraseforserver.key:(再输入一次密码)$opensslgenrsa-outserver.key1024GeneratingRSAprivatekey,1024bitlongmodulus.......................++++++..................................................................++++++eis65537(0x10001)$opensslreq-new-keyserver.key-outserver.csr$opensslx509-req-days365-inserver.csr-signkeyserver.key-outserver.crt$sudocpserver.crt/etc/ssl/certs$sudocpserver.key/etc/ssl/privateSSLEngineonSSLOptions+StrictRequireSSLCertificateFile/etc/ssl/certs/server.crtSSLCertificateKeyFile/etc/ssl/private/server.key第3章用Apache做Web服务器57$sudo/etc/init.d/apache2restart4.Apache排错[warn]NameVirtualHost*:0hasnoVirtualHostsapache2:Couldnotdeterminetheserver'sfullyqualifieddomainname,using127.0.0.1forServerName$echoServerNamelocalhost|sudotee/etc/apache2/conf.d/fqdn3.3Apache性能优化3.3.2优化Apache配置2.优化MaxClientsIfModulempm_worker_moduleStartServers2MaxClients150MinSpareThreads25MaxSpareThreads75ThreadsPerChild25MaxRe
本文标题:Ubuntu-Server最佳方案03
链接地址:https://www.777doc.com/doc-6371022 .html