首页
About Me
Search
1
linuxea:gitlab-ci之docker镜像质量品质报告
49,484 阅读
2
linuxea:如何复现查看docker run参数命令
23,648 阅读
3
Graylog收集文件日志实例
18,633 阅读
4
linuxea:jenkins+pipeline+gitlab+ansible快速安装配置(1)
18,423 阅读
5
git+jenkins发布和回滚示例
18,235 阅读
ops
Openppn
Sys Basics
rsync
Mail
NFS
Other
Network
HeartBeat
server 08
Code
Awk
Shell
Python
Golang
vue
virtualization
KVM
Docker
openstack
Xen
kubernetes
kubernetes-cni
Service Mesh
Data
Mariadb
PostgreSQL
MongoDB
Redis
MQ
Ceph
TimescaleDB
kafka
surveillance system
zabbix
ELK Stack/logs
Open-Falcon
Prometheus
victoriaMetrics
Web
apache
Tomcat
Nginx
自动化
Puppet
Ansible
saltstack
Proxy
HAproxy
Lvs
varnish
更多
互联咨询
最后的净土
软件交付
持续集成
gitops
devops
登录
Search
标签搜索
kubernetes
docker
zabbix
Golang
mariadb
持续集成工具
白话容器
elk
linux基础
nginx
dockerfile
Gitlab-ci/cd
最后的净土
基础命令
gitops
jenkins
docker-compose
Istio
haproxy
saltstack
marksugar
累计撰写
667
篇文章
累计收到
111
条评论
首页
栏目
ops
Openppn
Sys Basics
rsync
Mail
NFS
Other
Network
HeartBeat
server 08
Code
Awk
Shell
Python
Golang
vue
virtualization
KVM
Docker
openstack
Xen
kubernetes
kubernetes-cni
Service Mesh
Data
Mariadb
PostgreSQL
MongoDB
Redis
MQ
Ceph
TimescaleDB
kafka
surveillance system
zabbix
ELK Stack/logs
Open-Falcon
Prometheus
victoriaMetrics
Web
apache
Tomcat
Nginx
自动化
Puppet
Ansible
saltstack
Proxy
HAproxy
Lvs
varnish
更多
互联咨询
最后的净土
软件交付
持续集成
gitops
devops
页面
About Me
搜索到
7
篇与
的结果
2016-04-01
apache日志切割
一,cronolog下载ronolog包:wget -P /usr/lcoal https://cronolog.org/download/cronolog-1.6.2.tar.gz1,install:cd /usr/local && tar xf cronolog-1.6.2.tar.gz && cd cronolog-1.6.2 && ./configure && make && make install 2,配置httpd.conf[tangzhengchao@Aliyun-live2 conf]$ vim httpd.conf 搜索关键字找到位置修改278 ErrorLog "|/usr/local/sbin/cronolog /alidata/server/httpd/logs/error_%w.log" 307 CustomLog "|/usr/local/sbin/cronolog /alidata/server/httpd/logs/access_%w.log" combined 日志存放在/alidata/server/httpd/logs/下,以access_和error_开头命名,以%w.log结尾,%w表示0-6的某一天,从开始计算,一直轮询[tangzhengchao@Aliyun-live2 vhosts]$ ll /alidata/server/httpd/logs/ total 480 -rw-r--r-- 1 root root 1203 Mar 30 17:29 error_3.log 3,配置dl.16889999.com.conf[tangzhengchao@Aliyun-live2 vhosts]$ vim dl.16889999.com.conf ErrorLog "|/usr/local/sbin/cronolog /alidata/log/httpd/dl.16889999.com-error-%w.log" CustomLog "|/usr/local/sbin/cronolog /alidata/log/httpd/dl.16889999.com-access-%w.log" vhost_common env=!dontlog [tangzhengchao@Aliyun-live2 vhosts]$ ll /alidata/log/httpd/dl.16889999.com* -rw-r--r-- 1 root root 165445 Mar 30 23:59 /alidata/log/httpd/dl.16889999.com-access-3.log -rw-r--r-- 1 root root 266742 Mar 31 10:39 /alidata/log/httpd/dl.16889999.com-access-4.log 4,配置[tangzhengchao@Aliyun-live2 logs]$ vim ../conf/vhosts/jds.jince.com.confErrorLog "|/usr/local/sbin/cronolog /alidata/log/httpd/jds.jince.com-error-%w.log" CustomLog "|/usr/local/sbin/cronolog /alidata/log/httpd/jds.jince.com-access-%w.log" vhost_common env=!dontlog [tangzhengchao@Aliyun-live2 vhosts]$ ll /alidata/log/httpd/ total 69996 -rw-r--r-- 1 root root 57273 Mar 30 17:37 jds.jince.com-access-3.log -rw-r--r-- 1 root root 38541 Mar 31 10:56 jds.jince.com-access-4.log cronolog配置:ronolog安装完成后,默认/usr/local/sbin/cronolog在$apache.conf中(或者vhosts配置文件)错误日志 "|cronolog位置 /日志存放路径_%w周期.logErrorLog "|/usr/local/sbin/cronolog /alidata/server/httpd/logs/error_%w.log"访问日志 "|cronolog位置 /日志存放路径_%w周期.log combined 结尾CustomLog "|/usr/local/sbin/cronolog /alidata/server/httpd/logs/access_%w.log" combined当设置完成后,会从日期的形式(每日)自动分割日志。如:access_0.log ,直到access_6.log结尾,下个周期则轮训覆盖,只保留最新7天日志!二:rotatelogs分割找出rotatelogs位置[root@localhost local]# find / -name rotatelogs /usr/sbin/rotatelogs 修改配置文件ErrorLog "| /usr/sbin/rotatelogs /var/log/httpd/error_%Y%m%d.log 86400 480" CustomLog "| /usr/sbin/rotatelogs /var/log/httpd/access_%Y%m%d.log 86400 480" common 86400:86400 表示一天,即每天生成一个新的日志文件。480:相对于UTC的时差的分钟数。如果省略,则默认为0,并使用UTC时间。比如,要指定UTC时差为-5小时的地区的当地时间,则此参数应为-300,北京时间为+8时间,应设置为480。这样日志里的时间才会和服务器上的时间一致,方便查看日志。
2016年04月01日
3,864 阅读
1 评论
0 点赞
2015-11-03
httpd2.4特性之httpd2.2区别
httpd2.4 httpd2.4的新特性(1)MPM支持允许DOS机制(2)支持event MPM(3)支持异步读写(4)支持每个模块及每个目录分别使用各自的日志级别(5)支持每个请求配置<if>(6)增强版的表达式分析器(7)支持毫秒级的keepalive timeout(8)基于FQDN的虚拟主机不再需要NameVirtualHost指令(9)支持用户自定义变量 新模块:(1)mod_proxy_fcgi php(2)mod_ratelimit 速率限制(3)mod_remoteip 指明远程客户端ip地址 配置机制的修改 不再支持使用Order,Deny,Allow来做基于IP的访问控制 httpd依赖于apr,apr-util,apr-iconapr:apache protable runtime 安装可参考下面文档https://www.linuxea.com/index.php/archives/apachectl2-4.html 配置:1,切换使用mpmLoadModule mpm_NAME_module modules/mod_mpm_NAME.so NAME:prefork,event,worker2,修改主机的文档路径,'Main' server的DocumentRoot3,基于IP的访问控制法则允许所有主机访问:Require all granted拒绝所有主机访问:Require all deny 控制特定IP访问: Require ip IPADDR :授权指定来源地址的主机访问 Require not ip IPADDR:拒绝指定来源地址的主机访问 IPADDR: IP:172.16.100.100 network/mask:172.16.100.100/23 network/mask:172.168.100.100/16 虚拟主机!#vim /etc/httpd24/extra/httpd-vhsots.conf<VirtualHost *:80> ServerAdmin webmaster@a.com DocumentRoot "/vhost/a.com" ServerName www.a.com ErrorLog "logs/www.a.com-error_log" CustomLog "logs/www.a.com-access_log" combined <Directory "/vhost/a.com"> Options none AllowOverride none Require all granted </Directory></VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@b.com DocumentRoot "/vhost/b.com" ServerName www.b.com ErrorLog "logs/www.b.com-error_log" CustomLog "logs/www.b.com-access_log" combined <Directory "/vhost/b.com"> Options none AllowOverride none Require all granted </Directory></VirtualHost>
2015年11月03日
3,896 阅读
0 评论
0 点赞
2015-11-03
httpd2.2/ab/crul/https配置(三)
crulCurl命令是基于URL语法在命令行内下工作的文件传输工具,支持FTP,FPTS,HTTP,HTTPS,GOPHER,TELNET,LDAP通常我们使用curl查看会在日志中出现crul/7.19.7如此类的字段,如果不想看到,则可以模拟,如下:[root@www ~]# curl https://192.168.233.138 www.1.com [root@www ~]# tail /var/log/httpd/access_log 192.168.233.138 - - [02/Nov/2015:05:21:26 -0800] "GET / HTTP/1.1" 200 10 "-" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2"模拟头部[root@www ~]# curl -A "chrome 40" https://192.168.233.138 www.1.com [root@www ~]# tail /var/log/httpd/access_log 192.168.233.138 - - [02/Nov/2015:05:22:24 -0800] "GET / HTTP/1.1" 200 10 "-" "chrome 40"模拟跳转:[root@www ~]# curl -A "chrome 40" -e "https://www.linuxea.com" https://192.168.233.138 www.1.com [root@www ~]# tail /var/log/httpd/access_log 192.168.233.138 - - [02/Nov/2015:05:25:41 -0800] "GET / HTTP/1.1" 200 10 "https://www.linuxea.com">https://www.linuxea.com</a>" "chrome 40" [root@www ~]#响应首部信息:[root@www ~]# curl -I 127.0.0.1 HTTP/1.1 200 OK Server: Tengine/2.0.3 Date: Mon, 02 Nov 2015 13:28:21 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive Vary: Accept-Encoding X-Powered-By: PHP/5.3.3 X-Pingback: https://www.linuxea.com/index.php/action/xmlrpc Cache-Control: max-age=0 Expires: Mon, 02 Nov 2015 13:28:21 GMTcurl的选项非常多,部分选项如下:-basic 使用httpd基本认证--cacert CA证书--compressed 要求返回是压缩的格式elinks然而除了curl之外还有一个命令行浏览网站的elinks,并且支持http,https等首先需要安装:[root@www ~]# yum -y install elinks [root@www ~]# elinks https://www.linuxea.com 可以将内容标准输入elinks -dump[root@www ~]# elinks -dump https://www.linuxea.com2,mod_deflate模块压缩页面优化传输速度适用场景:(1)节约带宽,额外消耗CPU时钟周期:同时,可能较老浏览器不支持(2)压缩适于压缩较大的资源文本格式压缩SetOutputFilter DEFLATE # Restrict compression to these MIME types AddOutputFilterByType DEFLATE text/plain; 文本 AddOutputFilterByType DEFLATE text/html 超文本标记语言 AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/css # Level of compression (Highest 9 - Lowest 1) DeflateCompressionLevel 9 # Netscape 4.x has some problems BrowserMatch ^Mozilla/4 gzip-only-text/html 模式匹配 # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4\.0[678] no-gzip 不压缩gzip #MSIE masquerades as Netscape.but it is fine BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html这个可放在虚拟主机中,也可以放全局文件中测试如下:[root@www ~]# curl --compress -I https://www.1.com/fstab.txt HTTP/1.1 200 OK Date: Mon, 02 Nov 2015 14:15:12 GMT Server: Apache/2.2.15 (CentOS) Last-Modified: Mon, 02 Nov 2015 14:14:52 GMT ETag: "ff098-325-5238f669899f3" Accept-Ranges: bytes Vary: Accept-Encoding Content-Encoding: gzip Content-Length: 379 Connection: close Content-Type: text/plain; charset=UTF-8[root@www ~]# curl -I https://www.1.com/fstab.txt HTTP/1.1 200 OK Date: Mon, 02 Nov 2015 14:15:24 GMT Server: Apache/2.2.15 (CentOS) Last-Modified: Mon, 02 Nov 2015 14:14:52 GMT ETag: "ff098-325-5238f669899f3" Accept-Ranges: bytes Content-Length: 805 Vary: Accept-Encoding Connection: close Content-Type: text/plain; charset=UTF-83,httpshttps监听在443端口上,基于sslssl:是基于v3版, tls基于v1版本ssl回话的简化过程(1)客户端发送可选择的加密方式,并向服务器请求证书(2)服务器端发送证书以及选定的加密方式给客户端(3)证书验证如果信任给其发证书的CA (a)验证证书的合法性->用CA的公钥解密证书的签名 (b)解密完成,验证证书内容的合法性:内容完整性验证 (c)检查证书的有效期限: (d)检查证书是否被吊销 (e) 证书中拥有者的名字与访问的目标主机要一致(4)客户端生成临时会话秘钥(对称秘钥),并使用服务器端的公钥加密 配置httpd支持https:(1)为服务器申请数字证书出于测试的目的,私有ca即可,如下: (a)创建私有CA (b)在服务器创建证书签署请求 (c)CA签证(2)配置http支持使用ssl,及使用的证书yum -y install mod_ssl配置文件:/etc/httpd/conf.d/ssl.conf基于IP创建VirtualHost *:443 DocumentRoot "/vhost/1.com/htdocs" ServerName https://www.1.com:443 SSLCertificateFile /etc/httpd/ssl/httpd.crt SSLCertificateKeyFile /etc/httpd/ssl/httpd.key(3)测试基于https访问响应的主机注意:SSL是基于IP地址创建的!单IP主机,只能使用一个https主机!4,httpd自带的工具程序htpasswd:基于basic认证基于文件实现时,用到的账号密码文件生成工具apachectl:apache启动停止脚本,支持start,stopapxs:httpd-devel包提供,扩展httpd使用第三方模块的工具程序rotatelogs:日志滚动工具,access.log,access.1.log,access.2.logsuexec:当http启动后root是主控进程,子进程是普通进程运行,在httpd.conf中的user和group有所指明,在访问某些资源有特殊权限配置的资源时,临时切换至指定用户运行abab:全称apache benchmark ,压力测试工具5,压力测试工具ab:httpd自带的ab工具,并不是很好用,他是一个模拟测试工具,并不是很好的反应实际测试情况,如还有:webbench,http_load!专业的测试工具有:jmeter,这个有专门的测试专员来做,以及loadrunner,这个是具备认证的人员使用。另外一个工具可以还原真实场景 网易开发的一款强大的测试工具:tcpcopy,允许复制真实环境,并且可以重放ab的测试工具使用:ab [OPTIONS] URL-n:总的请求数-c:模拟的并发数-k:本机到本机测试:我这里测试的网络的-n 请求数,-c 并发数[root@www htdocs]# ulimit -n 3000 #调节当前用户同时打开的文件数压测[root@www htdocs]# ab -n 1000 -c 100 https://www.xxxxxx.com/909.html Server Software: Tengine/2.1.0 Server Hostname: https://www.xxxxxx.com Server Port: 80 Document Path: /909.html 页面 Document Length: 36089 bytes 大小 Concurrency Level: 10 并发节点 Time taken for tests: 39.740 seconds 时间 Complete requests: 89 发送的请求 Failed requests: 84 没完成的请求 (Connect: 0, Receive: 0, Length: 84, Exceptions: 0) Write errors: 0 错误的请求 Total transferred: 3458342 bytes发送的字节 HTML transferred: 3432078 bytes传送html量 Requests per second: 2.24 [#/sec] (mean) Time per request: 4465.209 [ms] (mean)平均秒数 Time per request: 446.521 [ms] (mean, across all concurrent requests) 单个请求平均时间 Transfer rate: 84.98 [Kbytes/sec] receivedK字节,带宽的大小 Connection Times (ms) min mean[+/-sd] median max Connect: 28 208 162.2 182 800 Processing: 400 3837 663.4 3967 5669 处理经由时长 Waiting: 199 1880 395.2 1871 2676 等待响应时长 Total: 432 4044 640.1 4167 6066 Percentage of the requests served within a certain time (ms) 50% 4164 66% 4265 75% 4317 80% 4332 90% 4479 95% 4528 98% 4726 99% 6066 100% 6066 (longest request) %100请求的时长 [root@www htdocs]#ab的模拟效果并不是互联网模拟测试效果。
2015年11月03日
5,386 阅读
3 评论
0 点赞
2015-11-01
httpd2.2配置文件详解/虚拟主机配置等 (二)
httpd2.2 (二) 1,定义默认主页面[root@192 ~]# vim /etc/httpd/conf/httpd.confDirectoryIndex index.html index.html.var 如果你需要改为别的页面,在这里定义即可,这里的顺序也重要,从左到右依次匹配。 2,日志错误日志 ErrorLog logs/error_loghttpd路径下的logs是一个软连接,指向/var/log/httpd/lrwxrwxrwx. 1 root root 19 Oct 30 07:19 logs -> ../../var/log/httpd 访问日志CustolLog logs/access_log combined LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined #LogFormat后面的跟的是宏LogFormat "%h %l %u %t \"%r\" %>s %b" commonLogFormat "%{Referer}i -> %U" refererLogFormat "%{User-agent}i" agent %H:Remote host 远程主机%L: 客户端用户通过Identd登录时使用的名称,一般用户名应该为空-%u: 认证登录的名字,无登录机制一般为-表示为空%t:收到客户端请求时的时间\”:显示引号本身,而不作为引号符号%r:请求报文的首行%>s: 响应状态码%b: 响应报文的大小,单位为字节,不包含首部信息%{Referer}i: 记录http首部Referer对应的值:即访问入口,从哪个页面跳转至此页面%{User-Agent}i: 记录http首部User-Agent对应的值,即浏览器类型 详情点击官方文档参考:https://httpd.apache.org/docs/2.2/mod/mod_log_config.html 3,路径别名DocumentRoot "/var/www/html" 比如说,我们在/var/www/html/下建一个images文件夹,文件夹里存放1.html,写入1.html,当我们访问ip/1.html的时候,应该访问的是/var/www/html/1.htmlAlias为:Alias /icons/ "/var/www/icons/" 我们在这里指定一个新的路径,这个路径并不存在Alias /images/ "/web/pics/"Alias /icons/ "/var/www/icons/"Alias /images/ "/web/pics/"此时,我们使用alias的images到/web/pics/,在进行访问就找不到了。 当我们打开日志进行查看,提示这个找不到这个问题。因为这个路径根本就不存在[root@192 images]# cat /var/log/httpd/error_log [Sat Oct 31 07:44:20 2015] [error] [client 192.168.233.1] File does not exist: /web[Sat Oct 31 07:44:20 2015] [error] [client 192.168.233.1] File does not exist: /web[Sat Oct 31 07:44:20 2015] [error] [client 192.168.233.1] File does not exist: /web我们创建这个文件并且复制这个文件[root@192 html]# mkdir -pv /web/pics/ && cp /var/www/html/images/1.html /web/pics/ 复制完成后,访问的页面表示Alias 定义的/web/pics/路径下的1.html了 4,设定默认字符集AddDefaultCharset UTF-8#常用字符集:GBK,GB2312,GB18030 5,基于用户的访问控制质询:WWW-Authenticate:服务器用401状态拒绝客户端请求,说明需要用户提供用户名和密码,弹出对话框认证:Authorization:客户端用户填入账号密码后再次发请求至服务器:认证通过,则请求授权 需要用户认证后才能访问的安全域5.1,安全域名称,提供认证原因说明http协议支持的认证方式:basic和digest,而basic是基于base64编码,basic机制,basic是基本的,目前使用较多,digest浏览器支持的不是很好 5.2示例:创建安全域页面路径[root@192 html]# mkdir linux创建页面文件[root@192 html]# echo tom 11 jreey 123 >> linux/index.html修改配置文件,添加配置[root@192 ~]# vim /etc/httpd/conf/httpd.conf <Directory "/var/www/html/linux"> Options None # none表示不启用任何属性 AllowOverride None #是否允许覆盖 AuthType Basic #认证类型 AuthName "This My Home,Pls Dot Move" #认证领域的名字 AuthUserFile /etc/httpd/users/.htpasswd #这里的用户是虚拟用户,非系统用户 Require User tom,jerry #要求谁能登录,如果有多个用户,使用空格分隔(Require Valid-user #所有合法的账号) </Directory> htpasswd命令用户维护此文件htpasswd命令的使用参数: -c:添加第一个用户时创建此文件 -m:以md5格式加密用户密码存放 -s:以sha格式加密用户密码存放 -D:删除指定用户 开始创建用户[root@192 html]# mkdir /etc/httpd/users#第一次使用-c -m[root@192 html]# htpasswd -c -m /etc/httpd/users/.htpasswd tomNew password: Re-type new password: Adding password for user tom#第二次添加用户则只需要-m即可[root@192 html]# htpasswd -m /etc/httpd/users/.htpasswd jerryNew password: Re-type new password: Adding password for user jerry[root@192 html]# 删除之需要-D指明文件路径下的文件中的用户名即可 组认证:[root@192 html]# vim /etc/httpd/conf/httpd.conf <Directory "/var/www/html/linux"> Options None AllowOverride None AuthType Basic AuthName "This My Home,Pls Dot Move" AuthUserFile /etc/httpd/users/.htpasswd AuthUserFile /etc/httpd/users/.htgroup Require group work #定义一个组,组名叫work </Directory>组文件定义: 每行定义一个组 格式为:Grp_Name:User1 User2 ... [root@192 html]# echo work: tom jerry > /etc/httpd/users/.htgroup 6,虚拟主机一个屋里器可以服务于多个站点,每个站点可通过一个或多个虚拟主机来实现httpd三种类型的虚拟主机:1,基于IP2,基于PORT3,基于FQDN 注意:在定义之前需要关闭Main server[root@192 html]# vim /etc/httpd/conf/httpd.conf#DocumentRoot "/var/www/html" 注释掉 定义虚拟主机的方法:<virtualHost "IP:PORT"> ServerName ServerAlias DocumentRoot</VirtualHost> 注意:大多数可用全局或main server中的指令,都可以定义有VirtualHost中 第一种,基于端口的虚拟主机[root@192 html]# vim /etc/httpd/conf/httpd.confListen 80Listen 8080 <VirtualHost *:80> ServerName www.1.com DocumentRoot /vhosts/1.com/htdocs/</VirtualHost><VirtualHost *:8080> ServerName www.2.com DocumentRoot /vhosts/2.com/htdocs/</VirtualHost> [root@192 html]# mkdir -p /vhosts/{1.com,2.com}/htdocs[root@192 html]# echo www.1.com > /vhosts/1.com/htdocs/index.html[root@192 html]# echo www.2.com > /vhosts/2.com/htdocs/index.html[root@192 html]# echo 192.168.233.138 www.2.com > /etc/hosts[root@192 html]# echo 192.168.233.138 www.1.com >> /etc/hosts[root@192 html]# curl www.1.comwww.1.com[root@192 html]# curl www.2.com:8080www.2.com[root@192 html]# 如果你要在浏览器中显示,可能需要修改host文件windows文件路径:C:\Windows\System32\drivers\etc 第二种:基于IP的虚拟主机注意:基于IP则需IP[root@192 html]# ifconfig eth1:0 192.168.233.139/24 up[root@192 html]# vim /etc/httpd/conf/httpd.conf#Listen 8080 注释掉,因为使用基于IP的<VirtualHost 192.168.233.138:80> ServerName www.1.com DocumentRoot /vhosts/1.com/htdocs/</VirtualHost><VirtualHost 192.168.233.139:80> ServerName www.2.com DocumentRoot /vhosts/2.com/htdocs/</VirtualHost> [root@192 html]# service httpd restart 提示:这里也可以开启Listen 8080.<VirtualHost 192.168.233.139:8080>即可,可复用,如下:[root@192 html]# vim /etc/httpd/conf/httpd.confListen 80Listen 8080<VirtualHost 192.168.233.138:8080> ServerName www.3.com DocumentRoot /vhosts/3.com/htdocs/</VirtualHost> [root@192 html]# mkdir /vhosts/3.com/htdocs -p[root@192 html]# echo www.3.com > /vhosts/3.com/htdocs/index.html[root@192 html]# service httpd restart现在便可以访问三个站点 第三种:基于FQDN[root@192 html]# vim /etc/httpd/conf/httpd.confNameVirtualHost 192.168.233.138:80 #这项需要开启,指定这些主机是通过那台机器进行访问,2.4则不需要<VirtualHost 192.168.233.138:80> ServerName www.1.com DocumentRoot /vhosts/1.com/htdocs/</VirtualHost><VirtualHost 192.168.233.138:80> ServerName www.2.com DocumentRoot /vhosts/2.com/htdocs/</VirtualHost><VirtualHost 192.168.233.138:8080> ServerName www.3.com DocumentRoot /vhosts/3.com/htdocs/</VirtualHost> 注意,这里测试时,如果是windows需要改host文件[root@192 html]# httpd -tSyntax OK[root@192 html]# service httpd restartStopping httpd: [ OK ]Starting httpd: [ OK ][root@192 html]# 注意:额外经常用于每个虚拟主机的配置有以下:ErrorLog,CustomLog,<Directory>,<Location>,ServerAlias 7,内置的status页面<Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from 192.168.233.0/24改成IP地址段或域名即可</Location> 这个页面显示的运行时间,可可用进程(。。。。)模型不同,显示各不相同 ——:空闲进程S:正在启动R:正在读取请求W:发送响应报文K:持久链接读D:DNS查询C:正在关闭链接L:正在记录日志g:正在关闭i:空间的清理工作进程- ExtendedStatus On可显示更详细信息,但是这个可能会消耗系统资源!
2015年11月01日
3,526 阅读
0 评论
0 点赞
2015-10-30
httpd2.2配置文件详解(一)
apache一,apache MPM简介MPM:prefork:多进程模型,每个进程响应一个请求worker:多线程模型,每个线程响应一个请求event:事件驱动模型,一个线程响应多个请求并发服务器响应请求1,单进程I/O模型2,多进程I/O模型3,复用的I/O模型 多线程模型 事件驱动复用的多进程I/O模型httpd基本配置和应用httpd的官网是http.apache.org,目前早已超过系统安装树的版本,为2.2和2.4二,httpd包介绍[root@localhost ~]# yum list all httpdLoaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile base: ftp.sjtu.edu.cn extras: ftp.sjtu.edu.cn updates: ftp.sjtu.edu.cnbase | 3.7 kB 00:00 extras | 3.4 kB 00:00 mariadb | 2.9 kB 00:00 mariadb/primary_db | 22 kB 00:01 updates | 3.4 kB 00:00 Installed Packageshttpd.x86_64 #依赖包 httpd-tools.x86_64 #依赖包 Available Packageshttpd-devel.i686 httpd-devel.x86_64 #以上三个和开发相关 httpd-manual.noarch #在线手册页, [root@localhost ~]# httpd-tools, 压力测试等 [root@localhost ~]# rpm -ql httpd-tools/usr/bin/ab /usr/bin/htdbm/usr/bin/htdigest/usr/bin/htpasswd/usr/bin/logresolve/usr/share/doc/httpd-tools-2.2.15/usr/share/doc/httpd-tools-2.2.15/LICENSE/usr/share/man/man1/ab.1.gz/usr/share/man/man1/htdbm.1.gz/usr/share/man/man1/htdigest.1.gz/usr/share/man/man1/htpasswd.1.gz/usr/share/man/man1/logresolve.1.gz[root@localhost ~]# 三,程序环境:rpm安装的httpd,大多数情况下http自己ID运行时,他的工作路径是/etc/httpd/配置文件:主配置文件:/etc/httpd/conf/httpd.conf分段配置文件:/etc/httpd/conf.d/*.conf服务脚本:/etc/rc.d/init.d/httpd脚本的配置文件:/etc/sysconfig/httpd,#定义httpd进程如何工作模块链接文件:/etc/httpd/modules #映射文件。真正的路径是/usr/lib64/httpd/modules主程序文件:/usr/sbin/httpd #这里提供的是prefork文件 /usr/sbin/httpd.worker #worker /usr/sbin/httpd.event #event这里要说明的是,httpd在2.2,mpm时是不是支持dso,需要切换不同的文件来进行切换模块,而在2.4,则使用dso动态加载即可。日志文件目录:/var/log/httpd access_log:访问日志文件 error_log: 错误日志站点文档目录:/var/www/html如果已经安装好,则可以使用:server httpd start 启动在查看下httpd 80端口,使用:ss -tnl 查看如下所示:[root@localhost ~]# service httpd startStarting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName [ OK ][root@localhost ~]# 当我们第一次启动时候,会报出一个警告,这是因为DNS会反解本机IP对应的主机名是否解析,如果反解除的结果和我们的主机名不一致,但是我们没有DNS,所以他无法确定,使用当前的主机名!这个信息可以安全忽略/var/log/httpd/error_log中的日志,不一定全是错误信息,有安装信息等,关闭启动信息等等我们可以在浏览器输入ip地址讲会看到欢迎页面,这个页面是rpm安装的自带的。而这个欢迎页面在/etc/httpd/conf.d/welcome.conf当成功访问,日志里面将会有记录[root@localhost html]# tail /var/log/httpd/access_log 192.168.233.1 - - [30/Oct/2015:06:00:56 -0700] "GET / HTTP/1.1" 403 4961 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36"192.168.233.1 - - [30/Oct/2015:06:00:56 -0700] "GET /icons/apache_pb.gif HTTP/1.1" 200 2326 "https://192.168.233.138/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36"192.168.233.1 - - [30/Oct/2015:06:00:56 -0700] "GET /icons/poweredby.png HTTP/1.1" 200 3956 "https://192.168.233.138/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36"192.168.233.1 - - [30/Oct/2015:06:00:56 -0700] "GET /favicon.ico HTTP/1.1" 404 290 "https://192.168.233.138/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36"[root@localhost html]# 四,配置文件:Directive #指令 Value #值整个配置文件分成三个段[root@localhost html]# grep "Section" /etc/httpd/conf/httpd.conf### Section 1: Global Environment #全局环境配置,对所有内容生效,虚拟主机 ### Section 2: 'Main' server configuration #主服务器配置,核心配置 ### Section 3: Virtual Hosts #虚拟主机配置[root@localhost html]# Main和Virtual是不能同时启用的,要使用Main则需要忽视Virtual,使用Virtual则需要注释Main,也就是说主配置和虚拟主机是不能同时启用在编辑配置文件之前备份[root@localhost conf]# cp httpd.conf{,.bak}1,指定监听端口Listen 80 ,一般情况下当我们输入IP地址是监听所有可用IP地址的,使用IP:prot(1),Listen指令可出现多次,用于指明多个不同的套接字,如下所示Listen 127.0.0.1:80Listen 127.0.0.1:8080如果你修改了端口,则需要进行重启操作,service httpd restart,重启后使用IP:8080进行访问2,持久链接相关当我们打开一个也没可能会应用数十个甚至上百个其他资源,每一个资源获取,如下:当我们打开页面是,输入域名1,DNS解析2,和IP建立tcp三次握手链接3,传输资源4,拆除链接如下所示:非持久链接:每个资源都是单独通过专用的链接进行获取持久链接:链接建立后,每个资源获取结束不会断开链接,而持续等待其他资源请求并完成传输我们将上图第四段去掉,处于持久链接状态,当有别的请求在进来时,仍然处于等待状态,当时我们需要考虑一个问题,如何断开?何时断开?1,数量限制:如100,超过则断开2,时间限制:如60秒,超过则断开劣势:对并发访问量较大的服务器,开启持久链接会对有些请求得不到服务改进:减短持久链接时间:httpd-2.4支持毫秒级别非持久链接对非常繁忙的场景中,他可以对每个排队的请求都能得到请求,尽管他可能浪费了大量带宽开启持久链接:KeeAlive Off|On开启断开的限制如下:最大保活请求资源数:MaxKeepAliveRequests 100 如果没有达到100个则这条生效:KeepAliveTimeout 15以上两条那个先到达,则断开3,MPM多路处理模块:并发请求响应的不同实现prefork ,worker,eventhttpd-2.2不支持同时编译多个不同的MPM,rpm安装的httpd-2.2提供了三个不同的那如何确定用的是哪个模块呢(1),查看httpd[root@localhost ~]# vim /etc/sysconfig/httpd下面这项:这项没有启用#HTTPD=/usr/sbin/httpd.worker默认为:/usr/sbin/httpd.其为prefork(2),ps aux |grep httpd(3),查看最主要的模块[root@localhost ~]# httpd -lCompiled in modules: core.c prefork.c http_core.c mod_so.c[root@localhost ~]# httpd -l查看静态编译模块httpd -M可以查看所有模块,包括静态和DSO模块httpd.worker -l,还有event -l[root@localhost ~]# httpd.worker -lCompiled in modules: core.c worker.c http_core.c mod_so.c[root@localhost ~]# 五,更换支持不同的MPM的主程序1,编辑/etc/sysconfig/httpd[root@localhost ~]# vim /etc/sysconfig/httpdHTTPD=/usr/sbin/httpd.worker注意,这里可以修改成httpd.worker或者httpd.event,修改后需要重启生效2,重启service httpd restart3.在查看[root@localhost ~]# ps aux |grep httpdroot 3809 0.0 0.4 184532 4072 ? Ss 07:20 0:00 /usr/sbin/httpd.workerapache 3812 0.0 0.5 528792 5392 ? Sl 07:20 0:00 /usr/sbin/httpd.workerapache 3813 0.0 0.5 594328 5412 ? Sl 07:20 0:00 /usr/sbin/httpd.workerapache 3814 0.0 0.5 594328 5396 ? Sl 07:20 0:00 /usr/sbin/httpd.workerroot 3925 0.0 0.0 103252 836 pts/0 S+ 07:20 0:00 grep httpd[root@localhost ~]# 当你更换不同的模块时,调用的配置各不相同配置文件在:/etc/httpd/conf/httpd.conf注意:在httpd2.2中event是测试专用的,所以,配置文件重只有prefork和worker两个容器<IfModule prefork.c>StartServers 8 #默认服务启动会启动8个空闲进程 MinSpareServers 5 #最少5个空闲进程 MaxSpareServers 20 #最大空闲进程数ServerLimit 256 #最多仅允许多少个进程来响应请求MaxClients 256 #最大客户端并发请求连接数MaxRequestsPerChild 4000 #每个子进程最多响应多少个请求</IfModule><IfModule worker.c>StartServers 4 #默认启动多少个空闲进程MaxClients 300 #最大并发连接数MinSpareThreads 25 #最少空闲线程数MaxSpareThreads 75 #最大空闲线程数ThreadsPerChild 25 #每个子进程可生产多少个线程MaxRequestsPerChild 0 #每个进程响应的链接无限制</IfModule>当我们第一次启动是会杀掉一个进程六,DSO机制httpd是高速模块化的,配置指令模块加载如下:在/etc/httpd/conf/httpd.conf中有很多LoadModuls,这些模块是存放在/etc/httpd/modules中,而/etc/httpd/modules是链接至/usr/lib64/httpd/modules/下,这些模块如果不想用只需要注释,添加模块只需要添加进去即可,可以使用httpd -M查看添加或者注释是否生效,如果进程生效,则需要reload,这里的模块可使用相对路径,相对于serverRoot指令指向的位置即可注意:建议使用service httpd reload重新装载配置文件5,指定主服务器的文档映射路径 "Main server"DocumentRoot指令这里的修改只需要修改DocumentRoot路径即可DocumentRoot "/var/www/html" #就是这项,改到页面位置即可,这个位置必须存在文档路径映射:DocumentRoot指向的路径为URL起始的位置/var/www/html/images/1.jpghttps://server/images/1.jpg6,站点路径访问控制站点访问控制机制:(1),基于来源地址(2), 基于账号定义的方式有两种:(1),文件系统路径文件系统路径通常使用 <Directory "/PAHT/TO/SOMEDIR">...</Directory>2,URL路径<Location "/URL"> ... </Location>七,Directory中定义访问控制 (1)OptionsIndexes:当访问的路径下无默认主页面文件存在,且没有指定具体要访问的资源时,会将此路径下的所以资源以列表呈现给用户;非常危险,不建议使用;FollowSymLinks:如果其页面文件是为指向DocumentRoot之外路径上的其他文件时,将直接显示目标文件的内容 None:什么特性都不启用 All:所以的都启用 (2)AllowOverride 这项一般不启用,启用可能占用相当多的服务器性能 (3)基于来源地址的访问控制 Order:检查次序 Order Allow Deny:只有明确Allow的来源地址,才允许访问,其他的均为Deny Order Deny Allow:只有明确Deny Allow from:允许访问的来源地址 Deny from:拒绝访问的来源地址 如: Order Allow Deny Deny from 10.0.0.2/16 Allow from 10.0.0.1/16 允许10.0.0.1来访问,拒绝10.0.0.2,明确Deny为Deny,明确Allow为Allow 这里的from支持网络格式,如: 10.0 10.0.0.0 10.0.0.0/16 都是一个意思
2015年10月30日
3,812 阅读
0 评论
0 点赞
2015-05-18
apachectl2.4编译安装及虚拟目录的实现
前提: 安装开发环境 yum groupinstall "Deveopment Tools" "Server Platform Developent" httpd依赖于:apr, apr-util, apr-icon 其他依赖包:pcre-devel zlib-devel 在安装前请确保以上基础的依赖包已经安装! 开始安装: 源码包安装顺序为:arp,apr-util,httpd 环境: os:cetos6.6 httpd-2.4.10.tar.bz2 apr-1.5.0.tar.bz2 apr-iconv-1.2.1.tar.bz2 apr-util-1.5.3.tar.bz2 (1)apr [root@localhost yum.repos.d]# tar xf apr-1.5.0.tar.bz2 [root@localhost yum.repos.d]# cd apr-1.5.0 [root@localhost apr-1.5.0]# ./configure --prefix=/usr/local/apr [root@localhost apr-1.5.0]# make && make install (2)apr-util [root@localhost apr-1.5.0]# cd .. [root@localhost yum.repos.d]# tar xf apr-util-1.5.3.tar.bz2 [root@localhost yum.repos.d]# cd apr-util-1.5.3 [root@localhost apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/apr [root@localhost apr-1.5.0]# make && make install (3)创建系统用户 [root@localhost apr-util-1.5.3]# groupadd -r apache [root@localhost apr-util-1.5.3]# useradd -r -g apache apache (4)httpd [root@localhost apr-1.5.0]# cd .. [root@localhost yum.repos.d]# tar xf httpd-2.4.10.tar.bz2 [root@localhost yum.repos.d]# cd httpd-2.4.10 [root@localhost httpd-2.4.10]# ./configure --prefix=/usr/local/apache -- sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite -- with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr- util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork [root@localhost httpd-2.4.10]# # make && make install (5)启动脚本的创建 1,编辑脚本文件 [root@localhost httpd-2.4.10]# vim /etc/profile.d/httpd.sh export PATH=/usr/local/apache/bin:$PATH [root@localhost httpd-2.4.10]# cd /etc/profile.d/ 2,执行脚本程序 [root@localhost profile.d]# . /httpd.sh 3,查看是否已经加载 [root@localhost profile.d]# which apachectl /usr/local/apache/bin/apachectl 4,清楚hash [root@localhost httpd-2.4.10]hash -r 5,启动apachectl [root@localhost httpd-2.4.10]# apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message 6,查看80端口是否监听 [root@localhost httpd-2.4.10]# ss -untl | grep :80 7,浏览器测试是否出现It works! 其他: 查看编辑安装的命令:其中包括安装路径,配置文件,安装的模块 [root@localhost httpd-2.4.10]# cd /usr/local/apache/ [root@localhost apache]# less build/config.nice 网页图标:icons/ 头文件:include/ 头文件如果要被系统调用的话,需要连接至/usr/include/ [root@localhost apache]# ln -sv /usr/local/apache/include/ /usr/include/httpd/ (6)日志和man手册 [root@localhost apache]# ls logs/ access_log error_log httpd.pid man手册的创建,当你编译完成后,是由单独的httpd man配置文件,添加至系统man配置中 [root@localhost apache]# ls man man1 man8 1,/etc/man.config 44行作业添加 [root@localhost apache]# vim /etc/man.config MANPATH /usr/local/apache/man 2,/etc/httpd24/httpd.conf 搜索/manual打开这行功能(我打开后服务起不来了,后续再 来研究) [root@localhost apache]# vim /etc/httpd24/httpd.conf Include /etc/httpd24/extra/httpd-manual.conf 到此,apache已经编译安装完成。 一:接下来修改模块!(可选) 1,使用httpd -M可以查看目前使用的是什么模块! 这个版本编译后默认是mpm_prefork_module (shared) 2,我们尝试着将prefork修改为event 1-35行 [root@localhost apache]# vim /etc/httpd24/httpd.conf 、 修改前复制一个并且注释 #LoadModule mpm_prefork_module modules/mod_mpm_prefork.so prefork修改为event LoadModule unixd_module modules/mod_unixd.so LoadModule mpm_event_module modules/mod_mpm_event.so 3,而后,在使用httpd -M查看是否已经修改! 二:修改Main server的DocumentRoot 1,创建一个目录 [root@localhost htdocs]# mkdir /data/web/htdocs -pv mkdir: created directory `/data' mkdir: created directory `/data/web' mkdir: created directory `/data/web/htdocs' 2,编辑一个测试页 [root@localhost htdocs]# vim /data/web/htdocs/index.html <h1>hello apache!<h1> 3,修改配置文件/etc/httpd24/httpd.conf DocumentRoot Directory 218行 4,重启apachectl,打开浏览器测试网站根目录是否已经跳转! 三,基于IP地址的访问控制 Require all granted是:允许所有主机访问 [root@localhost htdocs]# vim /etc/httpd24/httpd.conf Require all granted 245行 拒绝所有主机访问:Require all deny控制特定IP访问: Require ip IPADDR:授权指定来源地址的主机访问 Require not ip IPADDR:拒绝指定来源地址的主机访问 IPADDR可以是以下类型: IP: 172.16.100.2 Network/mask: 172.16.0.0/255.255.0.0 Network/Length: 172.16.0.0/16 Net: 172.16 控制特定主机(HOSTNAME)访问 Require host HOSTNAME Require not host HOSTNAME HOSTNAME: FQDN: 特定主机 DOMAIN:指定域内的所有主机 四,虚拟主机 使用虚拟主机需要把DocumentRoot关掉才能使用 另外,虚拟主机定义在一个配置文件:/etc/httpd24/extra/httpd-vhosts.conf 1,打开/etc/httpd24/httpd.conf,删除注释,开启虚拟主机 [root@localhost htdocs]#vim /etc/httpd24/httpd.conf Include /etc/httpd24/extra/httpd-vhosts.conf 查看LogFormat是否开启 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common 基于IP、Port和FQDN都支持; 基于FQDN的不再需要NameVirtualHost指令 2,创建/vhost/a.com和b.com [root@localhost ~]# mkdir /vhost/a.com/ -p [root@localhost ~]# mkdir /vhost/b.com/ -p [root@localhost ~]# tree /vhost/ /vhost/ ├── a.com └── b.com 2 directories, 0 files [root@localhost ~]# vim /vhost/a.com/index.html <h1>www.a.com<h1> [root@localhost ~]# vim /vhost/b.com/index.html <h1>www.b.com<h1> [root@localhost ~]# vim /vhost/b.com/index.html <h1>www.b.com<h1> ~ 2,编辑vhosts.conf文件 vim /etc/httpd24/extra/httpd-vhsots.conf <VirtualHost *:80> ServerAdmin webmaster@a.com DocumentRoot "/vhost/a.com" ServerName www.a.com ErrorLog "logs/www.a.com-error_log" CustomLog "logs/www.a.com-access_log" combined <Directory "/vhost/a.com"> Options none AllowOverride none Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@b.com DocumentRoot "/vhost/b.com" ServerName www.b.com ErrorLog "logs/www.b.com-error_log" CustomLog "logs/www.b.com-access_log" combined <Directory "/vhost/b.com"> Options none AllowOverride none Require all granted </Directory> </VirtualHost> 3,检查配置文件 [root@localhost ~]# httpd -t AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message Syntax OK 4,查看区域设置 [root@localhost ~]# httpd -S AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message VirtualHost configuration: *:80 is a NameVirtualHost default server www.a.com (/etc/httpd24/extra/httpd-vhosts.conf:23) port 80 namevhost www.a.com (/etc/httpd24/extra/httpd-vhosts.conf:23) port 80 namevhost www.b.com (/etc/httpd24/extra/httpd-vhosts.conf:31) ServerRoot: "/usr/local/apache" Main DocumentRoot: "/usr/local/apache/htdocs" Main ErrorLog: "/usr/local/apache/logs/error_log" Mutex default: dir="/usr/local/apache/logs/" mechanism=default PidFile: "/usr/local/apache/logs/httpd.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="daemon" id=2 Group: name="daemon" id=2 [root@localhost ~]# 5,测试 [root@www httpd-2.4.10]# curl www.a.com <h1>www.a.com<h1> [root@www httpd-2.4.10]# curl www.b.com <h1>www.b.com<h1> AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message的解决方法就是打开httpd.conf中ServerName就可以 https可以参考openssl应用简述PDF
2015年05月18日
2,577 阅读
0 评论
0 点赞
2015-04-20
简介源代码安装nginx/apache
在编译安装时请注意需求!必要时查看官方文档! [root@centos3 ~]# rpm -qi glibc Name : glibc Relocations: (not relocatable) Version : 2.12 Vendor: CentOS Release : 1.149.el6 Build Date: Wed 15 Oct 2014 10:00:58 AM CST Install Date: Mon 13 Apr 2015 02:22:42 PM CST Build Host: c6b9.bsys.dev.centos.org Group : System Environment/Libraries Source RPM: glibc-2.12-1.149.el6.src.rpm Size : 12959134 License: LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ Signature : RSA/SHA1, Sat 18 Oct 2014 04:00:42 AM CST, Key ID 0946fca2c105b9de Packager : CentOS BuildSystem <https://bugs.centos.org> URL : https://sources.redhat.com/glibc/ Summary : The GNU libc libraries Description : The glibc package contains standard libraries which are used by multiple programs on the system. In order to save disk space and memory, as well as to make upgrading easier, common system code is kept in one place and shared between programs. This particular package contains the most important sets of shared libraries: the standard C library and the standard math library. Without these two libraries, a Linux system will not function. [root@centos3 ~]# 手动编译源代码文件: 依赖环境:编译开发工具、以及各个被依赖到的程序包的开发组件 包组: Development tools server platform development desktop platform development [root@centos3 /]# yum -y groupinstall "Development tools" "server platform development" 这里省略一千字! Installed: autoconf.noarch 0:2.63-5.1.el6 automake.noarch 0:1.11.1-4.el6 bison.x86_64 0:2.4.1-5.el6 byacc.x86_64 0:1.9.20070509-7.el6 cscope.x86_64 0:15.6-6.el6 ctags.x86_64 0:5.8-2.el6 dbus-devel.x86_64 1:1.2.24-7.el6_3 diffstat.x86_64 0:1.51-2.el6 doxygen.x86_64 1:1.6.1-6.el6 flex.x86_64 0:2.5.35-9.el6 gcc.x86_64 0:4.4.7-11.el6 gcc-c++.x86_64 0:4.4.7-11.el6 gcc-gfortran.x86_64 0:4.4.7-11.el6 git.x86_64 0:1.7.1-3.el6_4.1 indent.x86_64 0:2.2.10-7.el6 intltool.noarch 0:0.41.0-1.1.el6 krb5-devel.x86_64 0:1.10.3-33.el6 libstdc++-devel.x86_64 0:4.4.7-11.el6 libtool.x86_64 0:2.2.6-15.5.el6 libvirt-devel.x86_64 0:0.10.2-46.el6 libvirt-java-devel.noarch 0:0.4.9-1.el6 ncurses-devel.x86_64 0:5.7-3.20090208.el6 nss-devel.x86_64 0:3.16.1-14.el6 openldap-devel.x86_64 0:2.4.39-8.el6 openssl-devel.x86_64 0:1.0.1e-30.el6 pam-devel.x86_64 0:1.1.1-20.el6 patchutils.x86_64 0:0.3.1-3.1.el6 rcs.x86_64 0:5.7-37.el6 redhat-rpm-config.noarch 0:9.0.3-42.el6.centos rpm-build.x86_64 0:4.8.0-37.el6 subversion.x86_64 0:1.6.11-10.el6_5 swig.x86_64 0:1.3.40-6.el6 systemtap.x86_64 0:2.5-5.el6 zlib-devel.x86_64 0:1.2.3-29.el6 Dependency Installed: cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-11.el6 cyrus-sasl-devel.x86_64 0:2.1.23-15.el6 cyrus-sasl-md5.x86_64 0:2.1.23-15.el6 gdb.x86_64 0:7.2-75.el6 gettext-devel.x86_64 0:0.17-18.el6 gettext-libs.x86_64 0:0.17-18.el6 giflib.x86_64 0:4.1.6-3.1.el6 gnutls-utils.x86_64 0:2.8.5-14.el6_5 java-1.7.0-openjdk.x86_64 1:1.7.0.65-2.5.1.2.el6_5 jna.x86_64 0:3.2.4-2.el6 jpackage-utils.noarch 0:1.7.5-3.12.el6 kernel-devel.x86_64 0:2.6.32-504.el6 keyutils-libs-devel.x86_64 0:1.4-5.el6 libcom_err-devel.x86_64 0:1.41.12-21.el6 libgcj.x86_64 0:4.4.7-11.el6 libgfortran.x86_64 0:4.4.7-11.el6 libselinux-devel.x86_64 0:2.0.94-5.8.el6 libsepol-devel.x86_64 0:2.0.41-4.el6 libvirt-client.x86_64 0:0.10.2-46.el6 libvirt-java.noarch 0:0.4.9-1.el6 mpfr.x86_64 0:2.4.1-6.el6 nc.x86_64 0:1.84-22.el6 nspr-devel.x86_64 0:4.10.6-1.el6_5 nss-softokn-devel.x86_64 0:3.14.3-17.el6 nss-softokn-freebl-devel.x86_64 0:3.14.3-17.el6 nss-util-devel.x86_64 0:3.16.1-3.el6 perl-Error.noarch 1:0.17015-4.el6 perl-Git.noarch 0:1.7.1-3.el6_4.1 ppl.x86_64 0:0.10.2-11.el6 systemtap-client.x86_64 0:2.5-5.el6 systemtap-devel.x86_64 0:2.5-5.el6 tzdata-java.noarch 0:2014g-1.el6 yajl.x86_64 0:1.0.7-3.el6 Complete! [root@centos3 /]# [root@centos3 ~]# lftp 172.16.0.1 lftp 172.16.0.1:~> mget /pub/Sources/sources/nginx/nginx-1.6.2.tar.gz 804164 bytes transferred lftp 172.16.0.1:/> bye [root@centos3 ~]# ls anaconda-ks.cfg install.log install.log.syslog nginx-1.6.2.tar.gz [root@centos3 ~]# useradd -r nginx [root@centos3 ~]# tar xf nginx-1.6.2.tar.gz [root@centos3 ~]# cd nginx-1.6.2 [root@centos3 nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx.conf --user=nginx --group=nginx 这里省略一千字 checking for PCRE library in /usr/include/pcre/ ... not found checking for PCRE library in /usr/pkg/ ... not found checking for PCRE library in /opt/local/ ... not found 已经报错 ./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option. [root@centos3 nginx-1.6.2]# yum install pcre-devel -y 这里省略一千字 Install 1 Package(s) Total download size: 318 k Installed size: 954 k Downloading Packages: pcre-devel-7.8-6.el6.x86_64.rpm | 318 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : pcre-devel-7.8-6.el6.x86_64 1/1 Verifying : pcre-devel-7.8-6.el6.x86_64 1/1 Installed: pcre-devel.x86_64 0:7.8-6.el6 Complete! [root@centos3 nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx.conf --user=nginx --group=nginx creating objs/Makefile Configuration summary + using system PCRE library + OpenSSL library is not used + md5: using system crypto library + sha1: using system crypto library + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx configuration prefix: "/etc" nginx configuration file: "/etc/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp" [root@centos3 nginx-1.6.2]# make [root@centos3 nginx-1.6.2]# make install 安装完成! 安装的路径和配置文件 [root@centos3 nginx-1.6.2]# cd /usr/local/nginx/ [root@centos3 nginx]# ls html logs sbin [root@centos3 nginx]# ls /usr/local/nginx/sbin/ nginx [root@centos3 nginx]# 再来! lftp 172.16.0.1:/pub/Sources/sources/httpd> mget httpd-2.2.29.tar.bz2 5625498 bytes transferred lftp 172.16.0.1:/pub/Sources/sources/httpd> bye [root@centos3 ~]# rpm -q httpd httpd-2.2.15-39.el6.centos.x86_64 [root@centos3 ~]# rpm -e httpd error: Failed dependencies: httpd >= 2.2.0 is needed by (installed) gnome-user-share-2.28.2-3.el6.x86_64 [root@centos3 ~]# yum remove httpd Running Transaction Erasing : gnome-user-share-2.28.2-3.el6.x86_64 1/2 Erasing : httpd-2.2.15-39.el6.centos.x86_64 2/2 Verifying : httpd-2.2.15-39.el6.centos.x86_64 1/2 Verifying : gnome-user-share-2.28.2-3.el6.x86_64 2/2 Removed: httpd.x86_64 0:2.2.15-39.el6.centos Dependency Removed: gnome-user-share.x86_64 0:2.28.2-3.el6 Complete! [root@centos3 ~]# [root@centos3 ~]# tar xf httpd-2.2.29.tar.bz2 [root@centos3 ~]# ls anaconda-ks.cfg httpd-2.2.29.tar.bz2 install.log.syslog nginx-1.6.2.tar.gz httpd-2.2.29 install.log nginx-1.6.2 [root@centos3 ~]# cd httpd-2.2.29 [root@centos3 httpd-2.2.29]# ls ABOUT_APACHE CHANGES httpd.dsp libhttpd.dep NOTICE server acinclude.m4 config.layout httpd.mak libhttpd.dsp NWGNUmakefile srclib Apache.dsw configure httpd.spec libhttpd.mak os support build configure.in include LICENSE README test BuildAll.dsp docs INSTALL Makefile.in README.platforms VERSIONING BuildBin.dsp emacs-style InstallBin.dsp Makefile.win README-win32.txt buildconf httpd.dep LAYOUT modules ROADMAP [root@centos3 httpd-2.2.29]# 在安装之前可以读读install文件 [root@centos3 httpd-2.2.29]# less INSTALL --help查看选项 [root@centos3 httpd-2.2.29]# ./configure --help [root@centos3 httpd-2.2.29]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd/ --enable-so 这里省略很多内容。 config.status: executing default commands [root@centos3 httpd-2.2.29]# make [root@centos3 httpd-2.2.29]# make install Installing header files Installing build system files Installing man pages and online manual mkdir /usr/local/apache/man mkdir /usr/local/apache/man/man1 mkdir /usr/local/apache/man/man8 mkdir /usr/local/apache/manual make[1]: Leaving directory `/root/httpd-2.2.29' [root@centos3 httpd-2.2.29]# cd /usr/local/apache/ [root@centos3 apache]# ls bin build cgi-bin error htdocs icons include lib logs man manual modules [root@centos3 apache]# [root@centos3 apache]# ls /usr/local/apache/bin/ ab apu-1-config dbmmanage htcacheclean htpasswd logresolve apachectl apxs envvars htdbm httpd rotatelogs apr-1-config checkgid envvars-std htdigest httxt2dbm [root@centos3 apache]# 添加环境变量搜索路径 [root@centos3 apache]# echo $PATH /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin [root@centos3 apache]# 加入坏境变量 [root@centos3 apache]# vim /etc/profile.d/httpd.sh export PATH=/usr/local/apache/bin:$PATH [root@centos3 apache]# . /etc/profile.d/httpd.sh [root@centos3 apache]# echo $PATH /usr/local/apache/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin [root@centos3 apache]# apachectl Usage: /usr/local/apache/bin/httpd [-D name] [-d directory] [-f file] [-C "directive"] [-c "directive"] [-k start|restart|graceful|graceful-stop|stop] [-v] [-V] [-h] [-l] [-L] [-t] [-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 -T : start without DocumentRoot(s) check [root@centos3 apache]# 库文件: Last login: Mon Apr 13 21:54:06 2015 from 172.16.250.167 [root@centos3 ~]# man httpd No manual entry for httpd [root@centos3 ~]# 下面的库文件没有被系统找到 [root@centos3 apache]# ls /usr/local/apache/lib/ apr.exp libapr-1.so.0 libaprutil-1.so.0 libexpat.so.0 aprutil.exp libapr-1.so.0.5.1 libaprutil-1.so.0.5.3 libexpat.so.0.5.0 libapr-1.a libaprutil-1.a libexpat.a pkgconfig libapr-1.la libaprutil-1.la libexpat.la libapr-1.so libaprutil-1.so libexpat.so [root@centos3 apache]# [root@centos3 apache]# cat /etc/ld.so.conf include ld.so.conf.d/*.conf [root@centos3 apache]# ldconfig -p | grep /usr/local/apache/lib/ [root@centos3 apache]# vim /etc/ld.so.conf.d/httpd.conf /usr/local/apapche/lib [root@centos3 apache]# ldconfig [root@centos3 apache]# ldconfig -p | grep /usr/local/apache/lib/ libexpat.so.0 (libc6,x86-64) => /usr/local/apache/lib/libexpat.so.0 libexpat.so (libc6,x86-64) => /usr/local/apache/lib/libexpat.so libaprutil-1.so.0 (libc6,x86-64) => /usr/local/apache/lib/libaprutil-1.so.0 libaprutil-1.so (libc6,x86-64) => /usr/local/apache/lib/libaprutil-1.so libapr-1.so.0 (libc6,x86-64) => /usr/local/apache/lib/libapr-1.so.0 libapr-1.so (libc6,x86-64) => /usr/local/apache/lib/libapr-1.so [root@centos3 apache]# 头文件导出方案: 头文件存放路径/usr/include/,输出httpd给系统头文件 [root@centos3 apache]# ln -sv /usr/local/apache/include /usr/include/httpd `/usr/include/httpd' -> `/usr/local/apache/include' [root@centos3 apache]# ls -l /usr/include/httpd lrwxrwxrwx 1 root root 25 Apr 13 22:54 /usr/include/httpd -> /usr/local/apache/include [root@centos3 apache]# ls /usr/include/httpd/ ap_compat.h apr_file_info.h apr_pools.h apr_user.h mod_dbd.h ap_config_auto.h apr_file_io.h apr_portable.h apr_uuid.h mod_include.h ap_config.h apr_fnmatch.h apr_proc_mutex.h apr_version.h mod_log_config.h ap_config_layout.h apr_general.h apr_queue.h apr_want.h mod_proxy.h ap_listen.h apr_getopt.h apr_random.h apr_xlate.h mod_rewrite.h ap_mmn.h apr_global_mutex.h apr_reslist.h apr_xml.h mod_ssl.h ap_mpm.h apr.h apr_ring.h apu_errno.h mod_status.h ap_provider.h apr_hash.h apr_rmm.h apu.h mpm_common.h apr_allocator.h apr_hooks.h apr_sdbm.h apu_version.h mpm_default.h apr_anylock.h apr_inherit.h apr_sha1.h apu_want.h mpm.h apr_atomic.h apr_ldap.h apr_shm.h expat.h os.h apr_base64.h apr_ldap_init.h apr_signal.h http_config.h scoreboard.h apr_buckets.h apr_ldap_option.h apr_skiplist.h http_connection.h unixd.h apr_crypto.h apr_ldap_rebind.h apr_strings.h http_core.h util_cfgtree.h apr_date.h apr_ldap_url.h apr_strmatch.h httpd.h util_charset.h apr_dbd.h apr_lib.h apr_support.h http_log.h util_ebcdic.h apr_dbm.h apr_md4.h apr_tables.h http_main.h util_filter.h apr_dso.h apr_md5.h apr_thread_cond.h http_protocol.h util_ldap.h ap_regex.h apr_memcache.h apr_thread_mutex.h http_request.h util_md5.h ap_regkey.h apr_mmap.h apr_thread_pool.h http_vhost.h util_script.h ap_release.h apr_network_io.h apr_thread_proc.h mod_auth.h util_time.h apr_env.h apr_optional.h apr_thread_rwlock.h mod_cgi.h util_xml.h apr_errno.h apr_optional_hooks.h apr_time.h mod_core.h apr_escape.h apr_poll.h apr_uri.h mod_dav.h [root@centos3 apache]# man手册文件 1,[root@centos3 apache]# vim /etc/man.config MANPATH /usr/local/apache/man ,2,[root@centos3 apache]# man -M /usr/local/apache/man
2015年04月20日
3,874 阅读
0 评论
0 点赞