zoukankan      html  css  js  c++  java
  • Linux学习笔记14架设Apache http服务器

    图形环境下单击“Applications → System Settings → Add/Remove Application”菜单项,
    在Server下找的"Web Server"选项,并选中,然后点Update按钮,按提示安装。
    如图1-2:
    图1:

    图2:

    安装前需要把加载Linux系统安装光盘。
    如图3:
    图3:


    安装好Apache服务器,可以在命令窗口输入命令来启动Apache服务:
    [root@CentOS4 ~]# /etc/rc.d/init.d/httpd start
    Starting httpd: [  OK  ]
    [root@CentOS4 ~]#


    启动之后,初步对HTTP服务进行简单测试,如图4:
    图4:


    关闭Apache服务:
    [root@CentOS4 ~]# /etc/rc.d/init.d/httpd stop
    Stopping httpd: [  OK  ]


    重新启动Apache服务:
    [root@CentOS4 ~]# /etc/rc.d/init.d/httpd restart
    Stopping httpd: [  OK  ]
    Starting httpd: [  OK  ]


    接下来就简单了解配置HTTP(Apache)服务器:
    配置文件httpd.conf位于/etc/httpd/conf目录下.

    [root@CentOS4 ~]# cat /etc/httpd/conf/httpd.conf
    #
    # Based upon the NCSA server configuration files originally by Rob McCool.
    #
    # This is the main Apache server configuration file.  It contains the
    # configuration directives that give the server its instructions.
    # See <URL:http://httpd.apache.org/docs-2.0/> for detailed information about
    # the directives.
    #
    # Do NOT simply read the instructions in here without understanding
    # what they do.  They're here only as hints or reminders.  If you are unsure
    # consult the online docs. You have been warned.  
    #
    # The configuration directives are grouped into three basic sections:
    #  1. Directives that control the operation of the Apache server process as a
    #     whole (the 'global environment').
    #  2. Directives that define the parameters of the 'main' or 'default' server,
    #     which responds to requests that aren't handled by a virtual host.
    #     These directives also provide default values for the settings
    #     of all virtual hosts.
    #  3. Settings for virtual hosts, which allow Web requests to be sent to
    #     different IP addresses or hostnames and have them handled by the
    #     same Apache server process.

    ... ...


    配置文件基本分为三个小节,一个global environment全局环境,一个'main' or 'default' server
    主服务/默认服务器配置,还有一个是Settings for virtual hosts虚拟端口配置。

    常用配置参数有:
    DocumentRoot "/var/www/html"  该参数指定Apache服务器存放网页的路径

    图形界面配置显示如图5:
    图5:


    MaxClients 118  该参数限制Apache所能提供服务的最高数值,最大可以设置到256。

    命令行:
    ... ...省略部分
    # prefork MPM
    # StartServers: number of server processes to start
    # MinSpareServers: minimum number of server processes which are kept spare
    # MaxSpareServers: maximum number of server processes which are kept spare
    # MaxClients: maximum number of server processes allowed to start
    # MaxRequestsPerChild: maximum number of requests a server process serves
    <IfModule prefork.c>
    StartServers 8
    MinSpareServers 5
    MaxSpareServers 20
    MaxClients 118
    MaxRequestsPerChild 100
    </IfModule>
    ... ...省略部分


    图形界面配置显示如图6:
    图6:



    Port 80  指定Apache服务器的监听端口,标准的HTTP服务器默认端口为80。

    命令行:
    ... ...省略部分
    # Listen: Allows you to bind Apache to specific IP addresses and/or
    # ports, in addition to the default. See also the <VirtualHost>
    # directive.
    #
    # Change this to Listen on specific IP addresses as shown below to
    # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
    #
    #Listen 12.34.56.78:80
    Listen *:80
    ... ...省略部分


    图形界面配置显示如图7:
    图7:


    ServerName CentOS 设置主机名.需要在DNS服务器注册该主机名才可以使用该名来访问,不然得指定IP地址。
    命令行:
    ... ...省略部分
    # ServerName gives the name and port that the server uses to identify itself.
    # This can often be determined automatically, but we recommend you specify
    # it explicitly to prevent problems during startup.
    #
    # If this is not set to valid DNS name for your host, server-generated
    # redirections will not work.  See also the UseCanonicalName directive.
    #
    # If your host doesn't have a registered DNS name, enter its IP address here.
    # You will have to access it by its address anyway, and this will make
    # redirections work in a sensible way.
    #
    ServerName CentOS

    ... ...省略部分



    MaxKeepAliveRequests 100 当使用保持连接(Persistent Connection)功能时,
    可以使用本参数决定每次连接所能发出的要求数目的上限.

    MaxRequestsPerChild 10  该参数限制每个子进程(Child Process)在结束前所能处理的请求数目,一旦达到该数目,这个子进程就会被中止,以避免长时间占据Apache(或者Apache服务器所采用的函数库),
    防止造成内存或者其他系统资源的超负荷。

    MaxSpareServers 和MinSpareServers 提供Web服务的HTTP守护进程.

    配置Apache时,我们可以选择图形界面配置
    或者通过修改配置文件httpd.conf参数进行配置。

    [完]



  • 相关阅读:
    程序员的一天
    美团点评云真机平台实践
    第5波:5本《自动化平台测试开发》+5本《软件自动化测试开发》又双叒叕来送书了...
    软件测试:管理篇
    软件测试:用例篇
    转载ASP.NET MVC 和ASP.NET Web Form简单区别
    转载ASP.NET 状态管理Application,Session,Cookie和ViewState用法
    转载 asp.net中ViewState的用法详解
    在ASP.NET中如何运行后台任务
    转载 .net中的dll.refresh文件和pdb文件
  • 原文地址:https://www.cnblogs.com/wghao/p/956577.html
Copyright © 2011-2022 走看看