国语自产精品视频在线看:您身边最放心的安全下载站! 最新软件|热门排行|软件分类|软件专题|厂商大全

国语自产精品视频在线看

技术教程
您的位置:首页服务器类Web服务器 → Apache安装配置优化

Apache安装配置优化

我要评论 2009/04/30 02:39:52 来源:国语自产精品视频在线看 编辑:编辑整理 [ ] 评论:0 点击:1593次

  Apache 安装😏、配置【pèi zhì】、优化

  安装 Apache 2.0.48 (查看🍄Install手册【shǒu cè】)

  考虑到【kǎo lǜ dào】以后要 rewite_url 来使【lái shǐ】🍈 google 更加容易收录👊网站【wǎng zhàn】,特地添加了😎 mod_rewrite 。

  同时为【tóng shí wéi】了😜限制流量【liàng】,特别加【tè bié jiā】了😜 mod_limitpcnn.c 补丁 , 所以多🐳了😜一个【yī gè】 --enable-forward 选项⛳。

  建议安🎞装完毕以后不🧔要删除【yào shān chú】安装目录【lù】😫,以便以后升级【hòu shēng jí】时使用。

  记得升【jì dé shēng】级前关⌚闭 apache2.0

  编译过程:

  代码:

 #./configure --enable-so --enable-speling --enable-rewrite --with-ssl=/usr/local/ssl --enable-forward
# make
# make install

  这个例💿子里面🧥是编译【shì biān yì】了【le】 mod_so,mod_speling 和 openssl 支持。

  同样有另外几种写法

  代码:

 #./configure --enable-modules=so --enable-modules=speling --enable-modules=rewrite

  或者

  代码:

 #./configure --enable-modules=”so speling”

  --enable-MODULE[=shared] 编译并包含模块【kuài】 MODULE. MODULE 是文档⏮中去掉” _module ”的模块【kuài】🕦名【míng】。要将一🐘个模块【kuài】编译成【biān yì chéng】🧣为 DSO, 需要加🐇 -shared 选项【xuǎn xiàng】 , 即 --enable-mods-shared 。 (查看【chá kàn】 MODULE 手册)

  注意【zhù yì】 :"如果希望核心😁能够装载 DSO,而不实【ér bú shí】🥚际编译任何动🐟态模块,则要明【zé yào míng】确指定 --enable-modules=so 或者 --enable-so" (查看 DSO 手册🐱),所以前【suǒ yǐ qián】面的顺【miàn de shùn】🚽序不能交换顺🤲序。 查看所有apache 的【de】🍎 configure 参数【cān shù】

  安装完👪毕后可【bì hòu kě】📡以用以下命令【xià mìng lìng】😏来查看启动了【qǐ dòng le】那些模块

  代码:

 # apachectl -l
Compiled in modules:
core.c 
mod_access.c
mod_auth.c
mod_include.c
mod_log_config.c
mod_env.c
mod_setenvif.c
prefork.c
http_core.c
mod_mime.c
mod_status.c
mod_autoindex.c
mod_asis.c
mod_cgi.c
mod_negotiation.c
mod_dir.c mod_imap.c
mod_actions.c
mod_speling.c
mod_userdir.c
mod_alias.c
mod_rewrite.c
mod_so.c

  接着【jiē zhe】,将启动【jiāng qǐ dòng】🐜程序放入开机程序中🦃去【qù】。 如果要【rú guǒ yào】🛅启动👖 ssl 加密网页【yè】,则必须通过手🍰动启动👖 apache2.0 (参见 ssl 部分 )

  代码:

 # echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local

  参考:

  代码:

 If you want your server to continue running after a system reboot ,
you should add a call to apachectl to your system startup files (typically rc.local or
a file in an rc.N directory). This will start Apache as root. Before doing this ensure
that your server is properly configured for security and access restrictions.

  在【zài】🌘 profile 里面添加以上🕳的语句🌂来设置【lái shè zhì】🔩路径【lù jìng】,使得在【zài】🌘 bash 下更容【xià gèng róng】易控制 apachectl, 省去了输入路径【lù jìng】的麻烦。

  代码:

 # vi /etc/profile
PATH=" $PATH:usr/local/apache2/bin:”

  配置 apache2.0

  代码:

 # vi /usr/local/apache2/conf/httpd.conf 

  配置文件【wén jiàn】请看🏺文件【wén jiàn】 httpd.conf (设置文🤺档目录【dàng mù lù】为/home/dalouis/public_html)

  代码:

 #chmod 755 – R /home/dalouis/ 

  设置目录的可【lù de kě】🎡读性为 drwxr-xr-x(755), 否则会出现【chū xiàn】🎍 "Forbidden You don't have permission to access / on this server."

  一些关于安全性的配置:

  考虑到【kǎo lǜ dào】 cgi-bin 的安全【de ān quán】性问题,我们暂时将 cgi-bin 去掉【qù diào】。将所有🦋 httpd.conf 中的所有关于🚚 cgi-bin 的行加🏮上【shàng】📳 #.

  Xiyang 的配置

  我用的【wǒ yòng de】🐬: mod_limitipconn, mod_expires, mod_gzip, mod_php4, mod_so, mod_access, mod_alias, mod_userdir, mod_dir, mod_autoindex, mod_status, mod_mime, mod_log_config, http_core

  关于超时的问题

  在我编写好所有的产品查看【pǐn chá kàn】页面的【yè miàn de】时候,经常会【jīng cháng huì】出现因为超时【wéi chāo shí】🌏,或者流🖍量过大 ,apache 停止工🛣作的问🐉题🧒,原因有二【èr】,一是代🛃码的不科学性【kē xué xìng】,二【èr】是 apache 的设置【de shè zhì】📔问题🧒。

  以下是对设置的一点改动:

  代码:

# KeepAlive: Whether or not to allow persistent connections(more than
# one request per connection). Set to "Off" to deactivate.

# KeepAlive Off

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.

# MaxKeepAliveRequests 0

# KeepAliveTimeout: Number of seconds to wait for the next request
# from the same client on the same connection.

# KeepAliveTimeout 0

  ? 记录访问者的【wèn zhě de】🎩 HTTP-REFERER 和 AGENT, 有助于统计来者是通🌩过什么【guò shí me】搜索引🏛擎找到我们的网站的🦌。 或者在【huò zhě zài】原有的【yuán yǒu de】CustomLog行🆙,将参数【jiāng cān shù】由【yóu】 common 改成😲 combined

  代码:

 # If you would like to have agent and referer logfiles,
# uncomment the following directives.
CustomLog logs/referer_log referer 
CustomLog logs/agent_log agent 
CustomLog logs/www.domain.com-access_log combined

  使用 mod_limitipconn.c 来限制 apache 的并发【de bìng fā】🌼数【shù】🏫

  Package: http://dominia.org/djao/limit/这里的安装建议使用【yì shǐ yòng】动态【dòng tài】 DSO 并【bìng】🔑 patch apache2.0, 以使得 apache2.0 可以认📬识在代理后方的 IP 。但是要📚 重新编【chóng xīn biān】

关键词📐:Apache

阅读本文后您有什么感想? 已有 人给出评价!

  • 46 欢迎喜欢
  • 2 白痴
  • 2 拜托
  • 2 哇
  • 2 加油
  • 2 鄙视