http服务软件及企业实战
主流web软件
当前互联网主流的wed服务说明
apache
nginx
(nginx.org)
resin
tomcat
php
(http://php.net/downloads.php)
linux系统软件包安装方式
apache介绍
特点及应用场合
apache
安装软件
[[email protected] ~]# rpm -qa httpd =è查看软件
httpd-2.2.15-53.el6.centos.x86_64
[[email protected] ~]# hostname httpd
[[email protected] ~]# logout
[[email protected] ~]#
[[email protected] ~]# rpm -e httpd-2.2.15-53.el6.centos.x86_64 =è卸载软件
warning: /etc/httpd/conf/httpd.conf saved as/etc/httpd/conf/httpd.conf.rpmsave
安装的步骤:
1032 rz –y ====è我是先将安装包下载windows
1033 ll
1034 tar -xf httpd-2.2.27.tar.gz
1035 cd httpd-2.2.27
1036 ls
1037 ./configure =====编译
--prefix=/application/apache2.2.27
--enable-deflate
--enable-expires
--enable-headers
--enable-modules=most
--enable-so
--with-mpm=worker
--enable-rewrite
#################################################################################################################
遇见错误:
checking whether to enable mod_deflate... checking dependencies
checking for zlib location... notfound
checking whether to enable mod_deflate... configure: error: mod_deflate has beenrequested but can not be built due to prerequisite failures
解决
[[email protected] httpd-2.2.27]# yuminstall zlib zlib-devel –y
##############################################################################################################
执行: yum install zlibzlib-devel –y,再进行编译
1041 echo $? ==========检查 0表示成功
1043 make && make install
1045 echo $?
1046 ln -s/application/apache2.2.27/ /application/apache
[[email protected] apache]# /application/apache/bin/apachectl–t =====检查apache服务
httpd: apr_sockaddr_info_get() failed for httpd
httpd: Could not reliably determine the server‘s fully qualified domainname, using 127.0.0.1 for ServerName
Syntax OK ===语法ok
[[email protected] apache]#
[[email protected] apache]# /application/apache/bin/apachectlstart ===========开启apache服务
httpd: apr_sockaddr_info_get() failed for httpd
httpd: Could not reliably determine the server‘s fully qualified domainname, using 127.0.0.1 for ServerName
[[email protected] apache]# lsof-i :80 端口号80 ============检查端口
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODENAME
httpd 6326 root 4u IPv6 64842 0t0 TCP *:http (LISTEN)
httpd 6328 daemon 4u IPv6 64842 0t0 TCP *:http (LISTEN)
httpd 6329 daemon 4u IPv6 64842 0t0 TCP *:http (LISTEN)
httpd 6330 daemon 4u IPv6 64842 0t0 TCP *:http (LISTEN)
[[email protected] apache]# ps-ef|grep httpd =========进程
root 6326 1 001:11 ? 00:00:00/application/apache2.2.27/bin/httpd -k start
daemon 6327 6326 001:11 ? 00:00:00 /application/apache2.2.27/bin/httpd-k start
daemon 6328 6326 001:11 ? 00:00:00/application/apache2.2.27/bin/httpd -k start
daemon 6329 6326 001:11 ? 00:00:00/application/apache2.2.27/bin/httpd -k start
daemon 6330 6326 001:11 ? 00:00:00/application/apache2.2.27/bin/httpd -k start
root 6414 2344 001:11 pts/0 00:00:00 grep --color=autohttpd
[[email protected] apache]#
[[email protected] apache]# /etc/init.d/iptablesstop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[[email protected] apache]# getenforce
Disabled
[[email protected] apache]# ifconfigeth0|grep "inet addr"|awk -F ":" ‘{print $2}‘|awk ‘{print $1}‘
192.168.21.168
检查apache安装成功?
至此软件安装完毕!!!!!
[[email protected] apache]# curl-I 192.168.21.128
HTTP/1.1 200 OK
Date: Wed, 06 Jul 2016 19:24:29 GMT
Server: Apache/2.2.27 (Unix) DAV/2
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "258e3-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Content-Type: text/html
前面编译的:
[[email protected] apache]# /application/apache/bin/apachectl -l|egrep"_so|_rewrite|header|expire|deflate"
mod_deflate.c
mod_expires.c
mod_headers.c
mod_rewrite.c
mod_so.c
[[email protected] apache]# strace/application/apache/bin/apachectl –I ======跟踪进程命令 ()
execve("/application/apache/bin/apachectl",["/application/apache/bin/apachect"..., "-I"], [/* 26 vars*/]) = 0
安装软件出现的问题
1.
解决:将写好的编译放在rules.mk即可。
2.
解决:
apache及目录结构
[[email protected] htdocs]# tree /application/apache
/application/apache
├── bin
│ ├── ab
│ ├── apachectl
│ ├── apr-1-config
│ ├── apu-1-config
│ ├── apxs
│ ├── checkgid
│ ├── dbmmanage
│ ├── envvars
。。。。。。。。
配置文件的目录
默认apache站点目录
服务很关键的步骤:检查语法,平滑重启
主配置文件目录
重要扩张配置文件
[[email protected] extra]# ll
total 56
-rw-r--r-- 1 root root 2859 Jul 7 00:44 httpd-autoindex.conf
-rw-r--r-- 1 root root 1753 Jul 7 00:44 httpd-dav.conf
-rw-r--r-- 1 root root 2344 Jul 7 00:44 httpd-default.conf 了解
-rw-r--r-- 1 root root 1103 Jul 7 00:44 httpd-info.conf
-rw-r--r-- 1 root root 5078 Jul 7 00:44 httpd-languages.conf
-rw-r--r-- 1 root root 949 Jul 7 00:44 httpd-manual.conf
-rw-r--r-- 1 root root 3789 Jul 7 00:44 httpd-mpm.conf 重点
-rw-r--r-- 1 root root 2207 Jul 7 00:44 httpd-multilang-errordoc.conf
-rw-r--r-- 1 root root 11530 Jul 700:44 httpd-ssl.conf
-rw-r--r-- 1 root root 817 Jul 7 00:44 httpd-userdir.conf
-rw-r--r-- 1 root root 1507 Jul 7 00:44 httpd-vhosts.conf重点
[[email protected] extra]#
便于寻找目录
[[email protected] /]# cd /application/apache
[[email protected] apache]# ls
bin cgi-bin error icons lib man modules
build conf htdocs include logs manual
[[email protected] apache]# cd conf/
[[email protected] conf]# cd extra/
[[email protected] extra]#
创建站点
一台主机上有不同的站点
[[email protected] extra]# mkdir/var/html/{www,blog,bbs} -p
[[email protected] extra]# tree /var/html/
/var/html/
├── bbs
├── blog
└── www
3 directories, 0 files
[[email protected] extra]#
[[email protected] extra]# touch/var/html/{www,blog,bbs}/index,html
[[email protected] extra]# tree /var/html/
/var/html/
├── bbs
│ └── index,html
├── blog
│ └── index,html
└── www
└── index,html
3 directories, 3 files
[[email protected] extra]# forname in www blog bbs;do echo "http://$name.etiantian.org">/var/html/$name/index.html;done
[[email protected] extra]# for name in www bolg bbs;do cat/var/html/$nama/index.html;done
http://bbs.etiantian.org
http://bbs.etiantian.org
[[email protected] extra]# vim httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin [email protected] 管理员邮箱
DocumentRoot"/var/html/www" 站点
ServerName www.etiantian.com 域名
ServerAlias www..com 别名
ErrorLog"logs/dummy-host.example.com-error_log" 站点的错误日志
CustomLog"logs/dummy-host.example.com-access_log" common 站点访问日志
注意的问题:
apache
apache日志轮询技术(cronolog【一般企业常用】 and rotatelogs)
[[email protected] tools]# wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
apache的轮巡
(http://oldboy.blog.51cto.com/2561410/584513)老男孩日志轮巡技术