apache安装与配置

合集下载

如何在Linux上安装和配置Apache服务器

如何在Linux上安装和配置Apache服务器

如何在Linux上安装和配置Apache服务器Apache是一个流行的开源Web服务器软件,被广泛用于搭建和管理网站。

在Linux系统上安装和配置Apache服务器是一项基本的技能。

本文将介绍如何在Linux操作系统下安装和配置Apache服务器。

一、安装Apache服务器首先,打开终端窗口,并使用以下命令来更新软件包列表:sudo apt update接下来,使用以下命令来安装Apache服务器:sudo apt install apache2安装过程中,您需要输入管理员密码进行确认。

安装完成后,Apache服务器将自动启动。

二、配置Apache服务器1. 配置文件路径Apache的配置文件位于/etc/apache2目录下。

在终端中使用cd命令进入该目录:cd /etc/apache22. 主配置文件编辑主配置文件apache2.conf,使用以下命令打开该文件:sudo nano apache2.conf在打开的文件中,可以找到一些常用的配置选项,您可以根据需要进行修改。

例如,您可以更改服务器名称、监听端口等。

3. 虚拟主机配置虚拟主机配置允许您在同一台服务器上运行多个网站。

默认情况下,Apache服务器已经为您配置了一个默认的虚拟主机。

如果您想添加更多的虚拟主机,您可以在/etc/apache2/sites-available目录下创建配置文件。

使用以下命令进入该目录:cd /etc/apache2/sites-available使用以下命令创建一个新的虚拟主机配置文件,例如mywebsite.conf:sudo nano mywebsite.conf在此配置文件中,您可以设置您的网站的域名、目录路径和其他相关设置。

保存并关闭文件。

接下来,使用以下命令启用新的虚拟主机配置文件:sudo a2ensite mywebsite.conf最后,重新加载Apache服务器以应用配置更改:sudo service apache2 reload您的新虚拟主机现在应该已经生效了。

CentOS7Apache服务的安装与配置

CentOS7Apache服务的安装与配置

CentOS7Apache服务的安装与配置⼀、Apache简介Apache 是⼀个知名的开源Web服务器。

早期的Apache服务器由Apache Group来维护,直到1999年6⽉Apache Group在美国德拉⽡市成⽴了⾮盈利性组织的公司,即Apache软件基⾦会(Apache Software Foundation,ASF)。

⽹站需要web服务器来架构,⽹页设计美⼯⼈员(flash,dreamweaver,firework,photoshop等),⽹页开发⼈员(php,.net,jsp等),⽹站建⽴好后,需要我们维护,优化,排错,架构延伸扩容等。

简单点说就是我们如果要浏览⼀个⽹页的话,基本上所有的⽹站都使⽤的是http协议来进⾏数据传输的!⾄于怎么样传输,我们做为运维来说就没有必要去深究了,那是做html前端开发⼈员要去考虑的事情!Apache由内核、标准模块和第三⽅提供的模块三个层次组成。

通常Apache在默认安装时,只安装图中的1、2两部分。

根据⽤户需要,⽤户可以通过修改配置去掉⼀些默认安装的标准模块;也可以通过修改配置安装⼀些默认不安装的模块。

同时,如果⽤户需要,也可以安装⼀些第三⽅提供的模块。

[此⽹站会有每⽉份的世界上⽹站使⽤的WEB服务器的使⽤率统计](https:///archives/category/web-server-survey/)Apache是世界上应⽤最⼴泛的web服务器之⼀[ Apache官⽹](/)⼆、CentOS下的Apache1. ⽹站分为两种静态⽹站:Apache,Nginx,html动态⽹站:php/perl/python,jsp(java), .net2. Apache服务概览软件包: httpd, httpd-devel, httpd-manual服务类型:由systemd启动的守护进程配置单元: /usr/lib/systemd/system/httpd.service守护进程: /usr/sbin/httpd端⼝: 80(http), 443(https)配置: /etc/httpd/Web⽂档: /var/www/html/Apache⽇志记录⽬录:/var/log/httpd/该⽬录下有两种⽂件:access_log # 记录客户端访问Apache的信息,⽐如客户端的iperror_log # 记录访问页⾯错误信息Apache服务启动的记录⽇志:/var/log/messages # 这个⽇志是系统的⼤集合3. 配置Apache服务器的准备⼯作系统平台: CentOS 7.3DHCP Server: 192.168.1.20第1步:服务器设置静态IP第2步:更改主机名,写/etc/hosts记录[root@Apache ~]# echo "192.168.1.20 Apache" >> /etc/hosts --往/etc/hosts添加ip和主机名[root@Apache ~]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.1.20 Apache第3步:关闭防⽕墙[root@Apache ~]# systemctl stop firewalld --临时关闭防⽕墙[root@Apache ~]# systemctl disable firewalld --永久关闭防⽕墙第4步:关闭selinux临时关闭:[root@Apache ~]# setenforce 0setenforce: SELinux is disabled永久关闭:[root@Apache ~]# vim /etc/selinux/configSELINUX=disabled # 将enforcing改为disabled[root@Apache ~]# reboot --重启系统永久⽣效三、Apache服务的搭建与配置1. 使⽤yum包安装Apache软件[root@Apache ~]# yum -y install httpd*[root@Apache ~]# rpm -qa | grep httpd --查看安装的http包httpd-manual-2.4.6-67.el7.centos.6.noarchhttpd-tools-2.4.6-67.el7.centos.6.x86_64httpd-2.4.6-67.el7.centos.6.x86_64httpd-devel-2.4.6-67.el7.centos.6.x86_64安装成功后,会产⽣下⾯两个⽂件/etc/httpd/conf/httpd.conf # 主配置⽂件/var/www/html # 默认⽹站家⽬录2. 认识配置⽂件⾥的主要参数[root@Apache ~]# vim /etc/httpd/conf/httpd.conf31 serverRoot "/etc/httpd" # 存放配置⽂件的⽬录42 Listen 80 # Apache服务监听端⼝66 User apache # ⼦进程的⽤户67 Group apache # ⼦进程的组86 ServerAdmin root@localhost # 设置管理员邮件地址119 DocumentRoot "/var/www/html" --⽹站家⽬录# 设置DocumentRoot指定⽬录的属性131 <Directory "/var/www/html"> # ⽹站容器开始标识144 Options Indexes FollowSymLinks # 找不到主页时,以⽬录的⽅式呈现,并允许链接到⽹站根⽬录以外151 AllowOverride None # none不使⽤.htaccess控制,all允许156 Require all granted # granted表⽰运⾏所有访问,denied表⽰拒绝所有访问157 </Directory> # 容器结束164 DirectoryIndex index.html # 定义主页⽂件,当访问到⽹站⽬录时如果有定义的主页⽂件,⽹站会⾃动访问316 AddDefaultCharset UTF-8 # 字符编码,如果中⽂的话,有可能需要改为gb2312或者gbk,因你的⽹站⽂件的默认编码⽽异3. 启动Apache⽹站[root@Apache ~]# systemctl start httpd.service[root@Apache ~]# lsof -i:80 --查看httpd服务是否启动COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEhttpd 20585 root 4u IPv6 402909 0t0 TCP *:http (LISTEN)httpd 20586 apache 4u IPv6 402909 0t0 TCP *:http (LISTEN)httpd 20587 apache 4u IPv6 402909 0t0 TCP *:http (LISTEN)httpd 20588 apache 4u IPv6 402909 0t0 TCP *:http (LISTEN)httpd 20589 apache 4u IPv6 402909 0t0 TCP *:http (LISTEN)httpd 20590 apache 4u IPv6 402909 0t0 TCP *:http (LISTEN)启动成功后使⽤浏览器:输⼊⾃⼰的IP地址会看到⼀个红帽的欢迎页⾯:[root@Apache ~]# firefox 192.168.1.20每次打开浏览器不是很⽅便,因此我们可以使⽤⽂本浏览器,⽅便测试。

Linux下Apache的安装与配置

Linux下Apache的安装与配置

Linux下Apache的安装与配置⼀、编译安装1、解决依赖关系⼆、后续操作1、启动httpd两种⽅法:第⼀种、/usr/local/apache/bin/apachectl start第⼆种⽅法:先修改http.pid⽂件位置打开配置⽂件增加⼀⾏vim /etc/httpd/httpd.conf 增加PidFile “/var/run/httpd.pid”为了启动httpd更加⽅便,#!/bin/bash## httpd Startup script for the Apache HTTP Server## chkconfig: - 85 15# description: Apache is a World Wide Web server. It is used to serve \# HTML files and CGI.# processname: httpd# config: /etc/httpd/conf/httpd.conf# config: /etc/sysconfig/httpd# pidfile: /var/run/httpd.pid# Source function library.. /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/httpd ]; then. /etc/sysconfig/httpdfi# Start httpd in the C locale by default.HTTPD_LANG=${HTTPD_LANG-"C"}# This will prevent initlog from swallowing up a pass-phrase prompt if# mod_ssl needs a pass-phrase from the user.INITLOG_ARGS=""# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server# with the thread-based "worker" MPM; BE WARNED that some modules may not# work correctly with a thread-based MPM; notably PHP will refuse to start.# Path to the apachectl script, server binary, and short-form for messages.apachectl=/usr/local/apache/bin/apachectlhttpd=${HTTPD-/usr/local/apache/bin/httpd}prog=httpdpidfile=${PIDFILE-/var/run/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd}RETVAL=0start() {echo -n $"Starting $prog: "LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONSRETVAL=$?echo[ $RETVAL = 0 ] && touch ${lockfile}return $RETVAL}stop() {echo -n $"Stopping $prog: "killproc -p ${pidfile} -d 10 $httpdRETVAL=$?echo[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}}reload() {echo -n $"Reloading $prog: "if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; thenRETVAL=$?echo $"not reloading due to configuration syntax error"failure $"not reloading $httpd due to configuration syntax error"elsekillproc -p ${pidfile} $httpd -HUPRETVAL=$?fiecho}# See how we were called.case "$1" instart)start;;stop)stop;;status)status -p ${pidfile} $httpdRETVAL=$?;;restart)stopstart;;condrestart)if [ -f ${pidfile} ] ; thenstopstartfi;;reload)reload;;graceful|help|configtest|fullstatus)$apachectl $@RETVAL=$?;;*)echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" exit 1esacexit $RETVAL将以上代码加⼊到vim /etc/init.d/httpd中⽽后为此脚本赋予执⾏权限:chmod +x /etc/rc.d/init.d/httpd加⼊服务列表:chkconfig --add httpd给3,5启动chkconfig --level 3,5 httpd on最后加路径将 export PATH=$PATH:/usr/local/apache/binvim /etc/profile.d/httpd.sh完成后重新登录就可以了。

APACHE安装配置说明

APACHE安装配置说明

APACHE安装配置说明⼀、软件下载⼆、环境检查# rpm -qa|grep zlibzlib-devel-1.2.3-3zlib-1.2.3-3# rpm -qa|grep sslopenssl-devel-0.9.8b-10.el5openssl-0.9.8b-10.el5如果需要依赖包,安装其对应的devel包即可,此处仅⽤到zlib和ssl。

另,如果有httpd包,要先卸载掉或停⽌其服务。

三、编译安装1、针对安装⽬的的说明(来⾃INSTALL⽂件)如果是开发者则使⽤此选项,--with-included-apr利于连接apache的代码或者是调试apache,其消除了由于版本或者编译中跟APR或者APR-util代码产⽣的不匹配;如果从⼦版本编译apache,要先运⾏buildconf(需要Python,GNU autoconf和libtool),然后运⾏configure。

发⾏包不⽤。

如果要在FreeBSD5.4之前编译时包含apache的threaded MPM,需要使⽤--enable-threads和--with-mpm 参数在Mac上编译⼦版本,要使⽤GNU Libtool 1.4.2及以上版本2、关于SSL加密和正则表达式(来⾃⽂件README)Apache2.0及以上版本在⽬录modules/ssl/下包含了mod_ssl模块⽤于配置和监听ssl⽹络接⼝的连接。

(另外,⼀些apr-util版本在⽬录srclib/apr-util/ssl/下提供了ssl⽹络接⼝)带有单词crypto的包的名字,可能包含openssl加密库的⽬标代码。

如果apache的加密功能不理想或者要排除再重分配,则可以使⽤包的名字包含nossl的发布包。

Apache使⽤PCRE包包含的正则表达式。

3、对configure参数的说明配置帮助表:-h, --help显⽰帮助信息display this help and exit--help=short ⽤short参数将只显⽰正在运⾏的当前脚本的选项,⽽不能列出适⽤于Apache配置脚本所运⾏的外部配置脚本的选项display optionsspecific to thispackage--help=recursive 使⽤recursive参数将显⽰所有程序包的简短描述display the shorthelp of all theincluded packages-V, --version显⽰版本display version information and exit-q, --quiet, --silent不显⽰checking……信息do notprint`checking...' messages--cache-file=FILE在指定⽂件中存储测试结果cache test results in FILE [disabled]-C, --config-cache 在⽂件config.cache中存储测试结果alias for `--cachefile=config.cache'-n, --no-create configure脚本运⾏结束后不输出结果⽂件,常⽤于正式编译前的测试。

Linux操作系统中Apache服务安装和配置

Linux操作系统中Apache服务安装和配置

6 . 2 P H P 环 境 的配置
P H P 作为主流 的开发语言已经被广泛应 用, P H P 配 置是为网
站前端 开发奠定 运行服务 基础 。 另外, 它 搭配M y s q l 数 据库和
A p a c h e )  ̄务器能够更高效、 安全和稳定的运行 网站。
4 Ap a c h e 的配置
如果网页中启 P e r l / P y t h o n 等解释器 编译 到服务器中。 A p a c h e H T T P S e r v e r 发布 目录 和网页文件 的属性 设置为适 当的权 限。 用了D N S 域名服务器 , 那么分别定义为s o f t . n o u . c o m ¥ g n e t . n o u . 是世界使 用排 名第 一的W e b e r 务器软件 它可以运行在 几乎所
环境 安装步骤 : 1 ) 解压缩 : t a r — j x v f p h p 一 5 . 2 . 6 . t a r .
b z 2 ; 2 ) 编译 : m a k e ; 3 ) 安装 : m a k e i n s t a l l
7 结束语
总之 , L i n u x 操作系统 中的A p a c h e ) J R 务的安装 、 配 置和搭
网络地带 ・
L i n u x 操作系统中A p a c h e 服务安装和配置
于润众( 大庆职业学院 计算机应用工 程系, 黑 龙江 大庆 1 6 3 2 5 5 )
摘 要 : A p a c h e 服务 器是 当今流 行 b 服务 器之・ , L i n u x 操 作 系统 具有很多优 点, 越 来越 引起 人们的 关注。 本文 主要 描述如 何在L i n u x 系统 中搭建 和配 置A p a c h e ) ]  ̄ . 务。

Apache安装过程详解(保证您可以顺利完成安装)

Apache安装过程详解(保证您可以顺利完成安装)

一、软件准备安装 Apache HTTP Server 和 配置PHP环境,要下载 “apache_2.2.4-win32-x86-no_ssl.msi”这两个文件 的不同版本在网上可以下载到,CSDN 上就有好多版本。

二、安装 Apache HTTP Server双击“apache_2.2.4-win32-x86-no_ssl.msi”开始安装出现 Windows 标准的软件安装欢迎界面,见图1图1 欢迎界面直接点“Next”继续,出现授权协议,见图2。

图2 授权协议选择“I accept the terms in the license agreement”同意授权协议,然后点“Next”继续图3 安装说明直接点“Next”下一步,出现填写信息界面,见图4。

图4 填写信息“Network Domain”填写你的网络域名,比如 mrsoft ,如果没有网络域名,可以随便填写。

但则一定要填写正确的网络域名。

“Server Name”填入你的服务器名,比如 will ,也就是主机名。

“Administrator's Email Address”填写系统管理员的联系电子邮件地址,比如 admin@163.c 上述三条信息仅供参考,其中联系电子邮件地址会在当系统故障时提供给访问者,三条信息均可下面有两个选择,图片上选择的是为系统所有用户安装,使用默认的80端口,并作为系统服务自另外一个是仅为当前用户安装,使用端口8080,手动启动。

图5 选择安装类型选择系统默认“Typical”安装,点“Next” ,出现如图6 系统默认的安装路径图6 系统默认的安装路径这里我更改安装路径(也可以不更改,根据个人习惯),点“Change”,选择你要安装的路径,图7 更改安装路径点击“OK”,如图8所示图8 更改后的安装路径直接点“Next”下一步,图9 准备安装确认安装选项无误,如果您认为要再检查一遍,可以点“Back”一步步返回检查。

linux-Apache 配置

linux-Apache 配置

Apache 配置一、安装Apache下载地址:/1. 安装Apache# tar zxvf httpd-2.2.11.tar.gz# cd httpd-2.2.11# ./configure --prefix=/usr/local/apache --enable-so//编译时加上加载模块参数--enable-so# make# make install2. 配置系统启动时自动启动Apache服务。

# vi /etc/rc.d/rc.local//在rc.local上加入一行/usr/local/apache/bin/apachectl –k start。

二、配置Apache1. 修改httpd.conf文件# vi /usr/local/apache/conf/httpd.conf1)设置根目录的路径根目录是指Apache存放配置文件和日志文件的目录,配置参数为ServerRoot,默认位于“/u sr/local/apache”。

命令如下:2)设置监听IP地址及端口号默认侦听本机所有IP地址的TCP80端口,命令如下:Listen 80用户也可以按自己的需求,使用多个Listen语句在多个地址和端口上侦听客户端请求。

比如:Listen 192.168.99.9:80Linsten 172.16.0.20:80803)设置系统管理员E-m ail使用ServerAdmin参数设置管理员E-m ail,比如管理员的Email地址为root@guoxuemin. cn:4)设置服务器主机的名称参数ServerName用来设置服务器的主机名称,如果没有域名则填入服务器的IP地址,比如服务器的IP地址为192.168.99.9:5)设置主目录的路径用户可以使用参数Document Root配置服务器主目录默认路径,比如,主目录路径为:6)设置默认文件Apache的默认文件名为index.ht ml,可以使用Directory Index参数来配置,比如,将ind ex.php设置为默认文件名:7)测试:打开浏览器,输入地址:http://192.168.99.9,可以打开站点了:2. 配置目录权限使用<Directory 目录路径>和</Directory>设置目录的权限。

apache用法

apache用法

apache用法Apache是一款流行的web服务器软件,它能够提供网页浏览、动态内容创建、数据库服务等多种功能。

在本文中,我们将介绍Apache 的安装、配置、管理、安全性和优化等方面的知识。

一、安装Apache安装Apache非常简单,您可以从官方网站下载适合您操作系统的安装包。

在安装过程中,您需要选择安装路径、配置文件位置等选项,并设置一些基本参数。

安装完成后,您可以通过浏览器或命令行来测试Apache是否正常运行。

二、配置ApacheApache的配置文件位于`/etc/httpd/conf`目录下,该文件包含了Apache服务器的各种设置。

配置文件使用了较为简洁的语法,方便修改和调整。

您可以使用文本编辑器打开配置文件,根据您的需求进行修改。

在配置文件中,您可以设置虚拟主机、监听地址和端口、启用或禁用某些模块等功能。

同时,您还可以配置SSL证书,以实现安全传输。

配置完成后,需要重新启动Apache服务器,使配置生效。

三、管理ApacheApache提供了多种管理工具,方便您监控和调整服务器状态。

您可以使用命令行工具`apachectl`来查看服务器状态、启动和停止服务、重新加载配置等操作。

此外,您还可以使用Web管理工具,如Apache自带的Web管理界面或第三方工具,通过浏览器进行管理操作。

四、安全性Apache具有较高的安全性,但仍然需要注意一些安全问题。

首先,确保您的配置文件没有安全漏洞,如弱密码、不正确的权限设置等。

其次,及时更新Apache软件和配置文件,以修复潜在的安全漏洞。

最后,限制对配置文件的访问,以防止未经授权的修改。

五、优化Apache优化Apache可以提高服务器的性能和稳定性。

首先,优化虚拟主机配置,根据实际需求设置合适的资源分配和访问控制。

其次,使用缓存技术,如反向代理和缓存服务器,减少对数据库的访问次数。

此外,合理配置服务器硬件资源,如内存、硬盘和CPU,以充分利用服务器性能。

Apache的安装及使用

Apache的安装及使用

Apache的安装及使⽤PHP最初是 Persional Home Page 的缩写,表⽰个⼈主页。

下载Apache进⼊apache服务器官⽹这⾥我们以下载稳定版的Apache httpd 2.4.39 Released 为例,点击download。

下载后解压,改名为httpd,放到D盘根⽬录。

Apache 各⽬录作⽤⽬录名说明bin Apache执⾏⽂件所在⽬录,如httpd.exe、ApacheMonitor.exe 等cgi-bin GCI⽹页程序存放⽬录conf Apache服务器配置⽂件所在⽬录error错误⽂件⽬录,⽤于保存因服务器设置或浏览器请求的数据错误时产⽣的错误htdocs默认Web⽂档根⽬录,就是存放默认⾸页的位置icons Apache预设的⼀些⼩图标存放⽬录includeliblogs Apache ⽇志⽂件存放⽬录,主要包括访问⽇志 access.log 和错误⽇志 error.logmodules Apache服务器⽀持的动态加载模块所在⽬录安装 Aapche 服务使⽤管理员⾝份运⾏cmd,命令⾏下进⼊到 Apache 下⾯的 bin ⽬录,输⼊httpd -k install把apache安装成windows后台服务。

命令启动Apache服务:httpd -k starthttpd -k stop停⽌httpd -k restart重启更多命令,请使⽤httpd -help查看如果出现以下错误【原因】httpd.conf ⾥⾯配置的 ServerRoot 路径跟实际路径不⼀致,导致路径⽆效。

【解决⽅案】修改 D:\httpd\Apache24\conf ⽬录下的 httpd.conf ⽂件,在38⾏左右Define SRVROOT "D:/httpd/Apache24"ServerRoot "${SRVROOT}"注意路径是 “/”不是“\”端⼝冲突问题Apache 默认使⽤的端⼝号为 80,如果遇到 80 端⼝被其他应⽤程序占⽤的情况,有两种解决⽅案:⽅案⼀:将占⽤ 80 端⼝的程序关闭掉,具体做法如下:在cmd中运⾏netstat -ano "80"查看是哪个PID在使⽤ 80 端⼝,查找到PID 后可以使⽤ kill 命令将其结束掉进程。

Linux——搭建Apache(httpd)服务器

Linux——搭建Apache(httpd)服务器

Linux——搭建Apache(httpd)服务器⼀、基本概念Apache(或httpd)是Internet上使⽤最多的Web服务器技术之⼀,使⽤的传输协议是http超⽂本传输协议(⼀个基于超⽂本的协议),⽤于通过⽹络连接来发送和接受对象。

有两个版本:http:超⽂本传输协议,通过线路以明⽂形式发送,默认情况下使⽤80/TCP(也可以使⽤其他端⼝)https:经TLS/SSL安全加密的超⽂本传输协议,默认情况下使⽤端⼝443/TCP⼆、了解Apache的配置⽂件1、配置⽂件的分类在Linux系统中配置服务,其实就是修改服务的配置⽂件,httpd服务程序的主要配置⽂件及存放位置如下:配置⽂件的名称存放位置服务⽬录/etc/httpd主配置⽂件/etc/httpd/conf/httpd.conf虚拟主机配置⽂件/etc/httpd/conf.d⽇志⽂件/etc/httpd/logs⽹站数据⽬录/var/www/html2、主配置⽂件的重要参数主配置⽂件/etc/httpd/conf/httpd.conf参数⽤途ServerRoot服务⽬录ServerAdmin管理员邮箱User运⾏服务的⽤户Group运⾏服务的⽤户组ServerName⽹站服务器的域名DocumentRoot⽂档根⽬录(⽹站数据⽬录)Directory⽹站数据⽬录的权限Listen监听的IP地址与端⼝号DirectoryIndex默认的索引页页⾯ErrorLog错误⽇志⽂件CustomLog访问⽇志⽂件Timeout⽹页超时时间,默认为300秒3、Directory标签<Directory "/var/www/html">AllowOverride None #设置.htaccess⽂件中的指令类型,None表⽰禁⽌使⽤.htaccess,该参数⼀般不改Require all granted #设置权限,默认开启所有客户机访问权限</Directory>三、如何配置Apache服务器⾸先准备:主机名、⽹络、yum源1、更改主机名:[root@localhost ~]# hostnamectl set-hostname $主机名[root@localhost ~]# bash #环境变量重载2、配置⽹络(1)虚拟交换机、⽹络适配器选择仅主机模式,并且配置为192.168.100.0⽹段;(2)编辑⽹络配置⽂件:[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33修改: BOOTPROTO=static #改为静态IP地址ONBOOT=yes #改为开机⾃启IPADDR=192.168.100.10PREFIX=24 或者 NETMASK=255.255.255.0(3)重启⽹络服务:[root@localhost ~]# systemctl restart network3、配置yum源(1)先在VMware⾥⾯把系统镜像⽂件连接到虚拟机的光驱上;(2)挂载光驱⾥的镜像:[root@localhost ~]# mount /dev/cdrom /media(3)修改yum源配置⽂件:[root@localhost ~]# vim /etc/yum.repos.d/local.repo[rhel]name=rhelbaseurl=file:///mediaenabled=1gpgcheck=0(4)清空yum源缓存信息:[root@localhost ~]# yum clean all(5)检索当前yum源信息:[root@localhost ~]# yum repolist任务⼀:配置简单的httpd服务1、安装httpd服务[root@server ~]# yum -y install httpd2、启动httpd服务[root@server ~]# systemctl restart httpd[root@server ~]# systemctl enable httpd3、配置防⽕墙[root@server ~]# firewall-cmd --permanent --add-service=http[root@server ~]# firewall-cmd --reload4、关闭SELinux[root@server ~]# setenforce 05、客户端测试[root@client ~]# firefox http://IP地址或者 curl http://IP地址任务⼆:配置基于⽤户的个⼈⽹站注意:该⽤户必须在Linux系统中存在1、新建⼀个⽤户(⽹站基于该⽤户)[root@server ~]# useradd user0[root@server ~]# passwd user02、修改⽤户的家⽬录权限,使其他⽤户具有读取和执⾏的权限[root@server ~]# chmod -R 705 /home/user03、创建存放⽤户个⼈主页空间的⽬录,写user0的⽹页⽂件[root@server ~]# mkdir /home/user0/public_html[root@server ~]# cd /home/user0/public_html[root@server ~]# echo "this is user0's web">>index.html4、修改基于⽤户的httpd配置⽂件[root@server ~]# vim /etc/httpd/conf.d/userdir.conf修改: UserDir enabled #开启,表⽰让httpd服务程序开启个⼈⽤户主页功能UserDir public_html #去注释,UserDir参数表⽰⽹站数据在⽤户家⽬录中的保存⽬录名称5、配置防⽕墙(同上)[root@server ~]# firewall-cmd --permanent --add-service=http[root@server ~]# firewall-cmd --reload6、修改selinux权限[root@server ~]# getsebool -a|grep home[root@server ~]# setsebool httpd_enable_homedirs on7、重启服务[root@server ~]# systemctl restart httpd8、客户端测试[root@client ~]# firefox http://IP地址/~username 或者curl http://IP地址/~username任务三:配置基于域名访问的虚拟主机1、新建虚拟主机的⽹页⽂件[root@server ~]# mkdir /www/one /www/two[root@server ~]# cd /www/one[root@server ~]# echo "this is a web for virtual host one">>index.html[root@server ~]# cd /www/two[root@server ~]# echo "this is a web for virtual host two">>index.html[root@server ~]# chmod o+x /www2、配置虚拟主机的⽂件[root@server ~]# cd /etc/httpd/conf.d[root@server ~]# vim vhost.conf<Directory /www/one> #设置⽹站⽬录权限Require all granted #开启所有客户机访问权限</Directory><VirtualHost 192.168.100.10> #虚拟主机ServerName #定义服务器名称DocumentRoot /www/one/ #⽹站数据⽬录</VirtualHost><Directory /www/two>Require all granted</Directory><VirtualHost 192.168.100.11>ServerName DocumentRoot /www/two/</VirtualHost>3、做域名解析⽂件server/client[root@server ~]# vim /etc/hosts192.168.100.10 192.168.100.11 4、配置防⽕墙(同上)[root@server ~]# firewall-cmd --permanent --add-service=http[root@server ~]# firewall-cmd --reload5、修改虚拟主机⽹页⽂件的selinux上下⽂类型[root@server ~]# semanage fcontext -a -t httpd_sys_content_t '/www(/.*)?'[root@server ~]# restorecon -RFv /www6、重启服务[root@server ~]# systemctl restart httpd任务四:配置基于端⼝访问的虚拟主机1——新建虚拟主机的⽹页⽂件[root@server ~]# mkdir /www/8088[root@server ~]# echo "this is a web for port 8088 ">>index.html[root@server ~]# mkdir /www/8089[root@server ~]# echo "this is a web for port 8089 ">>index.html2——配置虚拟主机的⽂件[root@server ~]# cd /etc/httpd/conf.d[root@server ~]# vim vhost.conf<Directory /www/8088/>Require all granted</Directory><virtualHost 192.168.100.10:8088>DocumentRoot /www/8088/</virtualHost><Directory /www/8089/>Require all granted</Directory><virtualHost 192.168.100.10:8089>DocumentRoot /www/8089/</virtualHost>3、配置防⽕墙[root@server ~]# firewall-cmd --permanent --zone=public --add-port=8089/tcp[root@server ~]# firewall-cmd --permanent --zone=public --add-port=8088/tcp[root@server ~]# firewall-cmd --reload4、关闭SELinux[root@server ~]# setenforce 05、重启服务[root@server ~]# systemctl restart httpd6、使⽤浏览器访问任务五:配置基于TLS加密的虚拟主机注意:经TLS/SSL安全加密的超⽂本传输协议,默认情况下使⽤端⼝443/TCP 1、安装TLS加密软件,⽹站内容不⽤明⽂传输[root@server ~]# yum -y install mod_ssl2、⽣成密钥[root@server ~]# openssl genrsa >tlsweb.key3、⽣成证书请求⽂件[root@server ~]# openssl req -new -key tlsweb.key > tlsweb.csr4、⽣成证书⽂件[root@server ~]# openssl req -x509 -days 365 -key tlsweb.key -in tlsweb.csr >tlsweb.crt5、修改ssl.conf配置⽂件[root@server ~]# vim /etc/httpd/conf.d/ssl.confSSLCertificateFile /etc/pki/tls/certs/tlsweb.crtSSLCertificateKeyFile /etc/pki/tls/private/tlsweb.key6、把证书⽂件拷贝到ssl.conf配置⽂件⾥的对应路径下⾯[root@server ~]# cp tlsweb.crt /etc/pki/tls/certs/7、把秘钥⽂件拷贝到ssl.conf配置⽂件⾥的对应路径下⾯[root@server ~]# cp tlsweb.key /etc/pki/tls/private/。

Apache Ant安装与配置

Apache Ant安装与配置

Apache ant 配置1、到Apache官方网站上下载Ant,目前最新版本是1.7.1.2、解压到C盘。

3、添加环境变量(1)添加ANT_HOME使他的值等于你刚刚解压的那个文件夹的路径,如:C:\apache-ant-1.7.1(2)添加Path,在Path里面添加;%ANT_HOME%\bin.(这里面的ANT_HOME就是你上面设置的ANT_HOME)。

然后按确定即可。

(3)打开DOC命令台,在里面输入ANT,显示将如下:Buildfile: build.xml does not exist!Build failed到这说明你的配置没有问题了。

提示说找不到Build.xml这是因为我们还没有新建这个文件,找不到不是配置的问题。

PS:如果在安装的时候提示找不到Tool.jar文件,说明你的CLASSPAT H没有设置好,可以先设置好它,也可以在命令行里面输入SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_12,因为这个Jar包实在JDK中的,在JRE里面肯定找不到。

Apache Ant安装与配置博客分类:java&flexAntApacheJDKJavaAdobe1,下载Apache anturl: /bindownload.cgi2,解压到你想放置的盘符e.g. :D:\Program Files\ant\apache-ant-1.8.13,将FB安装路径下的flexTasks.jar拷贝到ANT根路径下的lib中flexTasks.jar在FB中的路径:C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\4.0.0\ant\lib[视安装而定]ANT 下的lib: D:\Program Files\ant\apache-ant-1.8.1\lib [视你解压放置的路径而定]4,配置环境变量变量:ANT_HOME值:你刚解压到的路径:D:\Program Files\ant\apache-ant-1.8.1设置Path: %ANT_HOME%\bin到止,ANT就是安装完成了,运行cmd,输入ANT,如果没有指定build.xml 就会输出:Buildfile: build.xml does not exist!Build failed如:C:\Documents and Settings\Administrator>antBuildfile: build.xml does not exist!Build failed安装成功.如果,安装到上面,输入ANT后,提示Unable to locate tools.jar这是因为没有安装JDK引起的,ANT需要在JDK环境下有效运行,OK,下边就安装JDK。

apache的配置及小经验总结

apache的配置及小经验总结
$sql="insert into table values ";
///insert into table values(1)
if($i=0;$i<$nums;$i++){
也可以通过ini_set()函数去设置配置文件的值:@ini_set('display_errors',1);
E:extension=php_zip.dll 调用压缩包
F:查找error_reporting = E_ALL & ~E_NOTICE,将其前边的分号去掉(显示所用的错误和警告,除了notice)
$sql="insert into table values('$array[$i]')";
$rec=mysql_query($sql);
}
///批量插入第二种方法
$array=$_POST['checkbox'];
$nums=count($_POST['checkbox']);
21.javascript中在处理<select multiple="multiple">标签时,join()函数和implode()函数是一样的, arr.join(",") 将数组元素以逗号连接在一起
22.1.alert(document.form1.elements.length);
D:查找DirectoryIndex 看到后面只有index.html 在它后面加上index.php (index.sht,大概在241行ml)。
F:查找 Include conf/extra/http-mpm.conf ,将此行前边的#去掉。

实验2.1 Apache Web服务器的安装和配置

实验2.1 Apache Web服务器的安装和配置

实验2.1 Apache Web服务器的安装和配置【实验目的】•掌握Apache Web服务器安装和配置【实验过程】Apache HTTPD Server(以下简称Apache)是Apache软件基金会的一个开放源码的网页服务器。

它快速、可靠并且可通过简单的API扩展,可以在大多数计算机操作系统中运行,由于其多平台和可靠性被广泛使用,是使用排名世界第一的Web服务器软件。

Apache一般作为后台任务运行:在UNIX系统中为守护进程(Daemon),在Windows 系统中为服务(Service)。

Apache的运行分为启动阶段和运行阶段。

启动阶段时,Apache 以特权用户root(UNIX)或者Administrator(Windows)启动,进行配置文件解析、模块加载和初始化一些系统资源等操作。

运行阶段时,Apache开始接收和处理网络中用户的Web 服务请求。

Apache提供Source和Binary两种发布版本。

如果使用Linux做Web服务器,推荐使用Source版本,结合主机环境进行编译,然后进行安装、配置和使用。

在Windows环境下,Apache已经不直接提供Binary安装版本,而需要使用第三方的编译版本。

在下载页面,点击“Apache httpd for Microsoft Windows ...”,找到第三方下载ApacheHaus的下载地址(可以是其他版本),下载合适自己主机操作系统环境的版本。

下载安装包之后需要将压缩包进行解压,然后将解压后的文件放置在指定的安装目录下,例如“C:\Apache24”。

首先需要做的是针对Apache的配置文件httpd.conf进行安装目录配置,Web服务端口更改。

实例:更改安装目录(在conf/httpd.conf配置文件中,下同)#Define SRVROOT "/Apache24" ~默认配置,#符号表示此行已屏蔽或者注释SRVROOT "C:\Apache24" ~Apache安装的目录,例如C:\Apache24ServerRoot "${SRVROOT}"实例:监听端口配置修改(注意选择一个系统允许的端口,80端口在很多系统中默认已经被占用,启用这个端口需要修改操作系统配置):#Listen 12.34.56.78:80 ~默认配置Listen 8081#ServerName localhost:80 ~默认配置ServerName localhost:8081在http.conf文件修改编辑完成后,以Administrator权限启动命令行窗口。

apache安装及常用配置详细图示

apache安装及常用配置详细图示
2、强烈建议在对配置文件操作前先做好配置文件的备份。 3、强烈建议在安装完成后或修改完成某个配置后,不要急着再去修改其他配置文件, 先运行 apache 服务看看是否能够正常启动。这样方便日后配置文件出错时的问题查找。 4、修改任何配置后,重新启动服务后在测试。 5、如安装 linux 时已经安装 apache 服务器跳过第 1、3 节。
二、启动停止服务...................................................................................................................5 2.1 检查端口使用情况:.................................................................................................5
三、制作服务脚本...................................................................................................................5 3.1 创建启动文件.............................................................................................................5 3.2 注册服务.....................................................................................................................6

Apache使用教程(安装与配置)

Apache使用教程(安装与配置)

Apache是一个历史悠久并且功能十分强大的WEB服务器,但其丰富的功能对于一个新手来说往往不知道从何下手。

我个人感觉Apache的设计充分体现了模块化设计的优势,通过在动态模块加载(DSO)模式下的安装,任何子应用模块都可以通过配置文件的简单修改进行积木式的灵活配置。

安装的过程可以从简单的静态html服务开始,一个模块一个模块的学习使用。

从单纯的HTML静态服务(core),到复杂的动态页面服务(core + php, core + resin, core + php + mod_gzip, core + resin + mod_expire)。

本文主要从简化安装==>性能调优==>维护方便的角度,介绍了WEB服务的规划、HTTPD安装/应用模块配置、升级/维护等过程。

让Apache和PHP,Resin等应用模块的独立升级,完全互不影响。

1.WEB应用容量规划:根据硬件配置和WEB应用的特点进行WEB服务的规划及一些简单的估算公式;2.Apache安装过程:apache的通用的简化安装选项,方便以后的应用的模块化配置;修改 HARD_SERVER_LIMIT:vi /path/to/apache_src/src/include/httpd.h#define HARD_SERVER_LIMIT 2560 <===将原来的 HARD_SERVER_LIMIT 256 后面加个“0”apache编译:./configure --prefix=/home/apache --enable-shared=max --enable-module=most3.可选应用模块/工具的安装:php resin mod_gzip mod_expire及各个模块之间的配合;mod_php安装:./configure --with-apxs=/home/apache/bin/apxs --enable-track-vars --with-mysqlmod_resin安装:./configure --with-apxs=/home/apache/bin/apxsmod_gzip安装:修改Makefile中的 apxs路径:然后make make install工具:日志轮循工具cronolog安装:4.升级/维护:看看通用和模块化的安装过程如何简化了日常的升级/维护工作;按照以上的方法:系统管理员和应用管理员的职责可以清楚的分开,互相独立。

Apache安装配置详细解读

Apache安装配置详细解读

Apache 的安装无外乎两种方式:源代码安装和二进制包安装。

这两种安装类型各有特色,二进制包安装不需要编译,而源代码安装则需要先配置编译再安装,二进制包安装在一个固定的位置下,选择固定的模块,而源代码安装则可以让你选择安装路径,选择你想要的模块。

本文主要介绍二进制DEB包安装方式。

系统:GNU/Linux Debian/etchApache当前版本: 2.4.21、安装:使用以下命令安装:tony@tonybox:~$sudo aptitude update aptitude install apache2 apache2-utils其中apache2-utils提供了我们在配置维护过程中非常有用的一些工具安装完成后,可以使用下面的命令启动Apache 服务:tony@tonybox:~$ sudo /etc/init.d/apache2 start停止Apache服务则是:tony@tonybox:~$ sudo /etc/init.d/apache2 stop也可以直接用kill 命令强制杀死apache2进程tony@tonybox:~$ sudokillall apache2如有需要,可以通过rcconf来控制是否在系统启动是加载Apache 服务启动完成后打开浏览器,使用URL http://localhost/ 来访问已经启动的Apache服务器,服务器将会跳转到http://localhost/apache2-default/, 向浏览器返回一个Apache安装成功的页面。

注:这取决于/etc/apache2/sites-available/default 配置文件中,是否取消了RedirectMatch ^/$ /apache2-default/行的注释2、配置文件说明在Debian下,安装完成后,软件包为我们提供的配置文件位于/etc/apache2目录下:tony@tonybox:/etc/apache2$ ls -ltotal 72-rw-r--r-- 1 root root 12482 2006-01-16 18:15 apache2.confdrwxr-xr-x 2 root root 4096 2006-06-30 13:56 conf.d -rw-r--r-- 1 root root 748 2006-01-16 18:05 envvars -rw-r--r-- 1 root root 268 2006-06-30 13:56httpd.conf-rw-r--r-- 1 root root 12441 2006-01-16 18:15 magic drwxr-xr-x 2 root root 4096 2006-06-30 13:56mods-availabledrwxr-xr-x 2 root root 4096 2006-06-30 13:56mods-enabled-rw-r--r-- 1 root root 10 2006-06-30 13:56 ports.conf -rw-r--r-- 1 root root 2266 2006-01-16 18:15 READMEdrwxr-xr-x 2 root root 4096 2006-06-30 13:56sites-availabledrwxr-xr-x 2 root root 4096 2006-06-30 13:56sites-enableddrwxr-xr-x 2 root root 4096 2006-01-16 18:15 ssl其中apache2.conf为apache2服务器的主配置文件,查看此配置文件,你会发现以下内容# Include module configuration:Include /etc/apache2/mods-enabled/*.loadInclude /etc/apache2/mods-enabled/*.conf# Include all the user configurations:Include /etc/apache2/httpd.conf# Include ports listingInclude /etc/apache2/ports.conf# Include generic snippets of statementsInclude /etc/apache2/conf.d/[^.#]*有此可见,apache2 根据配置功能的不同,对配置文件进行了分割,这样更利于管理conf.d下为配置文件的附加片断,默认情况下,仅提供了charset 片断,tony@tonybox:/etc/apache2/conf.d$ cat charsetAddDefaultCharset UTF-8如有需要我们可以将默认编码修改为GB2312, 即文件的内容为:AddDefaultCharset GB2312httpd.conf是个空文件magic文件中包含的是有关mod_mime_magic模块的数据,一般不需要修改它。

httpd.conf配置完美详解

httpd.conf配置完美详解

httpd.conf配置完美详解Linux下httpd.conf 配置详解1. 关于本文本文将以Apache 2.2为例,以rhel5为平台,讲述Apache服务器的安装和设置。

2. 关于ApacheApache 是一款功能强大、稳定、可支撑关键任务的Web服务器Apache具有如下特性:1) 几乎可以运行在所有的计算机平台上.2) 支持最新的HTTP/1.1协议3) 简单而且强有力的基于文件的配置(HTTPD.CONF).4) 支持通用网关接口(CGI)5) 支持虚拟主机.6) 支持HTTP认证.7) 集成PERL.8) 集成的代理服务器9) 可以通过WEB浏览器监视服务器的状态, 可以自定义日志.10) 支持服务器端包含命令(SSI).11) 支持安全SOCKET层(SSL).12) 具有用户会话过程的跟踪能力.13) 支持FASTCGI14) 支持JAVA SERVLETS.……更多信息请参阅Apache网站:/doc/327020310.html,3. Apache的安装Apache的安装无外两种方式:源码包安装和二进制包安装。

这两种方式各有特色,二位制包安装不需编译,针对不同的平台有经过优化编译的不同的二进制文件以及包格式,安装简单方便,源码包则必须先配置编译再安装,可以根据你所用的主机环境进行优化、选择你所用的模块,安装定制更灵活。

下面分别介绍这两种安装方式。

3.1 以源码包方式安装3.1.1 下载最新版本的apache软件访问apahce网站/doc/327020310.html,/download.cgi下载最新版本的Apache源码包。

本文使用的是2.2.6版本,在linux系统下用下面的命令下载:wget /doc/327020310.html,/httpd/httpd-2.2.6.tar.gz3.1.2 解压缩下载的源码包首先建立一个工作目录( 笔者建议的目录为/usr/local/src/apache ) :mkdir -p /usr/local/src/apache 将下载的源码包移至工作目录:mv httpd-2.2.6.tar.gz /usr/local/src/apache进入工作目录并用tar命令解压源码包:cd /usr/local/src/apachetar zxvf httpd-2.2.6.tar.gz命令执行结束后,当前工作目录下将生成一个新的子目录httpd-2.2.6,此目录下即为Apache的源码文件。

linux下安装apache的及反向代理配置完整过程

linux下安装apache的及反向代理配置完整过程

下面是linux下安装apache的完整代码,系统是redhat5.51、检查系统防火墙有没开,需要把防火墙关掉,可以执行SETUP查看,关闭。

在开启了防火墙时,做如下设置,开启相关端口,修改/etc/sysconfig/iptables 文件,添加以下内容:-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8088 -j ACCEPT 2、安装Apache下载地址:</>1. 安装Apache# tar zxvf httpd-2.2.22.tar.gz //解压文件# cd httpd-2.2.22//进入安装文件夹#./configure --prefix=/usr/local/apache --enable-so--enable-mods-shared=most --enable-proxy --enable-proxy-connect--enable-proxy-ftp --enable-proxy-http --enable-proxy-scgi--enable-proxy-ajp --enable-proxy-balancer // 配置apache路径加载动态模块# make //编译apache# make install//安装apache其它相关命令:下载httpd-2.2.22.tar.bz2 把httpd-2.2.22.tar.bz2放到/soft 下[root@localhost ~]#cd /soft[root@localhost soft]#tar jxvf httpd-2.2.6.tar.bz2 //解压apache的压缩包[root@localhost soft]#cd httpd-2.2.6 //定位到httpd-2.2.6 文件夹下[root@localhost httpd-2.2.6]#ls //查看显示httpd-2.2.6 文件夹下内容 [root@localhost httpd-2.2.6]# ./configure --help | more //查看安装apache配置参数[root@localhost httpd-2.2.6]#./configure --prefix=/usr/local/apache --enable-so // 配置apache路径[root@localhost httpd-2.2.6]#./configure --prefix=/usr/local/apache--enable-so --enable-mods-shared=most --enable-proxy--enable-proxy-connect --enable-proxy-ftp --enable-proxy-http--enable-proxy-scgi --enable-proxy-ajp --enable-proxy-balancer// 配置apache路径加载动态模块[root@localhost httpd-2.2.6]#make //编译apache[root@localhost httpd-2.2.6]#make install //安装apache[root@localhost httpd-2.2.6]#cd /usr/local/apache //进入apache的目录[root@localhost apache]# cd conf/[root@localhost conf]#cp httpd.conf httpd.conf_bak //备份apache配置文件[root@localhost conf]#chkconfig --list httpd //查看httpd服务是否已存在[root@localhost conf]#chkconfig httpd off //关闭系统自带了httpd的服务,如果存在httpd服务[root@localhost conf]#service httpd status //查看自带httpd服务状态[root@localhost conf]# /usr/local/apache/bin/apachectl -k start//linux启动apache命令[root@localhost conf]# /usr/local/apache/bin/apachectl -k stop //linux 停止apache命令[root@localhost conf]#netstat -an | grep :80 //查看linux80端口是否开启[root@localhost conf]#ps -aux | grep httpd //linux下查看apache进程[root@localhost conf]#cd ../..[root@localhost local]#cp /usr/local/apache/bin/apachectl/etc/rc.d/init.d/apache //拷贝apache启动脚本[root@localhost local]#vi /etc/rc.d/init.d/apache // 这里是编辑apache 启动脚本在开头的#!/bin/sh 下面加上#chkconfig: 2345 85 15[root@localhost local]#chkconfig --add apache //添加apache服务[root@localhost local]#chkconfig --list apache //列出apache服务[root@localhost local]#service apache stop //停止apache服务[root@localhost local]#netstat -an | grep :80 //查看linux的80端口是否开启[root@localhost local]#ps -aux | grep httpd //查看是否存在httpd服务,若果之前自带httpd服务启动的话会导致新添加的apache服务启动失败[root@localhost local]#service apache start //启动apache服务打开你的服务器ip地址,看看是否出现了tomcat的默认首页,如果出现的话,那么恭喜你linux下安装apache已经成功了3、修改httpd.conf文件vi /usr/local/apache/conf/httpd.conf以下为httpd.conf内容:# This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the server its instructions.# See <URL:/docs/2.2> for detailed information.# In particular, see# <URL:/docs/2.2/mod/directives.html># for a discussion of each configuration directive.## Do NOT simply read the instructions in here without understanding# what they do. They're here only as hints or reminders. If you are unsure # consult the online docs. You have been warned.## Configuration and logfile names: If the filenames you specify for many # of the server's control files begin with "/" (or "drive:/" for Win32), the # server will use that explicit path. If the filenames do *not* begin # with "/", the value of ServerRoot is prepended -- so "logs/foo_log"# with ServerRoot set to "/usr/local/apache" will be interpreted by the # server as "/usr/local/apache/logs/foo_log".## ServerRoot: The top of the directory tree under which the server's# configuration, error, and log files are kept.## Do not add a slash at the end of the directory path. If you point# ServerRoot at a non-local disk, be sure to point the LockFile directive # at a local disk. If you wish to share the same ServerRoot for multiple # httpd daemons, you will need to change at least LockFile and PidFile. #ServerRoot "/usr/local/apache"## Listen: Allows you to bind Apache to specific IP addresses and/or# ports, instead of the default. See also the <VirtualHost># directive.## Change this to Listen on specific IP addresses as shown below to# prevent Apache from glomming onto all bound IP addresses.##Listen 12.34.56.78:80Listen 80Listen 8088 --增加监听端口## Dynamic Shared Object (DSO) Support## To be able to use the functionality of a module which was built as a DSO you# have to place corresponding `LoadModule' lines at this location so the # directives contained in it are actually available _before_ they are used.# Statically compiled modules (those listed by `httpd -l') do not need# to be loaded here.## Example:# LoadModule foo_module modules/mod_foo.so#LoadModule authn_file_module modules/mod_authn_file.so --加载的模块,正确安装完会自动加载以下模块LoadModule authn_dbm_module modules/mod_authn_dbm.soLoadModule authn_anon_module modules/mod_authn_anon.soLoadModule authn_dbd_module modules/mod_authn_dbd.soLoadModule authn_default_module modules/mod_authn_default.soLoadModule authz_host_module modules/mod_authz_host.soLoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_user_module modules/mod_authz_user.soLoadModule authz_dbm_module modules/mod_authz_dbm.soLoadModule authz_owner_module modules/mod_authz_owner.soLoadModule authz_default_module modules/mod_authz_default.soLoadModule auth_basic_module modules/mod_auth_basic.soLoadModule auth_digest_module modules/mod_auth_digest.soLoadModule dbd_module modules/mod_dbd.soLoadModule dumpio_module modules/mod_dumpio.soLoadModule reqtimeout_module modules/mod_reqtimeout.soLoadModule ext_filter_module modules/mod_ext_filter.soLoadModule include_module modules/mod_include.soLoadModule filter_module modules/mod_filter.soLoadModule substitute_module modules/mod_substitute.soLoadModule deflate_module modules/mod_deflate.soLoadModule log_config_module modules/mod_log_config.soLoadModule logio_module modules/mod_logio.soLoadModule env_module modules/mod_env.soLoadModule expires_module modules/mod_expires.soLoadModule headers_module modules/mod_headers.soLoadModule ident_module modules/mod_ident.soLoadModule setenvif_module modules/mod_setenvif.soLoadModule version_module modules/mod_version.soLoadModule proxy_module modules/mod_proxy.soLoadModule proxy_connect_module modules/mod_proxy_connect.soLoadModule proxy_ftp_module modules/mod_proxy_ftp.soLoadModule proxy_http_module modules/mod_proxy_http.soLoadModule proxy_scgi_module modules/mod_proxy_scgi.soLoadModule proxy_ajp_module modules/mod_proxy_ajp.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.so LoadModule mime_module modules/mod_mime.soLoadModule dav_module modules/mod_dav.soLoadModule status_module modules/mod_status.soLoadModule autoindex_module modules/mod_autoindex.soLoadModule asis_module modules/mod_asis.soLoadModule info_module modules/mod_info.soLoadModule cgi_module modules/mod_cgi.soLoadModule dav_fs_module modules/mod_dav_fs.soLoadModule vhost_alias_module modules/mod_vhost_alias.soLoadModule negotiation_module modules/mod_negotiation.soLoadModule dir_module modules/mod_dir.soLoadModule imagemap_module modules/mod_imagemap.soLoadModule actions_module modules/mod_actions.soLoadModule speling_module modules/mod_speling.soLoadModule userdir_module modules/mod_userdir.soLoadModule alias_module modules/mod_alias.soLoadModule rewrite_module modules/mod_rewrite.soTimeout 300 --新增的配置参数KeepAlive OnMaxKeepAliveRequests 1000KeepAliveTimeout 15UseCanonicalName OffAccessFileName .htaccessServerTokens FullServerSignature OnHostnameLookups Off<IfModule !mpm_netware_module><IfModule !mpm_winnt_module>## If you wish httpd to run as a different user or group, you must run # httpd as root initially and it will switch.## User/Group: The name (or #number) of the user/group to run httpd as. # It is usually good practice to create a dedicated user and group for # running httpd, as with most system services.#User daemonGroup daemon</IfModule></IfModule>----------------------------------以下内容是新增的关键参数<IfModule mpm_prefork_module>StartServers 40MinSpareServers 40MaxSpareServers 80MaxClients 256MaxRequestsPerChild 10000</IfModule><IfModule mpm_worker_module>StartServers 40MaxClients 2000MinSpareThreads 100MaxSpareThreads 300ThreadsPerChild 200MaxRequestsPerChild 0</IfModule>ProxyRequests OffRewriteEngine onRewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)RewriteRule .* - [F]RewriteEngine onRewriteCond %{HTTP:range} !(^bytes=[^,]+(,[^,]+){0,4}$|^$)RewriteRule .* - [F]TraceEnable off#NameVirtualHost 10.46.85.137:9080#<VirtualHost 10.46.85.137:9080>#ServerName 10.46.85.137:9080#ProxyPass /ponApp/ http://10.209.122.40:7001/xponApp/#ProxyPassReverse /ponApp/ http://10.209.122.40:7001/xponApp/#</VirtualHost>NameVirtualHost 10.46.85.137:8088<VirtualHost 10.46.85.137:8088>ServerName kuangdai --kuangdai LINUX系统的主机名ProxyPass /xponApp/ http://10.209.122.40:7001/xponApp/ ProxyPassReverse /xponApp/ http://10.209.122.40:7001/xponApp/启动服务报错--/etc/hosts 增加127.0.0.1 localhost.localdomainlocalhost ”kuangdai“主机名</VirtualHost><Proxy *>--配置反向代理的访问权限Order deny,allowAllow from all</Proxy>-----------------------------以上内容是新增的关键参数# 'Main' server configuration## The directives in this section set up the values used by the 'main'# server, which responds to any requests that aren't handled by a# <VirtualHost> definition. These values also provide defaults for# any <VirtualHost> containers you may define later in the file.## All of these directives may appear inside <VirtualHost> containers,# in which case these default settings will be overridden for the# virtual host being defined.### ServerAdmin: Your address, where problems with the server should be# e-mailed. This address appears on some server-generated pages, such # as error documents. e.g. admin@#ServerAdmin you@## ServerName gives the name and port that the server uses to identify itself.# This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup.## If your host doesn't have a registered DNS name, enter its IP address here. #ServerName 127.0.0.1:80 --这个ServerName可随意配置一定去掉前面### DocumentRoot: The directory out of which you will serve your# documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations.#DocumentRoot "/usr/local/apache/htdocs"## Each directory to which Apache has access can be configured with respect # to which services and features are allowed and/or disabled in that# directory (and its subdirectories).## First, we configure the "default" to be a very restrictive set of# features.#<Directory />Options FollowSymLinksAllowOverride NoneOrder deny,allowDeny from all</Directory>## Note that from this point forward you must specifically allow# particular features to be enabled - so if something's not working as # you might expect, make sure that you have specifically enabled it# below.### This should be changed to whatever you set DocumentRoot to.#<Directory "/usr/local/apache/htdocs">## Possible values for the Options directive are "None", "All",# or any combination of:# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews## Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you.## The Options directive is both complicated and important. Please see # /docs/2.2/mod/core.html#options# for more information.#Options Indexes FollowSymLinks## AllowOverride controls what directives may be placed in .htaccess files.# It can be "All", "None", or any combination of the keywords:# Options FileInfo AuthConfig Limit#AllowOverride None## Controls who can get stuff from this server.#Order allow,denyAllow from all</Directory>## DirectoryIndex: sets the file that Apache will serve if a directory# is requested.#<IfModule dir_module>DirectoryIndex index.html</IfModule>## The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients.#<FilesMatch "^\.ht">Order allow,denyDeny from allSatisfy All</FilesMatch>## ErrorLog: The location of the error log file.# If you do not specify an ErrorLog directive within a <VirtualHost># container, error messages relating to that virtual host will be# logged here. If you *do* define an error logfile for a <VirtualHost> # container, that host's errors will be logged there and not here.#ErrorLog "logs/error_log"## LogLevel: Control the number of messages logged to the error_log.# Possible values include: debug, info, notice, warn, error, crit,# alert, emerg.#LogLevel warn<IfModule log_config_module>## The following directives define some format nicknames for use with # a CustomLog directive (see below).#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedLogFormat "%h %l %u %t \"%r\" %>s %b" common<IfModule logio_module># You need to enable mod_logio.c to use %I and %OLogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"\"%{User-Agent}i\" %I %O" combinedio</IfModule>## The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a <VirtualHost># container, they will be logged here. Contrariwise, if you *do*# define per-<VirtualHost> access logfiles, transactions will be# logged therein and *not* in this file.#CustomLog "logs/access_log" common## If you prefer a logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive.##CustomLog "logs/access_log" combined</IfModule><IfModule alias_module>## Redirect: Allows you to tell clients about documents that used to # exist in your server's namespace, but do not anymore. The client # will make a new request for the document at its new location.# Example:# Redirect permanent /foo /bar## Alias: Maps web paths into filesystem paths and is used to# access content that does not live under the DocumentRoot.# Example:# Alias /webpath /full/filesystem/path## If you include a trailing / on /webpath then the server will# require it to be present in the URL. You will also likely# need to provide a <Directory> section to allow access to# the filesystem path.## ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that# documents in the target directory are treated as applications and # run by the server when requested rather than as documents sent to the # client. The same rules about trailing "/" apply to ScriptAlias# directives as to Alias.#ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"</IfModule><IfModule cgid_module>## ScriptSock: On threaded servers, designate the path to the UNIX# socket used to communicate with the CGI daemon of mod_cgid.##Scriptsock logs/cgisock</IfModule>## "/usr/local/apache/cgi-bin" should be changed to whatever your ScriptAliased# CGI directory exists, if you have that configured.#<Directory "/usr/local/apache/cgi-bin">AllowOverride NoneOptions NoneOrder allow,denyAllow from all</Directory>## DefaultType: the default MIME type the server will use for a document # if it cannot otherwise determine one, such as from filename extensions. # If your server contains mostly text or HTML documents, "text/plain" is # a good value. If most of your content is binary, such as applications # or images, you may want to use "application/octet-stream" instead to # keep browsers from trying to display binary files as though they are # text.#DefaultType text/plain<IfModule mime_module>## TypesConfig points to the file containing the list of mappings from # filename extension to MIME-type.#TypesConfig conf/mime.types## AddType allows you to add to or override the MIME configuration# file specified in TypesConfig for specific file types.##AddType application/x-gzip .tgz## AddEncoding allows you to have certain browsers uncompress# information on the fly. Note: Not all browsers support this.##AddEncoding x-compress .Z#AddEncoding x-gzip .gz .tgz## If the AddEncoding directives above are commented-out, then you# probably should define those extensions to indicate media types: #AddType application/x-compress .ZAddType application/x-gzip .gz .tgz## AddHandler allows you to map certain file extensions to "handlers": # actions unrelated to filetype. These can be either built into the server # or added with the Action directive (see below)## To use CGI scripts outside of ScriptAliased directories:# (You will also need to add "ExecCGI" to the "Options" directive.) ##AddHandler cgi-script .cgi# For type maps (negotiated resources):#AddHandler type-map var## Filters allow you to process content before it is sent to the client. ## To parse .shtml files for server-side includes (SSI):# (You will also need to add "Includes" to the "Options" directive.) ##AddType text/html .shtml#AddOutputFilter INCLUDES .shtml</IfModule>## The mod_mime_magic module allows the server to use various hints from the # contents of the file itself to determine its type. The MIMEMagicFile # directive tells the module where the hint definitions are located.##MIMEMagicFile conf/magic## Customizable error responses come in three flavors:# 1) plain text 2) local redirects 3) external redirects## Some examples:#ErrorDocument 500 "The server made a boo boo."#ErrorDocument 404 /missing.html#ErrorDocument 404 "/cgi-bin/missing_handler.pl"#ErrorDocument 402 /subscription_info.html### MaxRanges: Maximum number of Ranges in a request before# returning the entire resource, or one of the special# values 'default', 'none' or 'unlimited'.# Default setting is to accept 200 Ranges.#MaxRanges unlimited## EnableMMAP and EnableSendfile: On systems that support it,# memory-mapping or the sendfile syscall is used to deliver# files. This usually improves server performance, but must# be turned off when serving from networked-mounted# filesystems or if support for these functions is otherwise# broken on your system.##EnableMMAP off#EnableSendfile off# Supplemental configuration## The configuration files in the conf/extra/ directory can be# included to add extra features or to modify the default configuration of # the server, or you may simply copy their contents here and change as# necessary.# Server-pool management (MPM specific)#Include conf/extra/httpd-mpm.conf# Multi-language error messages#Include conf/extra/httpd-multilang-errordoc.conf# Fancy directory listings#Include conf/extra/httpd-autoindex.conf# Language settings#Include conf/extra/httpd-languages.conf# User home directories#Include conf/extra/httpd-userdir.conf# Real-time info on requests and configuration#Include conf/extra/httpd-info.conf# Virtual hosts#Include conf/extra/httpd-vhosts.conf# Local access to the Apache HTTP Server Manual#Include conf/extra/httpd-manual.conf# Distributed authoring and versioning (WebDAV)#Include conf/extra/httpd-dav.conf# Various default settings#Include conf/extra/httpd-default.conf# Secure (SSL/TLS) connections#Include conf/extra/httpd-ssl.conf## Note: The following must must be present to support# starting without SSL on platforms with no /dev/random equivalent # but a statically compiled-in mod_ssl.#<IfModule ssl_module>SSLRandomSeed startup builtinSSLRandomSeed connect builtin </IfModule>。

Apache服务器配置与管理

Apache服务器配置与管理

Apache服务器配置与管理一、Apache服务器的安装与启动1、查询系统是否安装了Apacherpm -qa | grep httpd2、运行如下命令进行安装rpm -ivh /media/RH*/Server/httpd-2.2.3-11.e15_1.3.i386.rpm3、启动Apache服务器service httpd restart 或者etc/init.d/httpd restart4、检测配置文件的语法service httpd configtest5、测试Apache服务器注意:防火墙的配置二、Apache服务器默认的配置文件信息1、主配置文件:/etc/httpd/conf/httpd.conf2、服务器的根目录(ServerRoot):/etc/httpd3、根文档目录(DocumentRoot):/var/www/html4、访问日志文件:/etc/httpd/logs/access_log5、错误日志文件:/etc/httpd/logs/error_log6、模块存放路径:/etc/httpd/modules(一)httpd.conf文件的格式1、httpd.conf配置文件主要由全局环境、主服务器配置和虚拟主机3个部分组成2、配置语句的语法格式:配置参数名称参数值3、检查httpd.conf的语法是否正确apachectl configtest 或者service httpd configtest(二)Web服务的基本配置1、主目录的路径(DocumentRoot)默认位置:/var/www/html可以将需要发布的网页放在这个目录下2、默认文档在浏览器中,输入Web站点的IP地址或域名即显示出来的Web页面DirectoryIndex index.html index.htm index.php index.html.var3、配置Apache监听的IP地址和端口号Listen 80(在本机所有可用IP地址上监听TCP 80端口)只监听IP地址为192.168.16.177的80端口和192.168.18.178的8080端口Listen 192.168.16.177 80Listen 192.168.18.178 80804、设置相对根目录路径相对根目录通常是Apache存放配置文件、日志文件、模块文件等的地方。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
ps=\
worker.list=ajp13 #模块版本
worker.ajp13.port=8009 #工作端口,若没占用则不用修改
worker.ajp13.host=localhost #本机,若上面的Apache主机不为localhost,作相应修改
worker.ajp13.type=ajp13 #类型
AllowOverride None
Order deny,allow
deny fБайду номын сангаасom all
Satisfy all
<// Directory>
然后把deny from all中的deny改成了allow,保存后重起了 apache,问题解决。
DirectoryIndex index.html index.htm index.jsp
ErrorLog logs/shsc-error_log.txt
CustomLog logs/shsc-access_log.txt common
JkMount /servlet/* ajp13
#让Apache支持对servlet传送,用以Tomcat解析
下载 apache tomcat jk
tomcat 配置
在%TOMCAT_HOME%\conf下新建或修改workers.properties,内容如下:
workers.tomcat_home=D:\Apache\Tomcat6.0 #让mod_jk模块知道Tomcat的位置
workers.java_home=D:\Program Files\Java\jre6 #让mod_jk模块知道jre的位置
JkLogLevel info
#设置虚拟主机
<VirtualHost localhost>
ServerAdmin localhost
DocumentRoot D:/Apache/Tomcat6.0/webapps/ROOT
#您的站点项目所在路径,应与tomcat中的目录设置相同
ServerName localhost
worker.ajp13.lbfactor=1 #代理数,不用修改
apache 配置
修改%APACHE_HOME%\conf下httpd.conf文件 在尾部添加如下信息:
#设置Apache与Tomcat之间的连接,让Apache遇到jsp文件时,在后台将其交由Tomcat去处理
LoadModule jk_module modules/mod_jk-1.2.30-httpd-2.2.3.so
#此处mod_jk的文件为你下载的文件
JkWorkersFile "D:/Apache/Tomcat6.0/conf/workers.properties"
#指定tomcat监听配置文件地址
JkLogFile "D:/Apache/Tomcat6.0/logs/mod_jk2.log"
#指定日志存放位置
JkMount /*.jsp ajp13
#让Apache支持对jsp传送,用以Tomcat解析
JkMount /*.do ajp13
#让Apache支持对.do传送,用以Tomcat解析
</VirtualHost>
重启apache服务
查看apache服务启动错误,进入apache目录下bin目录 运行 httpd.exe -t
出现无权访问的错误的解决方案:
linux服务器出现Forbidden You don’t have permission to access / on this server的解决方法
1:httpd.conf设置不正确
一:
<Directory />
Options FollowSymLinks
相关文档
最新文档