首页 > 代码库 > apace日常操作和配置

apace日常操作和配置

[root@limt modules]# /usr/sbin/apachectl -hUsage: /usr/sbin/httpd [-D name] [-d directory] [-f file]                       [-C "directive"] [-c "directive"]                       [-k start|restart|graceful|graceful-stop|stop]                       [-v] [-V] [-h] [-l] [-L] [-t] [-S]Options:  -D name            : define a name for use in <IfDefine name> directives  -d directory       : specify an alternate initial ServerRoot  -f file            : specify an alternate ServerConfigFile  -C "directive"     : process directive before reading config files  -c "directive"     : process directive after reading config files  -e level           : show startup errors of level (see LogLevel)  -E file            : log startup errors to file  -v                 : show version number  -V                 : show compile settings  -h                 : list available command line options (this page)  -l                 : list compiled in modules  -L                 : list available configuration directives  -t -D DUMP_VHOSTS  : show parsed settings (currently only vhost settings)  -S                 : a synonym for -t -D DUMP_VHOSTS  -t -D DUMP_MODULES : show all loaded modules   -M                 : a synonym for -t -D DUMP_MODULES  -t                 : run syntax check for config files

1 查看apache编译时加载的模块

[root@limt modules]# /usr/sbin/apachectl -lCompiled in modules:  core.c  prefork.c  #采用的多进程模式  http_core.c  mod_so.c

2 看所有可Load的模块

/usr/sbin/apachectl -t -D DUMP_MODULES

3 检查配置文件语法

[root@limt modules]# /usr/sbin/apachectl -t -f /etc/httpd/conf/httpd.conf httpd: Could not reliably determine the servers fully qualified domain name, using 192.168.1.104 for ServerNameSyntax OK

4 启动apache

[root@limt modules]# /usr/sbin/apachectl -k start -f /etc/httpd/conf/httpd.conf httpd: Could not reliably determine the servers fully qualified domain name, using 192.168.1.104 for ServerName[root@limt modules]# ps -ef|grep httproot       6011      1  0 04:26 pts/0    00:00:00 /usr/sbin/nss_pcache 294914 off /etc/httpd/aliasroot       6013      1  4 04:26 ?        00:00:00 /usr/sbin/httpd -k start -f /etc/httpd/conf/httpd.confroot       6015   6013  0 04:26 ?        00:00:00 /usr/bin/crlhelper 327684 6013 /etc/httpd/aliasapache     6016   6013  0 04:26 ?        00:00:00 /usr/sbin/httpd -k start -f /etc/httpd/conf/httpd.confapache     6017   6013  3 04:26 ?        00:00:00 /usr/sbin/httpd -k start -f /etc/httpd/conf/httpd.confapache     6018   6013  2 04:26 ?        00:00:00 /usr/sbin/httpd -k start -f /etc/httpd/conf/httpd.confapache     6019   6013  2 04:26 ?        00:00:00 /usr/sbin/httpd -k start -f /etc/httpd/conf/httpd.confapache     6020   6013  2 04:26 ?        00:00:00 /usr/sbin/httpd -k start -f /etc/httpd/conf/httpd.confapache     6021   6013  3 04:26 ?        00:00:00 /usr/sbin/httpd -k start -f /etc/httpd/conf/httpd.confapache     6022   6013  3 04:26 ?        00:00:00 /usr/sbin/httpd -k start -f /etc/httpd/conf/httpd.confapache     6023   6013  3 04:26 ?        00:00:00 /usr/sbin/httpd -k start -f /etc/httpd/conf/httpd.confapache     6024   6013  4 04:26 ?        00:00:00 /usr/sbin/httpd -k start -f /etc/httpd/conf/httpd.confroot       6026   4496  0 04:27 pts/0    00:00:00 grep http

5 停止apache

[root@limt modules]# /usr/sbin/apachectl -k stophttpd: Could not reliably determine the servers fully qualified domain name, using 192.168.1.104 for ServerName[root@limt modules]# [root@limt modules]# ps -ef|grep httproot       6039   4496  0 04:28 pts/0    00:00:00 grep http

6 配置文件:/etc/httpd/conf/httpd.conf

Section 1: Global EnvironmentServerTokens OS#语法:ServerTokens Major | Minor | Min[imal] | Prod[uctOnly] | OS | Full#默认:ServerTokens Full#这个指令用来控制服务器回应给客户端的“Server:”应答头是否包含关于服务器操作系统类型和编译进的模块描述信息。#注意:在使用ServerTokens指令时要先启用ServerSignature指令。#apache软件安装的位置ServerRoot "/etc/httpd"#主httpd进程(所有其他进程的父进程)的进程号文件位置PidFile run/httpd.pidTimeout 60#开启持久性连接功能。即当客户端连接到服务器,下载完数据后仍然保持连接状态KeepAlive Off#一个连接服务的最多请求次数MaxKeepAliveRequests 100#持续连接多长时间,该连接没有再请求数据,则断开该连接。缺省为15秒KeepAliveTimeout 15#多进程模式# prefork MPM<IfModule prefork.c>StartServers       8MinSpareServers    5MaxSpareServers   20ServerLimit      256MaxClients       256MaxRequestsPerChild  4000</IfModule>#多进程多线程模式# worker MPM<IfModule worker.c>StartServers         4MaxClients         300MinSpareThreads     25MaxSpareThreads     75 ThreadsPerChild     25MaxRequestsPerChild  0</IfModule>#监听端口Listen 8080#加载模块LoadModule auth_basic_module modules/mod_auth_basic.soLoadModule auth_digest_module modules/mod_auth_digest.soLoadModule authn_file_module modules/mod_authn_file.soLoadModule authn_alias_module modules/mod_authn_alias.so#加载conf.d目录的配置模块Include conf.d/*.conf# Section 2: ‘Main‘ server configuration#apache运行的用户User apacheGroup apache#管理员的邮件地址ServerAdmin root@localhostServerName指定Apache用于识别自身的名字和端口号。 # 通常这个值是自动指定的,但是我们推荐你显式的指定它以防止启动时出错 # # 如果你为你的主机指定了一个无效的DNS名,server-generated重定向将不能工作。 # 参见UseCanonicalName指令 # # 如果你的主机没有注册DNS名,在这里键入它的IP地址 # 无论如何,你必须使用它的IP地址来提供服务, # 这里使用一种容易理解的方式重定向服务 ServerName localhost:80 # # UseCanonicalName:决定Apache如何构造URLS和 SERVER_NAME 和 SERVER_PORT 的指令。 # 当设置为 “Off”时,Apache会使用用户端提供的主机名和端口号。 # 当设置为“On”,Apache会使用ServerName指令的值。 # UseCanonicalName Off #主站点的网页存储位置DocumentRoot "/var/www/html"#错误日志文件ErrorLog logs/error_logServerSignature On#Section 3: Virtual Hosts#<VirtualHost *:80>#    ServerAdmin webmaster@dummy-host.example.com#    DocumentRoot /www/docs/dummy-host.example.com#    ServerName dummy-host.example.com#    ErrorLog logs/dummy-host.example.com-error_log#    CustomLog logs/dummy-host.example.com-access_log common#</VirtualHost>

 

apace日常操作和配置