Web简介
什么是Web
WWW:World Wide Web,万维网
英国人TimBerners-Lee在1989年欧洲共同体的一个大型科研机构工作时发明的
Web是一种超文本信息系统,其主要实现方式是超文本连接
Web特点
1、Web页面的图形化和易于链接
2、Web与操作系统、浏览器平台无关
3、分布式
4、动态习惯
5、交互性
Web工作原理
HTTP(Hyper Text Transfer Protocol,超文本传输协议):提供了访问超文本信息的功能,是Web浏览器和Web服务器之间的应用层通信协议
HTTP协议是用于分布式写作超文本信息系统的、通用的、面向对象的协议
Web使用HTTP协议传输各种超文本页面和数据
URL,统一资源标识符:是一个世界通用的负责给万维网上的资源(如网页)定位的系统
静态网站和动态网站的区别
1、静态网站
没有任何程序开发的网站,纯HTML编写;网页文件名是html或htm结尾的
优点:打开速度相对比较快;网站容易被搜索引擎收录;比较安全,重要数据不会丢失
缺点:不能直接对网站内容进行修改,实现不了交互等功能
2、动态网站
通过后台程序,可以方便的对整个网站内容进行修改、删除操作
这些程序都要使用数据库才能完成动态的操作
动态网站的开发语言有:ASP , JSP , PHP , ASP.NET 等
数据库:Access,MySQL,Oracle,SQL Server等
常用组合:
ASP --> Access,MySQL
PHP --> MySQL
JSP --> MySQL,Oracle
优点:维护方便,能实现需要的各种需求;查询信息方便
缺点:要用到数据库,对数据的安全和保密性要求较高;动态网站不利于搜索引擎记录;制作成本较高
Web错误代码
如果出现错误会返回一个表示该请求状态的数字代码,该状态代码记录在Web服务器日志中,同时可以可能在Web浏览器中显示
Web错误代码:
错误代码描述
400错误的请求
401未经授权
403禁止访问:访问被拒绝
404找不到文件或目录
405用户访问该页的HTTP动作未被许可
408请求时间超时
410系统资源已经不存在
411需要内容长度头
412客户端设置的前提条件在Web服务器上评估时失败
413请求实体太大
414请求URL太大
415不支持的媒体类型
500服务器内部错误
501标题值指定的配置没有执行
502Web服务器作为网关或代理服务器时收到无效的响应
503服务不可用
Apache简介
Apache HTTPServer,简称Apache:Apache软件基金会的一个开放源代码的网页服务器
可运行在UNIX、Windows、Linux等系统中
快速、可靠并且可以通过简单的API扩展,将Perl和Python等解释器编译到服务器中
Apache源于NCSA httpd 服务器,经过多次修改发展而成。
特点:简单、速度快、性能稳定、并可以作为代理服务器使用
Apache的特性
支持HTTP/1.1通信协议
拥有简单而强有力的基于文件的配置过程
支持通用网关接口(CGI)
支持基于端口号、IP地址和域名的虚拟主机
支持多种方式的HTTP认证
集成Perl代理模块
支持实时监控服务器状态和定制服务器日志
支持服务器端包含指令(SSI)
支持安全Socket层(SSL)
提供用户会话过程的跟踪
支持FastCGI
通过第三方模块可以支持Java Servlets
Apache服务安装
httpd软件包介绍
httpd-2.2.15-53.el6.centos.x86_64.rpm #Apache服务主程序软件包
httpd-devel-2.2.15-53.el6.centos.x86_64.rpm #Apache库程序
httpd-manual-2.2.15-53.el6.centos.noarch.rpm #Apache服务器手册
httpd-tools-2.2.15-53.el6.centos.x86_64.rpm #Apache服务器使用工具
安装httpd
-> rpm安装
-> yum安装
-> 源码编译安装
rpm安装
CentOS 6.8
1、挂载系统光盘
[root@localhost ~]# ls /mnt/cdrom/CentOS_BuildTag isolinux RPM-GPG-KEY-CentOS-Debug-6EFI Packages RPM-GPG-KEY-CentOS-Security-6EULA RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Testing-6GPL repodata TRANS.TBLp_w_picpaths RPM-GPG-KEY-CentOS-6
2、rpm安装httpd
1)、安装httd主程序包
[root@localhost Packages]# rpm -ivh httpd-2.2.15-53.el6.centos.x86_64.rpm warning: httpd-2.2.15-53.el6.centos.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEYPreparing... ########################################### [100%] 1:httpd ########################################### [100%]
2)、安装帮助手册
[root@localhost Packages]# rpm -ivh httpd-manual-2.2.15-53.el6.centos.noarch.rpm warning: httpd-manual-2.2.15-53.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEYPreparing... ########################################### [100%] 1:httpd-manual ########################################### [100%]
3)、httpd-tools工具
[root@localhost Packages]# rpm -ivh httpd-tools-2.2.15-53.el6.centos.x86_64.rpm warning: httpd-tools-2.2.15-53.el6.centos.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEYPreparing... ########################################### [100%]package httpd-tools-2.2.15-53.el6.centos.x86_64 is already installed
4)、库程序
[root@localhost Packages]# rpm -ivh httpd-devel-2.2.15-53.el6.centos.x86_64.rpm warning: httpd-devel-2.2.15-53.el6.centos.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEYerror: Failed dependencies:apr-devel is needed by httpd-devel-2.2.15-53.el6.centos.x86_64apr-util-devel is needed by httpd-devel-2.2.15-53.el6.centos.x86_64 [root@localhost Packages]# rpm -ivh apr-devel-1.3.9-5.el6_2.x86_64.rpm warning: apr-devel-1.3.9-5.el6_2.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEYPreparing... ########################################### [100%] 1:apr-devel ########################################### [100%][root@localhost Packages]# rpm -ivh apr-util-devel-1.3.9-3.el6_0.1.x86_64.rpm warning: apr-util-devel-1.3.9-3.el6_0.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEYerror: Failed dependencies:expat-devel is needed by apr-util-devel-1.3.9-3.el6_0.1.x86_64[root@localhost Packages]# rpm -ivh expat-devel-2.0.1-11.el6_2.x86_64.rpm warning: expat-devel-2.0.1-11.el6_2.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEYPreparing... ########################################### [100%] 1:expat-devel ########################################### [100%][root@localhost Packages]# rpm -ivh apr-util-devel-1.3.9-3.el6_0.1.x86_64.rpm warning: apr-util-devel-1.3.9-3.el6_0.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEYPreparing... ########################################### [100%] 1:apr-util-devel ########################################### [100%][root@localhost Packages]# rpm -ivh httpd-devel-2.2.15-53.el6.centos.x86_64.rpm warning: httpd-devel-2.2.15-53.el6.centos.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEYPreparing... ########################################### [100%] 1:httpd-devel ########################################### [100%] [root@localhost Packages]# rpm -qa | grep httpdhttpd-manual-2.2.15-53.el6.centos.noarchhttpd-devel-2.2.15-53.el6.centos.x86_64httpd-tools-2.2.15-53.el6.centos.x86_64httpd-2.2.15-53.el6.centos.x86_64 [root@localhost Packages]# service httpd startStarting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName [ OK ] [root@localhost ~]# service httpd statushttpd (pid 2753) is running...
CentOS 7
1、挂载系统光盘
[root@localhost ~]# ls /mnt/cdrom/CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7EFI p_w_picpaths Packages RPM-GPG-KEY-CentOS-Testing-7EULA isolinux repodata TRANS.TBL
2、rpm安装httpd
1)、安装httd主程序包,依赖httpd-tools
[root@localhost Packages]# rpm -ivh httpd-2.4.6-40.el7.centos.x86_64.rpm warning: httpd-2.4.6-40.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a0eb5: NOKEYerror: Failed dependencies:/etc/mime.types is needed by httpd-2.4.6-40.el7.centos.x86_64httpd-tools = 2.4.6-40.el7.centos is needed by httpd-2.4.6-40.el7.centos.x86_64 [root@localhost Packages]# rpm -ivh httpd-tools-2.4.6-40.el7.centos.x86_64.rpm warning: httpd-tools-2.4.6-40.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key D f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:httpd-tools-2.4.6-40.el7.centos ################################# [100%][root@localhost Packages]# rpm -ivh mailcap-2.1.41-2.el7.noarch.rpm warning: mailcap-2.1.41-2.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:mailcap-2.1.41-2.el7 ################################# [100%][root@localhost Packages]# rpm -ivh httpd-2.4.6-40.el7.centos.x86_64.rpm warning: httpd-2.4.6-40.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:httpd-2.4.6-40.el7.centos ################################# [100%]
2)、安装帮助手册
[root@localhost Packages]# rpm -ivh httpd-manual-2.4.6-40.el7.centos.noarch.rpm warning: httpd-manual-2.4.6-40.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:httpd-manual-2.4.6-40.el7.centos ################################# [100%]
3)、库程序
[root@localhost Packages]# rpm -ivh httpd-devel-2.4.6-40.el7.centos.x86_64.rpm warning: httpd-devel-2.4.6-40.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYerror: Failed dependencies:apr-devel is needed by httpd-devel-2.4.6-40.el7.centos.x86_64apr-util-devel is needed by httpd-devel-2.4.6-40.el7.centos.x86_64 [root@localhost Packages]# rpm -ivh apr-devel-1.4.8-3.el7.x86_64.rpm warning: apr-devel-1.4.8-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:apr-devel-1.4.8-3.el7 ################################# [100%][root@localhost Packages]# rpm -ivh apr-util-devel-1.5.2-6.el7.x86_64.rpm warning: apr-util-devel-1.5.2-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYerror: Failed dependencies:expat-devel(x86-64) is needed by apr-util-devel-1.5.2-6.el7.x86_64libdb-devel(x86-64) is needed by apr-util-devel-1.5.2-6.el7.x86_64openldap-devel(x86-64) is needed by apr-util-devel-1.5.2-6.el7.x86_64[root@localhost Packages]# rpm -ivh expat-devel-2.1.0-8.el7.x86_64.rpm warning: expat-devel-2.1.0-8.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:expat-devel-2.1.0-8.el7 ################################# [100%][root@localhost Packages]# rpm -ivh libdb-devel-5.3.21-19.el7.x86_64.rpm warning: libdb-devel-5.3.21-19.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:libdb-devel-5.3.21-19.el7 ################################# [100%][root@localhost Packages]# rpm -ivh openldap-devel-2.4.40-8.el7.x86_64.rpm warning: openldap-devel-2.4.40-8.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYerror: Failed dependencies:cyrus-sasl-devel(x86-64) is needed by openldap-devel-2.4.40-8.el7.x86_64[root@localhost Packages]# rpm -ivh cyrus-sasl-devel-2.1.26-19.2.el7.x86_64.rpm warning: cyrus-sasl-devel-2.1.26-19.2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYerror: Failed dependencies:cyrus-sasl(x86-64) = 2.1.26-19.2.el7 is needed by cyrus-sasl-devel-2.1.26-19.2.el7.x86_64[root@localhost Packages]# rpm -ivh cyrus-sasl-2.1.26-19.2.el7.x86_64.rpm warning: cyrus-sasl-2.1.26-19.2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:cyrus-sasl-2.1.26-19.2.el7 ################################# [100%][root@localhost Packages]# rpm -ivh cyrus-sasl-devel-2.1.26-19.2.el7.x86_64.rpm warning: cyrus-sasl-devel-2.1.26-19.2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:cyrus-sasl-devel-2.1.26-19.2.el7 ################################# [100%][root@localhost Packages]# rpm -ivh apr-util-devel-1.5.2-6.el7.x86_64.rpm warning: apr-util-devel-1.5.2-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYerror: Failed dependencies:openldap-devel(x86-64) is needed by apr-util-devel-1.5.2-6.el7.x86_64[root@localhost Packages]# rpm -ivh openldap-devel-2.4.40-8.el7.x86_64.rpm warning: openldap-devel-2.4.40-8.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:openldap-devel-2.4.40-8.el7 ################################# [100%][root@localhost Packages]# rpm -ivh apr-util-devel-1.5.2-6.el7.x86_64.rpm warning: apr-util-devel-1.5.2-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:apr-util-devel-1.5.2-6.el7 ################################# [100%][root@localhost Packages]# rpm -ivh httpd-devel-2.4.6-40.el7.centos.x86_64.rpm warning: httpd-devel-2.4.6-40.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:httpd-devel-2.4.6-40.el7.centos ################################# [100%] [root@localhost Packages]# rpm -qa | grep httpdhttpd-tools-2.4.6-40.el7.centos.x86_64httpd-2.4.6-40.el7.centos.x86_64httpd-manual-2.4.6-40.el7.centos.noarchhttpd-devel-2.4.6-40.el7.centos.x86_64 [root@localhost ~]# systemctl status httpd.service● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: inactive (dead) Docs: man:httpd(8) man:apachectl(8) [root@localhost Packages]# systemctl start httpd [root@localhost ~]# systemctl status httpd.service● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2016-10-28 18:47:37 EDT; 4s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 2705 (httpd) Status: "Processing requests..." CGroup: /system.slice/httpd.service ├─2705 /usr/sbin/httpd -DFOREGROUND ├─2706 /usr/sbin/httpd -DFOREGROUND ├─2707 /usr/sbin/httpd -DFOREGROUND ├─2708 /usr/sbin/httpd -DFOREGROUND ├─2709 /usr/sbin/httpd -DFOREGROUND └─2710 /usr/sbin/httpd -DFOREGROUND Oct 28 18:47:37 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...Oct 28 18:47:37 localhost.localdomain httpd[2705]: AH00558: httpd: Could not reliably...eOct 28 18:47:37 localhost.localdomain systemd[1]: Started The Apache HTTP Server.Hint: Some lines were ellipsized, use -l to show in full. [root@localhost Packages]# ss -tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::80 :::* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::* [root@localhost ~]# systemctl stop firewalld或者[root@localhost ~]# iptables -F
yum安装
1、查看和httpd相关的软件包
CentOS 6.8
[root@localhost ~]# yum list all httpdLoaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfilecdrom | 4.0 kB 00:00 ... Available Packageshttpd.x86_64 2.2.15-53.el6.centos cdrom [root@localhost ~]# yum list all httpd*Loaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfileInstalled Packageshttpd-tools.x86_64 2.2.15-53.el6.centos @FTP Available Packageshttpd.x86_64 2.2.15-53.el6.centos cdromhttpd-devel.i686 2.2.15-53.el6.centos cdromhttpd-devel.x86_64 2.2.15-53.el6.centos cdromhttpd-manual.noarch 2.2.15-53.el6.centos cdrom
2、查看httpd软件包的描述信息
[root@localhost ~]# yum info httpdLoaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfileAvailable PackagesName : httpdArch : x86_64Version : 2.2.15Release : 53.el6.centosSize : 833 kRepo : cdromSummary : Apache HTTP ServerURL : http://httpd.apache.org/License : ASL 2.0Description : The Apache HTTP Server is a powerful, efficient, and extensible : web server.
3、安装httpd软件包
[root@localhost ~]# yum install -y httpdLoaded plugins: fastestmirror, securitySetting up Install ProcessLoading mirror speeds from cached hostfileResolving Dependencies--> Running transaction check---> Package httpd.x86_64 0:2.2.15-53.el6.centos will be installed--> Finished Dependency Resolution Dependencies Resolved ========================================================================================== Package Arch Version Repository Size==========================================================================================Installing: httpd x86_64 2.2.15-53.el6.centos cdrom 833 k Transaction Summary==========================================================================================Install 1 Package(s) Total download size: 833 kInstalled size: 3.0 MDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Installing : httpd-2.2.15-53.el6.centos.x86_64 1/1 Verifying : httpd-2.2.15-53.el6.centos.x86_64 1/1 Installed: httpd.x86_64 0:2.2.15-53.el6.centos Complete! [root@localhost ~]# service httpd startStarting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName [ OK ][root@localhost ~]# ss -tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 :::80 :::* LISTEN 0 3 ::1:53 :::* LISTEN 0 3 192.168.80.155:53 *:* LISTEN 0 3 172.18.16.147:53 *:* LISTEN 0 3 172.16.1.5:53 *:* LISTEN 0 3 127.0.0.1:53 *:* LISTEN 0 128 :::22 :::* LISTEN 0 128 *:22 *:* LISTEN 0 100 ::1:25 :::* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 ::1:953 :::* LISTEN 0 128 127.0.0.1:953 *:*
4、客户端访问
5、卸载httpd软件包
[root@localhost ~]# yum remove -y httpdLoaded plugins: fastestmirror, securitySetting up Remove ProcessResolving Dependencies--> Running transaction check---> Package httpd.x86_64 0:2.2.15-53.el6.centos will be erased--> Finished Dependency Resolution Dependencies Resolved ========================================================================================== Package Arch Version Repository Size==========================================================================================Removing: httpd x86_64 2.2.15-53.el6.centos @cdrom 3.0 M Transaction Summary==========================================================================================Remove 1 Package(s) Installed size: 3.0 MDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Erasing : httpd-2.2.15-53.el6.centos.x86_64 1/1 Verifying : httpd-2.2.15-53.el6.centos.x86_64 1/1 Removed: httpd.x86_64 0:2.2.15-53.el6.centos Complete!
CentOS 7
1、查看和httpd相关的软件包
[root@localhost ~]# yum list all httpdLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfileAvailable Packageshttpd.x86_64 2.4.6-40.el7.centos cdrom [root@localhost ~]# yum list all httpd*Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfileAvailable Packageshttpd.x86_64 2.4.6-40.el7.centos cdromhttpd-devel.x86_64 2.4.6-40.el7.centos cdromhttpd-manual.noarch 2.4.6-40.el7.centos cdromhttpd-tools.x86_64 2.4.6-40.el7.centos cdrom
2、查看httpd软件包的描述信息
[root@localhost ~]# yum info httpdLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfileAvailable PackagesName : httpdArch : x86_64Version : 2.4.6Release : 40.el7.centosSize : 2.7 MRepo : cdrom/7/x86_64Summary : Apache HTTP ServerURL : http://httpd.apache.org/License : ASL 2.0Description : The Apache HTTP Server is a powerful, efficient, and extensible : web server.
3、安装httpd软件包
[root@localhost ~]# yum install -y httpdLoaded plugins: fastestmirrorcdrom | 3.6 kB 00:00:00 Loading mirror speeds from cached hostfileResolving Dependencies--> Running transaction check---> Package httpd.x86_64 0:2.4.6-40.el7.centos will be installed--> Processing Dependency: httpd-tools = 2.4.6-40.el7.centos for package: httpd-2.4.6-40.el7.centos.x86_64--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-40.el7.centos.x86_64--> Running transaction check---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos will be installed---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed--> Finished Dependency Resolution Dependencies Resolved ========================================================================================== Package Arch Version Repository Size==========================================================================================Installing: httpd x86_64 2.4.6-40.el7.centos cdrom 2.7 MInstalling for dependencies: httpd-tools x86_64 2.4.6-40.el7.centos cdrom 82 k mailcap noarch 2.1.41-2.el7 cdrom 31 k Transaction Summary==========================================================================================Install 1 Package (+2 Dependent packages) Total download size: 2.8 MInstalled size: 9.6 MDownloading packages:(1/3): httpd-tools-2.4.6-40.el7.centos.x86_64.rpm | 82 kB 00:00:00 (2/3): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00 (3/3): httpd-2.4.6-40.el7.centos.x86_64.rpm | 2.7 MB 00:00:00 ------------------------------------------------------------------------------------------------------------------------------------------------Total 9.5 MB/s | 2.8 MB 00:00:00 Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : httpd-tools-2.4.6-40.el7.centos.x86_64 1/3 Installing : mailcap-2.1.41-2.el7.noarch 2/3 Installing : httpd-2.4.6-40.el7.centos.x86_64 3/3 Verifying : httpd-2.4.6-40.el7.centos.x86_64 1/3 Verifying : mailcap-2.1.41-2.el7.noarch 2/3 Verifying : httpd-tools-2.4.6-40.el7.centos.x86_64 3/3 Installed: httpd.x86_64 0:2.4.6-40.el7.centos Dependency Installed: httpd-tools.x86_64 0:2.4.6-40.el7.centos mailcap.noarch 0:2.1.41-2.el7 Complete! [root@localhost ~]# rpm -q httpdhttpd-2.4.6-40.el7.centos.x86_64 [root@localhost ~]# systemctl start httpd [root@localhost ~]# ss -tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::80 :::* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::* [root@localhost ~]# systemctl stop firewalld或者[root@localhost ~]# iptables -F
4、客户端访问
5、卸载httpd软件包
[root@localhost ~]# yum remove httpdLoaded plugins: fastestmirrorResolving Dependencies--> Running transaction check---> Package httpd.x86_64 0:2.4.6-40.el7.centos will be erased--> Finished Dependency Resolution Dependencies Resolved ========================================================================================== Package Arch Version Repository Size==========================================================================================Removing: httpd x86_64 2.4.6-40.el7.centos @cdrom 9.4 M Transaction Summary==========================================================================================Remove 1 Package Installed size: 9.4 MIs this ok [y/N]: yDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction Erasing : httpd-2.4.6-40.el7.centos.x86_64 1/1 Verifying : httpd-2.4.6-40.el7.centos.x86_64 1/1 Removed: httpd.x86_64 0:2.4.6-40.el7.centos Complete!
源码编译安装
CentOS 6.8
软件包:httpd-2.2.9.tar.gz
[root@localhost ~]# tar xf httpd-2.2.9.tar.gz[root@localhost ~]# cd httpd-2.2.9/[root@localhost httpd-2.2.9]# ./configure --prefix=/usr/local/apache2.2 --enable-so --enable-rewrite --enable-charset-lite --enable-cgi[root@localhost httpd-2.2.9]# make[root@localhost httpd-2.2.9]# make install [root@localhost httpd-2.2.9]# echo 'export PATH=/usr/local/apache2.2/bin:$PATH' > /etc/profile.d/apache.sh[root@localhost httpd-2.2.9]# . /etc/profile.d/apache.sh[root@localhost httpd-2.2.9]# echo $PATH/usr/local/apache2.2/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin [root@localhost httpd-2.2.9]# httpdhttpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName[root@localhost httpd-2.2.9]# ss -tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 :::80 :::* LISTEN 0 3 ::1:53 :::* LISTEN 0 3 192.168.80.155:53 *:* LISTEN 0 3 172.18.16.147:53 *:* LISTEN 0 3 172.16.1.5:53 *:* LISTEN 0 3 127.0.0.1:53 *:* LISTEN 0 128 :::22 :::* LISTEN 0 128 *:22 *:* LISTEN 0 100 ::1:25 :::* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 ::1:953 :::* LISTEN 0 128 127.0.0.1:953 *:* [root@localhost httpd-2.2.9]# ls /usr/local/apache2.2/bin/ab checkgid envvars-std htdigest httxt2dbm apachectl dbmmanage htcacheclean htpasswd logresolve apxs envvars htdbm httpd rotatelogs [root@localhost httpd-2.2.9]# httpd -vServer version: Apache/2.2.9 (Unix)Server built: Oct 27 2016 04:29:36 设置httpd服务开机自动启动[root@localhost httpd-2.2.9]# cp /usr/local/apache2.2/bin/apachectl /etc/init.d/httpd[root@localhost httpd-2.2.9]# vi /etc/init.d/httpd #!/bin/sh# chkconfig: 2345 10 15# description: Startup script for the Apache HTTP Server....[root@localhost httpd-2.2.9]# chkconfig --add httpd[root@localhost httpd-2.2.9]# chkconfig --list | grep httpdhttpd 0:off1:off2:on3:on4:on5:on6:off [root@localhost ~]# chkconfig httpd off[root@localhost ~]# chkconfig --list | grep httpdhttpd 0:off1:off2:off3:off4:off5:off6:off[root@localhost ~]# chkconfig httpd on[root@localhost ~]# chkconfig --list | grep httpdhttpd 0:off1:off2:on3:on4:on5:on6:off 注意:如果不添加chkconfig、description两行,出报下面的错误[root@localhost httpd-2.2.9]# chkconfig --add httpdservice httpd does not support chkconfighttpd文件添加行:2345是设为要启动的运行级别,10是启动优先级,90是杀死进程的优先级,谁优先谁先挂的意思。
CentOS 7
软件包:httpd-2.4.18.tar.gz
[root@localhost ~]# tar xf package/httpd-2.4.8.tar.gz [root@localhost ~]# cd httpd-2.4.18/ [root@localhost httpd-2.4.18]# ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-pcre --with-zlib --with-apr=/usr --with-apr-util=/usr [root@localhost httpd-2.4.18]# make [root@localhost httpd-2.4.18]# make install [root@localhost httpd-2.4.18]# echo 'export PATH=/usr/local/apache2/bin:$PATH' > /etc/profile.d/apache.sh[root@localhost httpd-2.4.18]# cat /etc/profile.d/apache.shexport PATH=/usr/local/apache2/bin:$PATH[root@localhost httpd-2.4.18]# . /etc/profile.d/apache.sh [root@localhost httpd-2.4.18]# echo $PATH/usr/local/apache2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@localhost httpd-2.4.18]# apachectl [root@localhost httpd-2.4.18]# ss -tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::80 :::* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::* [root@localhost ~]# ls /usr/local/apache2/bin/ab checkgid envvars-std htdbm httpd rotatelogsapachectl dbmmanage fcgistarter htdigest httxt2dbmapxs envvars htcacheclean htpasswd logresolve [root@localhost ~]# httpd -vServer version: Apache/2.4.18 (Unix)Server built: Oct 28 2016 17:06:21
设置httpd开机自启动
[root@localhost ~]# cat /lib/systemd/system/http.service [Unit]Description=HTTP Web ServerAfter=network.target [Service]Type=forkingExecStart=/usr/local/apache2/bin/apachectl startExecReload=/usr/local/apache2/bin/apachectl restartExecStop=/usr/local/apache2/bin/apachectl stopPrivateTmp=true [Install]WantedBy=multi-user.target [root@localhost ~]# systemctl enable http.service ● http.service - HTTP Web Server Loaded: loaded (/usr/lib/systemd/system/http.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2016-10-28 18:42:00 EDT; 1s ago Process: 2622 ExecStart=/usr/local/apache2/bin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 2625 (httpd) CGroup: /system.slice/http.service ├─2625 /usr/local/apache2/bin/httpd -k start ├─2626 /usr/local/apache2/bin/httpd -k start ├─2627 /usr/local/apache2/bin/httpd -k start ├─2628 /usr/local/apache2/bin/httpd -k start ├─2629 /usr/local/apache2/bin/httpd -k start └─2630 /usr/local/apache2/bin/httpd -k start Oct 28 18:41:59 localhost.localdomain systemd[1]: Starting HTTP Web Server...Oct 28 18:42:00 localhost.localdomain apachectl[2622]: AH00558: httpd: Could not reli...eOct 28 18:42:00 localhost.localdomain systemd[1]: Started HTTP Web Server.Hint: Some lines were ellipsized, use -l to show in full. [root@localhost ~]# systemctl disable http.service