对自己所学的知识进行一个系统的总结。。。平时可能经常用到这些知识,但是没有去总结之类的,或者很容易忽略一些知识点,对提高系统的管理能力和加强系统的认识或许很有帮助
start,stop,reload,restart,status
了解/etc/rc.d/init.d/httpd脚本
{
#!/bin/sh # # Startup script for the Apache Web Server # # chkconfig: 345 85 15 # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: httpd # pidfile: /var/run/httpd.pid # config: /etc/httpd/conf/httpd.conf # Source function library. . /etc/rc.d/init.d/functions # See how we were called. case "$1" in start) echo -n "Starting httpd: " daemon httpd -DSSL echo touch /var/lock/subsys/httpd ;; stop) echo -n "Shutting down http: " killproc httpd echo rm -f /var/lock/subsys/httpd rm -f /var/run/httpd.pid ;; status) status httpd ;; restart) $0 stop $0 start ;; reload) echo -n "Reloading httpd: " killproc httpd -HUP echo ;; *) echo "Usage: $0 {start|stop|restart|reload|status}" exit 1 esac exit 0 |
手动创建和添加httpd脚本
#touch /etc/rc.d/init.d/httpd #vi /etc/rc.d/init.d/httpd #chmod 700 /etc/rc.d/init.d/httpd
#chkconfig --add httpd
#/etc/rc.d/init.d/httpd start
}
熟悉httpd.conf
{
### Section 1: Global Environment
#
ServerType standalone 服务器类型standalone、inetd/xinetd
ServerRoot "/etc/httpd"服务器目录的绝对路径,很多配置文件是相对于这个这个目录的
PidFile /var/run/httpd.pid
ResourceConfig /dev/null
AccessConfig /dev/null
Timeout 300 网络超时时间,单位为秒
KeepAlive On
MaxKeepAliveRequests 0 一个连接中,同时请求数达到多少时,不响应这个连接的新请求 保证系统资源不会被某个连接大量占用。但是在实际配置中要求 尽量把这个数值调高来获得较高的系统性能。0表示无限制
KeepAliveTimeout 15 确保KeepAlive on才会生效。限制每个session的保持时间是15秒 一个TCP连接内可以发送多个请求,节省网络和系统资源。
MinSpareServers 16 限制最少空闲进程数目,加快反应速度
MaxSpareServers 64 最大空闲进程数。这指令表明,当空闲进程超过64个的时候,主进程 会杀掉多余的空闲进程,保持64个,节省系统资源。
StartServers 16 启动Apache后等待接受请求的空闲子进程数目
MaxClients 512 最大连接数
MaxRequestsPerChild 100000
### Section 2: 'Main' server configuration
#
Port 80 服务器运行的端口,默认为80,http标准端口号
<IfDefine SSL>
Listen 80
Listen 443
</IfDefine>
User www 用户ID通常保留默认值nobody
Group www 用户组ID通常保留默认值nogroup
ServerAdmin admin@openna.com 管理服务器的Web管理人员的地址,这个挺重要
ServerName www.openna.com 设置服务器将返回的主机名,真正的域名,存在于DNS
DocumentRoot "/home/httpd/ona" 文档目录树的绝对路径
<Directory />
Options None
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "/home/httpd/ona">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Files .pl>
Options None
AllowOverride None
Order deny,allow
Deny from all
</Files>
<IfModule mod_dir.c>
DirectoryIndex index.htm index.html index.php index.php3 default.html
index.cgi
指明作为目录索引的文件名
</IfModule>
<IfModule mod_userdir.c>
#UserDir disable
UserDir public_html 定义和本地用户的主目录相对的目录,同时修改/home/ower的权限
/home/ower/public_html,修改为755
</IfModule>
#<IfModule mod_include.c>
#Include conf/mmap.conf
#</IfModule>
UseCanonicalName On
<IfModule mod_mime.c>
TypesConfig /etc/httpd/conf/mime.types
</IfModule>
DefaultType text/plain
HostnameLookups Off 对客户端域名验证。on,一次反查;
double,反查之后进行一次正向解析;off,不进行域名验证。
为了安全,使用double,加快反应速度,使用off。
ErrorLog /var/log/httpd/error_log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
\ combined
SetEnvIf Request_URI \.gif$ gif-p_w_picpath
CustomLog /var/log/httpd/access_log combined env=!gif-p_w_picpath
ServerSignature Off
<IfModule mod_alias.c>
ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/"
<Directory "/home/httpd/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
</IfModuleGT;
<IfModule mod_mime.c>
AddEncoding x-compress Z
AddEncoding x-gzip gz tgz
AddType application/x-tar .tgz
</IfModule>
ErrorDocument 500 "The server made a boo boo.
ErrorDocument 404 http://192.168.1.1/error.htm
ErrorDocument 403 "Access Forbidden -- Go away.
<IfModule mod_setenvif.c>
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
</IfModule>
### Section 3: Virtual Hosts
#
<IfDefine SSL>
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
</IfDefine>
<IfModule mod_ssl.c>
SSLPassPhraseDialog builtin
SSLSessionCache dbm:/var/run/ssl_scache
SSLSessionCacheTimeout 300
SSLMutex file:/var/run/ssl_mutex
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
SSLLog /var/log/httpd/ssl_engine_log
SSLLogLevel warn
</IfModule>
<IfDefine SSL>
<VirtualHost _default_:443>
DocumentRoot "/home/httpd/ona"
ServerName www.openna.com
ServerAdmin admin@openna.com
ErrorLog /var/log/httpd/error_log
SSLEngine on
SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key
SSLCACertificatePath /etc/ssl/certs
SSLCACertificateFile /etc/ssl/certs/ca.crt
SSLCARevocationPath /etc/ssl/crl
SSLVerifyClient none
SSLVerifyDepth 10
SSLOptions +ExportCertData +StrictRequire
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
SetEnvIf Request_URI \.gif$ gif-p_w_picpath
CustomLog /var/log/httpd/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" env=!gif-p_w_picpath
</VirtualHost>
</IfDefine>
}
转载于:https://blog.51cto.com/0901huazi/836120