linux apache 2.4.3 安装概要
如何在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您的新虚拟主机现在应该已经生效了。
在Linux上搭建Web服务器的步骤
在Linux上搭建Web服务器的步骤在当今的数字化世界中,Web服务器作为承载和提供网页服务的重要组成部分,它的搭建对于Web应用程序的开发和部署具有至关重要的意义。
在本文中,我们将介绍在Linux操作系统上搭建Web服务器的步骤。
一、Linux环境准备1.选择合适的Linux发行版:目前常见的Linux发行版有Ubuntu、CentOS等,选择合适的发行版作为我们的Web服务器操作系统。
2.安装Linux操作系统:根据所选择的Linux发行版,进行系统的安装。
安装过程中需要设置用户名、密码等相关配置。
二、安装所需软件1.安装Apache服务器:Apache是目前最广泛使用的Web服务器软件之一。
在Linux上安装Apache可以通过包管理工具进行安装,以Ubuntu为例,命令如下:```sudo apt-get update //更新软件源sudo apt-get install apache2 //安装Apache```2.安装PHP解释器:PHP是一种广泛使用的服务器端脚本语言,用于动态生成Web页面。
同样使用包管理工具进行安装,以Ubuntu为例,命令如下:```sudo apt-get install php libapache2-mod-php //安装PHP和Apache模块```3.安装MySQL数据库:MySQL是一种开源的关系型数据库管理系统,用于存储和管理网站所需的数据。
以Ubuntu为例,命令如下:```sudo apt-get install mysql-server //安装MySQL服务器sudo mysql_secure_installation //进行安全设置```三、配置服务器1.配置Apache服务器:Apache的配置文件位于/etc/apache2目录下,通过编辑该文件可以对服务器进行相关配置。
```sudo nano /etc/apache2/apache2.conf //编辑配置文件```在配置文件中可以设置服务器的根目录、虚拟主机等信息。
CentOS6.0+apache2.4+php5.4.7+mysql5.5.27
CentOS6.0+apache2.4+php5.4.7+mysql5.5.27一、安装前准备1、安装编译工具及所需要库文件yum install make apr* autoconf automake curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel gd gettext gettext-devel kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel2、下载软件包(统一下载到/usr/local/src )wget /Downloads/MySQL-5.5/mysql-5.5.27.tar.gzwget /files/v2.8/cmake-2.8.8.tar.gzwget /apache//httpd/httpd-2.4.3.tar.gzwget /apache//apr/apr-1.4.6.tar.gz # Apache库文件wget /apache//apr/apr-util-1.4.1.tar.gz # Apache库文件wget /distributions/php-5.4.7.tar.gzwget /project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz #PHPlibmcrypt模块wget ftp:///pub/software/programming/pcre/pcre-8.31.tar.gz二、安装mysql 5.5.271、安装cmake# cd /usr/local/src# tar zxf cmake-2.8.8.tar.gz# cd cmake-2.8.8# ./configure# make# make install2、开始安装mysql# groupadd mysql# useradd -g mysql mysql -s /bin/false // 创建用户mysql并加入到mysql组,不允许mysql 用户直接登陆系统# mkdir -p /data/mysql // 创建mysql 数据库存放目录# chown -R mysql.mysql /data/mysql // 设置mysql 数据库权限# mkdir -p /usr/local/mysql // 创建mysql 安装目录# cd /usr/local/src# tar zxf mysql-5.5.27.tar.gz# cd mysql-5.5.27# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc# make# make install# cd /usr/local/mysql# cp ./support-files/f /etc/f# vi /etc/f //编辑配置文件,在[mysqld] 部分增加下面一行datadir = /data/mysql:wq! 保存# ./scripts/mysql_install_db --user=mysql# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld // 把mysql 加入系统启动# chmod 755 /etc/init.d/mysqld# chkconfig mysqld on# vi /etc/rc.d/init.d/mysqld 修改下面两项定义basedir =/usr/local/mysql // MySQL程序安装路径datadir =/data/mysql // MySQl数据库存放目录大约在46、47行,注意,等号后面不要有空格# service mysqld start# vi /etc/profile // 把mysql服务加入系统环境变量:在最后添加下面这一行export PATH=$PATH:/usr/local/mysql/bin:wq! // 保存下面这两行把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定mysql的库文件地址ln -s /usr/local/mysql/lib/mysql /usr/lib/mysqlln -s /usr/local/mysql/include/mysql /usr/include/mysql# shutdown -r now // 需要重启系统,等待系统重新启动之后继续在终端命令行下面操作# mysql_secure_installation // 根据提示按Y 回车,然后输入2次同样的密码,继续按Y 回车,直到设置完成。
Linux下Apache服务的部署和配置
Linux下Apache服务的部署和配置⽬录1 Apache的作⽤2 Apache的安装3 apache的启⽤4 apache的基本信息5 apache的访问控制5.1 基于客户端ip的访问控制5.2 基于⽤户认证的访问控制6 apache的虚拟主机7 apache的加密访问8 ⽹页重写9 正向代理10 反向代理11 apache ⽀持的语⾔1 Apache的作⽤解析⽹页语⾔,如html,php,jsp等接收web⽤户的请求,并给予⼀定的响应2 Apache的安装安装apche软件:dnf install httpd.x86_64 -y3 apache的启⽤开启apache服务并设置开机启动:systemctl enable --now httpd查看apache服务的状态:systemctl enable --now httpd查看⽕墙信息:firewall-cmd --list-all 在⽕墙中永久开启http服务:firewall-cmd --permanent --add-service=http在⽕墙中永久开启https服务: f irewall-cmd --permanent --add-service=https在不改变当前⽕墙状态的情况下刷新防⽕墙:firewall-cmd --reload4 apache的基本信息apche的基本信息服务名称:httpd主配置⽂件:/etc/httpd/conf/httpd.conf⼦配置⽂件:/etc/httpd/conf.d/*.conf默认发布⽬录:/var/www/html默认端⼝:80 (http),443(https)⽇志⽂件:/etc/httpd/logs开启apche服务后,输⼊ip查看默认发布页⾯:(1)更改apche服务的端⼝号查看httpd服务的默认端⼝号:netstat -antlupe |grep httpd编辑配置⽂件:/etc/httpd/conf/httpd.conf,修改端⼝号重启httpd服务:systemctl restart httpd查看httpd服务的端⼝号:netsat -antlupe | grep httpd更改端⼝号后,输⼊ip后⽆法正常连接,原因是8080端⼝未添加在⽕墙中在防⽕墙⾥添加888端⼝号:firewall-cmd --permanent --add-port=888/tcp在不改变当前⽕墙状态的情况下刷新防⽕墙:firewall-cmd --reload输⼊IP地址:端⼝号,可以正常访问(2)修改apche的默认发布⽂件默认⽬录:cd /var/www/html在⽂件默认发布⽬录下新建⼀个⽂件index.html输⼊:http://172.25.254.144查看默认发布⽂件就是访问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安装配置说明⼀、软件下载⼆、环境检查# 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脚本运⾏结束后不输出结果⽂件,常⽤于正式编译前的测试。
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 配置
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>设置目录的权限。
Apache2.4+PHP5.4+CodeIgniter安装步骤
Apache 2.4.23 + PHP 5.4.45 + CodeIgniter安装步骤1 Apache安装1.1 下载:访问/download/VC10/下载WINDOWS XP可以使用的最新版本。
1.2 解压:C:\Apache2.4。
1.3 配置:打开C:\Apache24\conf\httpd.conf找到ServerName修改为ServerName localhost:8080,找到Listen修改为Listen 8080,找到ServerRoot修改网站基地址,找到DocumentRoot修改网页目录,找到Directory修改虚拟目录,找到DirectoryIndex添加默认显示页面名称。
1.4 运行环境:安装Visual C++ Runtime(x86)运行环境。
1.5 启动:进行DOC窗口,CD C:\Apache24\bin,httpd.exe为窗口启动,httpd.exe -k install 为安装服务。
然后访问http://localhost:8080即可显示It works!2 PHP安装2.1 下载:访问/download/下载WINDOWS XP可以使用的最新版本。
2.2 解压:C:\PHP2.3 环境变量:右击我的电脑,点击属性,点击高级--环境变量,点击系统变量--Path,添加;C:\PHP;C:\PHP\ext;C:\Apache24\bin(可以不添加)。
2.4 配置:修改C:\PHP\php.ini-production修改为C:\PHP\php.ini。
找到修改extension_dir修改为“ext”或“.\ext”或“C:\PHP\ext”。
2.5 功能扩展:找到extension选择需要的模块并去掉前面的分号即可开启。
3 Apache与PHP关联3.1 打开C:\Apache2.4\conf\httpd.conf找到LoadModule,在最后添加LoadModule php5_module "C:/php/php5apache2_4.dll"。
apache2.4.3的安装以及整合tomcat
操作准备:(1)安装apache-tomcat-6.0.20到 /opt 下,并修改名字为tomcat(很简单直接解压就行了,再次不再赘述)(2)上传以下安装包到opt下(如果已经存在则不用上传)(3)如果机器上没有安装过apache则直接跳到安装apache的步骤进行操作停止现在的apache服务:[root@localhost local]# cd /opt/apache/bin[root@localhost bin]# ./apachectl stop修改现有apache端口:[root@localhost bin]# cd /opt/apache/conf[root@localhost conf]# vi httpd.conf找到 Listen 80改为 Listen 81备注: 修改文件操作是光标定格到80后面然后按下i键,即可进行修改修改完毕,按下Esc键然后输入 :wq (wq前面有个冒号)开始安装apache:[root@localhost ~]# cd /opt //源码存放位置[root@localhost opt]# tar -zxvf apr-1.4.6.tar.gz[root@localhost opt]# cd apr-1.4.6[root@localhost apr-1.4.6]# ./configure --prefix=/usr/local/apr可能遇见的情况如下:如果出现以下错误则编辑libtool将 $echo 替换为$ECHO具体操作::%s#$echo#$ECHO#groot@localhost apr-1.4.6]# makeroot@localhost apr-1.4.6]# make installroot@localhost apr-1.4.6]# cd /optroot@localhost opt]# tar -zxvf apr-util-1.5.1.tar.gzroot@localhost opt]# cd apr-util-1.5.1root@localhost apr-util-1.5.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprroot@localhost apr-util-1.5.1]# makeroot@localhost apr-util-1.5.1]# make installroot@localhost apr-util-1.5.1]# cd /optroot@localhost opt]# unzip -o pcre-8.30.ziproot@localhost opt]# cd pcre-8.30root@localhost cd pcre-8.30]# ./configure --prefix=/usr/local/pcreroot@localhost cd pcre-8.30]# makeroot@localhost cd pcre-8.30]# make installroot@localhost cd pcre-8.30]# cd /opt[root@localhost opt]# tar -zxvf httpd-2.4.3.tar.gz[root@lamp opt]# cp -rf apr-1.4.6 httpd-2.4.3/srclib/apr[root@lamp opt]# cp -rf apr-util-1.5.1 httpd-2.4.3/srclib/apr-util 这两句话是为了防止,安装时报如下错误Configur:error:Bundled APR requested but not found at ./srclib/. Download …[root@localhost opt]# cd httpd-2.4.3[root@localhost httpd-2.4.3]# ./configure --prefix=/usr/local/apache --enable-so –enable-mods-shared=most --with-mpm=worker --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-included-apr加入--with-included-apr为了防止apache启动报错:例如httpd: Syntax error on line 140 of /usr/local/apache2/conf/httpd.conf: Cannot load/usr/local/apache2/modules/mod_dir.so into server: /usr/local/apache2/modules/mod_dir.so: undefined symbol: apr_array_clear[root@localhost httpd-2.4.3]# make[root@localhost httpd-2.4.3]# make installroot@localhost httpd-2.4.3]#cd /usr/local/apache //进入apache的目录root@localhost apache]# cd conf/root@localhost conf]#cp -a httpd.conf httpd.conf- //备份apache配置文件启动apache服务:用于查看是否正确安装apacheroot@localhost conf]#cd /usr/local/apache/binroot@localhost bin]# ./apachectl start然后打开浏览器输入http://localhost:80进行查看Apache与tomcat的整合:root@localhost bin]# cd /optroot@localhost opt]# tar –zxvf tomcat-connectors-1.2.37-src.tar.gzroot@localhost opt]# cd tomcat-connectors-1.2.37-src/nativeroot@localhost native]# ./configure --with-apxs=/usr/local/apache/bin/apxsroot@localhost native]# makeroot@localhost native]# cp ./apache-2.0/mod_jk.so /usr/local/apache/modules/ root@localhost native]# cd/usr/local/apache/confroot@localhost conf]# ls创建 mod_jk.conf和workers.properties 这两个文件到此conf 文件夹中创建mod_jk.confvi mod_jk.confJkWorkersFile /usr/local/apache/conf/workers.properties# Where to put jk logsJkLogFile /usr/local/apache/logs/mod_jk.log# Set the jk log level [debug/error/info]JkLogLevel info# Select the log formatJkLogStampFormat "[%a %b %d %H:%M:%S %Y]"# JkOptions indicate to send SSL KEY SIZE,#JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories # JkRequestLogFormat set the request formatJkRequestLogFormat "%w %V %T"JkMount /servlet/* worker1JkMount /*.jsp worker1创建workers.propertiesvi workers.properties# Defining a worker named worker1 and of type ajp13worker.list=worker1worker.worker1.type=ajp13worker.worker1.host=localhostworker.worker1.port=8009worker.worker1.lbfactor=50worker.worker1.cachesize=1worker.worker1.cache_timeout=600worker.worker1.socket_keepalive=1worker.worker1.socket_timeout=300保存退出root@localhost conf]# vi httpd.conf修改DocumentRoot 为 (我的网页放在/opt/sgcc_web/ 下)"/opt/sgcc_web"下面的那一个Directory 节点也改为 "/opt/sgcc_web"跳到文件末尾找到SSLRandomSeed startup builtinSSLRandomSeed connect builtin</IfModule>删除此节点以后的全部内容,并追加以下两句话LoadModule jk_module modules/mod_jk.soInclude /usr/local/apache/conf/mod_jk.conf如下图:然后找到以下两句,删除前面的#号#LoadModule ssl_module modules/mod_ssl.so#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so 第一句话是防止apache启动时报以下错误AH00526: Syntax error on line 51 of /usr/local/apache2/conf/extra/httpd-ssl.conf: Invalid command 'SSLCipherSuite', perhaps misspelled or definedby a module not included in the server configuration第二句话是防止apache启动时报以下错误AH00526: Syntax error on line 76 of /usr/local/apache2/conf/extra/httpd-ssl.conf: SSLSessionCache: 'shmcb' session cache not supported (knownnames: ). Maybe you need to load the appropriate socache module(mod_socache_shmcb?).保存,apache配置结束!最后编辑Tomcat的配置文件server.xml,在HOST段中加入:在http://localhost:8080/和http://localhost:80/index.jsp,应该可以看到相同的页面了。
linux下apache编译安装配置
中标麒麟linux下Apache编译安装步骤中标麒麟linux v6.0自带的apache版本较低,已知的漏洞较多,不宜作为web 服务器,需更新到最新稳定版2.4.9,2.4.9版目前没有适合中标麒麟的rpm包,需通过源代码编译方式安装,本手册描述了源代码编译安装步骤,供项目负责人和部署实施人员参考。
查看默认安装apache版本方式[root@localhost ~]# httpd -vServer version: Apache/2.2.15 (Unix)Server built: Aug 7 2012 05:11:49一、软件包准备中标麒麟linux操作系统光盘或镜像httpd-2.4.9.tar.gz#wget /apache//httpd/httpd-2.4.9.tar.gzapr-1.5.1.tar.gz#wget /apache//apr/apr-1.5.1.tar.gzapr-util-1.5.3.tar.gz#wget /apache//apr/apr-util-1.5.3.tar.gzpcre-8.30.zip#wget /projects/pcre/files/pcre/8.30/pcre-8.30.zip/download二、安装依赖包1.配置光盘作为yum源。
2.通过yum安装、升级gcc编译器和libtool#yum install gcc*#yum install libtool*3.安装pcre#unzip pcre-8.30.zip# cd pcre-8.30# ./configure --prefix=/usr/local/pcre#make#make install4.安装apr#tar -zxvf apr-1.5.1.tar.gz#cd apr-1.5.1#vim configure找到 $RM "$cfgfile"这行注释掉或者删除# ./configure --prefix=/usr/local/apr#make#make install5.安装apr-util#tar -zxvf apr-util-1.5.3.tar.gz# cd apr-util-1.5.3# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr #make#make install三、编译安装apache#tar -zxvf httpd-2.4.9.tar.gz#cd httpd-2.4.9# ./configure --prefix=/usr/local/apache --enable-so \--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util \--with-pcre=/usr/local/pcre --enable-mods-shared=most \--enable-proxy --enable-proxy-connect --enable-proxy-ftp \--enable-proxy-http --enable-proxy-scgi --enable-proxy-ajp--enable-proxy-balancer#make#make install注意:以上所有软件配置和编译过程中有无报错信息。
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,以充分利用服务器性能。
linux配置Apache(详解)
Linux下配置ApacheApache 以其自身的强大和良好的兼容性被许多电脑爱好者所喜爱, 在此我们主要是用它来为bugzilla 做服务器. 环境是linux1.挂载光驱2.拷贝安装3.配置服务器4.测试使用一.挂载光驱在这里我用虚拟机,如果你是物理机安装的, 也是一样的.(区别不大)光驱挂载:注意: Device status 下的选项一定要钩上Use ISO image file:一定要选择正确的光碟(建议自己用解压软件到三张碟中查看一下, 确定后再加载,提高效率)在命令行输入:输入:mount /dev/cdrom /mnt/cdrom (注:mount 挂载命令; /dev/cdrom:默认挂载软件;/mnt/cdrom:默认挂载点) 回车出现write-protected ......read-only 表明加载成功二.拷贝安装接下来我们进入刚才加载的目录下(/mnt/cdrom),将它拷贝出来.输入:cd /mnt/cdrom (注:cd :目录切换)输入:ls (注:ls :查看)我们用cd命令进入RedHat(通常是这个目录),然后进入RPMS(通常是这个目录),然后, 输入:ls |grep httpd (注:grep :包含某字符的) 回车找到httpd的安装文件httpd-2.0.40-21.i386.rpm。
然后输入:cp httpd-2.0.40-21.i386.rpm /root 回车我们拷贝到root 下输入:cd 切换到root下,输入:rpm -ivh httpd-2.0.40-21.i386.rpm (注:rpm :安装命令-ivh:安装并显示进度和过程)出现以上显示,安装OK了三. 配置服务器接下来我们配置服务,进入:cd /etc/httpd/conf (注:在linux下etc目录是用来存放配置文件的)回车输入:ls 查看我们要操作的就是httpd.conf首先我们先备份一份,用cp命令输入:cp httpd.conf httpd.conf.bak (我已经转过一遍了,所以图中有httpd.conf.bak文件) 然后再次输入ls 查看就可以看到备份的文件了然后我们输入:ifconfig 命令,察看当前你的IP地址Inet addr:192.168.232.4 就是你的IP了(以实际为准)编辑配置文件httpd.conf输入:vi httpd.conf (注:vi 编辑命令)进入后会看到很多的用“#”注释的文字,别急我们找我们要的。
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)服务器⼀、基本概念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/。
ApachehttpServer2.4安装与配置
ApachehttpServer2.4安装与配置前⾔Apache官⽹从2.2之后,不再提供windows的msi或exe安装版本,现在Apache http Server有两个分⽀2.2及2.4注意事项如果之前有安装2.2的版本,请先卸载Apache2.4下载2、选择2.4的版本,点击 (windows安装版本)3、选择前三个⽹站中的任意⼀下进⼊下载,(推荐Apache Lounge镜像站点快)4、以为例,选择需要的x86或x64进⾏下载注意事项不同的VC对应不同的vc++(简单理解为Visual Studio)版本,我的电脑上安装了VS2015所以选择VC14,如果是vs2012请选择VC11我的环境我的电脑安装了VS2015,WIN10 X64位操作系统⽂件分析解压⽂件1、下载完成后,解压出⽬录如下:2、详细的安装配置步骤可以参考图⼀中的ReadMe.txt主要的⽂件和⽬录创建服务:bin\httpd.exe管理⾯板:bin\ApacheMonitor.exe主要的配置⽂件:conf\httpd.conf⽹站根⽬录:\htdocs配置⽅法下⾯说⼀下我的简单配置步骤1、默认的安装⽬录是在C:/Apache24,找到⾃⼰的实际⽬录⽐如我的D:/Apache242、打开conf\httpd.conf把⽂件中的所有 ”c:/Apache24″替换为⾃⼰的安装⽬录,如” d:/Apache24″找到 218⾏(版本不同,可能有区别)的 ServerName ,把前⾯的 # 去掉找到 DocumentRoot ,修改⽹站的根⽬录,⽐如是 “d:/Apache24/htdocs”DocumentRoot 下⽅⼀⾏的 Directory也做相应修改修改端⼝号——“Listen:80”改为80803、以管理员⾝份运⾏CMD,进⼊Apache24\bin ⽬录(httpd.exe所在⽬录)4、输⼊ httpd.exe -k install -n "Apache24" 安装服务(注:Apache24为安装服务名称)安装完成5、⾄此,安装基本完成。
centos6.5 apache2.4安装教程
Centos6.5 安装apache2.4.33部署教程1、安装部署安装环境2、检查卸载原有apache3、安装httpd所依赖的软件包4、编译安装apache5、注册apache为系统服务6、测试apache一、安装部署环境1、Centos6.5-64位系统2、切换使用root用户切换root的方式:su root二、检查卸载原有apache[root@bogon ~]$ rpm -qa|grep httpdhttpd-2.2.15-60.el6.centos.6.x86_64httpd-tools-2.2.15-60.el6.centos.6.x86_64有安装过进行卸载[root@bogon ~]$ sudo rpm -e --nodeps httpd-tools-2.2.15-60.el6.centos.6.x86_64[root@bogon ~]$ sudo rpm -e --nodeps httpd-2.2.15-60.el6.centos.6.x86_64再次检查[root@bogon ~]$ rpm -qa|grep httpd[root@bogon ~]$卸载完成三、安装httpd所依赖的软件包●apr-1.6.3.tar.bz2●expat-2.2.3.tar.bz2●apr-util-1.6.1.tar.bz2●pcre-8.42.tar.bz2●httpd-2.4.33.tar.bz2自动安装依赖包yum -y install gcc-c++ //安装C++编译环境yum -y install pcre-devel //安装pcre开发依赖包yum -y install openssl-devel三、编译安装apache1)安装apr[root@localhost ias]# tar xf apr-1.6.3.tar.bz2[root@localhost ias]# cd apr-1.6.3[root@localhost apr-1.6.3]# ./configure --prefix=/usr/local/apr[root@kvm ~]# make && make install2)安装apr-util因为我们使用了 apr 1.6.2 的依赖,所以下面我们必须要用 apr-util 1.6.0 版本,apr-util 1.6.0不再捆绑安装 expat ,但又需要 expat 的支持,所以我们得手动先安装 expat。
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>。
apache2服务器的搭建和配置步骤详解
apache2服务器的搭建和配置步骤详解前⾔这篇⽂章主要给⼤家介绍了在linux下apache2服务器的搭建和配置的相关资料,具有⼀定的参考价值,下⾯来⼀起学习学习吧。
步骤如下⾸先当然是下载包包:myths@myths-X450LD:~$ sudo apt-get install apache2装完后就可以⽤了,在地址栏输⼊本地回送地址127.0.0.1或者localhost就可以进⼊到默认的界⾯了。
默认的界⾯当然就是apache2的说明界⾯了。
其实很多情况下并不需要在⽹上寻找帮助⽂档,⼏乎所有的软件都会⾃带使⽤说明,只是略长,我们⼀般都懒得看。
但是其实很多重要的东西就在这当中,⽐如apache2的默认界⾯⾥:Ubuntu Logo Apache2 Ubuntu Default PageIt works!This is the default welcome page used to test the correct operation of the Apache2 server after installation on Ubuntu systems. It is based on the equivalent page on Debian, from which the Ubuntu Apache packaging is derived. If you can read this page, it mea If you are a normal user of this web site and don't know what this page is about, this probably means that the site is currently unavailable due to maintenance. If the problem persists, please contact the site's administrator.Configuration OverviewUbuntu's Apache2 default configuration is different from the upstream default configuration, and split into several files optimized for interaction with Ubuntu tools. The configuration system is fully documented in /usr/share/doc/apache2/README.Debian.gz. Refe The configuration layout for an Apache2 web server installation on Ubuntu systems is as follows:/etc/apache2/|-- apache2.conf| `-- ports.conf|-- mods-enabled| |-- *.load| `-- *.conf|-- conf-enabled| `-- *.conf|-- sites-enabled| `-- *.confapache2.conf is the main configuration file. It puts the pieces together by including all remaining configuration files when starting up the web server.ports.conf is always included from the main configuration file. It is used to determine the listening ports for incoming connections, and this file can be customized anytime.Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ directories contain particular configuration snippets which manage modules, global configuration fragments, or virtual host configurations, respectively.They are activated by symlinking available configuration files from their respective *-available/ counterparts. These should be managed by using our helpers a2enmod, a2dismod, a2ensite, a2dissite, and a2enconf, a2disconf . See their respective man pages for The binary is called apache2\. Due to the use of environment variables, in the default configuration, apache2 needs to be started/stopped with /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not work with the default configuration. Document RootsBy default, Ubuntu does not allow access through the web browser to any file apart of those located in /var/www, public_html directories (when enabled) and /usr/share (for web applications). If your site is using a web document root located elsewhere (such as i The default Ubuntu document root is /var/www/html. You can make your own virtual hosts under /var/www. This is different to previous releases which provides better security out of the box.Reporting ProblemsPlease use the ubuntu-bug tool to report bugs in the Apache2 package with Ubuntu. However, check existing bug reports before reporting a new bug.Please report bugs specific to modules (such as PHP and others) to respective packages, not to the web server itself.Valid XHTML 1.0 Transitional仅仅从这个⽂件中,我们就可以⾄少得到以下的重要信息:当访问本机的时候,默认进⼊的页⾯是/var/www/html/index.html。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Linux apache 2.4.3 版本安装概要
1.下载apache源码包
下载地址:/dist/httpd/
2.下载apr-1.4.6 和apr-util-1.4.1 具体原因可查看2.4以上版本的发布报告
下载地址:/download.cgi
3.下载pcre-8.31
下载地址:/projects/pcre/
安装步骤:
自己的操作方法:
1.将所有的文件拷贝到/home/wucq
2.解压httpd-2.4.3.tar
解压命令:tar zxvf httpd-2.4.3.tar.gz
mv httpd-2.4.3 apache
3.
解压:[root@localhost apache]# tar zxvf apr-1.4.6.tar.gz
配置环境:
[root@localhost apr-1.4.6]# ./configure --prefix=/usr/local/apr/
编译和安装:
[root@localhost apr-1.4.6]#make
[root@localhost apr-1.4.6]#make install
4.
解压: [root@localhost apache]# tar zxvf apr-util-1.4.1.tar.gz
配置环境:
[root@localhost apr-1.4.6]# ./configure
--prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr/编译和安装:
[root@localhost apr-1.4.6]#make
[root@localhost apr-1.4.6]#make install
5.
接着在apache下配置环境:
./configure --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util-httpd/
然后编译:make
安装:make install
此时运行httpd(service httpd start),在浏览器上输入127:0:0:1,就能看到下面的了
This page is used to test the proper operation of the Apache HTTP server after it has been installed. If you can read this page, it means that the Apache HTTP server installed at this site is working properly.。