apache安装与配置

1.首先须要四个安装包 
1.1apache下载路径http://mirror.bit.edu.cn/apache/ 
1.2相关依赖下载路径http://apr.apache.org/download.cgispring

rm -rf apr-1.6.三、rm -rf apr-util-1.6.一、rm -rf pcre-8.4二、rm -rf httpd-2.4.33
  • 1

2.liunx命令将其解压apache

tar -xjf  apr-1.6.3.tar.bz二、tar -xjf pcre-8.42.tar.bz二、tar -xjf apr-util-1.6.1.tar.bz二、tar -zxvf httpd-2.4.33.tar.gz
  • 1

3.切入到解压目录 
3.1ruby

cd apr-1.6.3 ./configure --prefix=/usr/local/apr 注意:"apr"的路径须要本身建立目录,命令mkdir apr make make install cd ..
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

3.2bash

cd apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr 注意:"apr-util"的路径须要本身建立目录,命令mkdir apr-util make make install cd ..
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

3.3app

cd pcre-8.42 ./configure --prefix=/usr/local/pcre 注意:"pcre"的路径须要本身建立目录,命令mkdir pcre make make install cd ..
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

若是出现: 
报错xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory在网上查找说多是少了expat库,yum install expat-devel安装该库,安装完再次编译,果真能够。 
4.安装apache 
版本是2.4.33ui

rpm -ivh  expat-devel-2.0.1-11.el6_2.x86_64.rpm
  • 1

tar安装包的apache安装命令,不一样命令导入相关so文件不同。spa

./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --enable-module=so --enable-mods-shared=most --enable-module=rewirte --enable-cache --enable-file-cache --enable-mem-cache --enable-so --enable-track-vars --enable-disk-cache --disable-cgid --disable-cgi
  • 1

tar安装包的apache安装命令rest

./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --enable-module=so --enable-mods-shared=all --enable-module=rewirte --enable-cache --enable-file-cache --enable-mem-cache --enable-so --enable-track-vars --enable-disk-cache --disable-cgid --disable-cgi
  • 1
  • 2
  • 3
  • 4
  • 5

tar安装包的apache安装命令code

./configure  --prefix=/usr/local/apache
--enable-mods-shared=most --enable-deflate --enable-speling --enable-cache --enable-file-cache --enable-disk-cache --enable-mem-cache --enable-rewrite --enable-so --enable-track-vars --enable-rewrite --with-z-dir=/usr/local/zlib --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-included-apr make && make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

版本2.2.31regexp

./configure  --prefix=/usr/local/apache
--enable-mods-shared=most --enable-deflate --enable-speling --enable-cache --enable-file-cache --enable-disk-cache --enable-mem-cache --enable-rewrite --enable-so --enable-track-vars --enable-rewrite --with-included-apr
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

5.启动apache 
安装完成后,须要在Apache的配置文件中增长:

ServerName localhost:80 
而后Apache即可以正常启动: 
/usr/local/apache/bin/apachectl start 
Apache即可以正常关闭命令: 
/usr/local/apache/bin/apachectl stop 
Apache即可以正常重启命令: 
/usr/local/apache/bin/apachectl restart

6.如何添加例如mod_rewrite.so文件 
从新编译mod_rewrite.so: 
在apache的源码安装目录中寻找mod_rewrite.c文件 
find / -name mod_rewrite.c 
/home/springshine/LAMP/httpd-2.2.3/modules/mappers/mod_rewrite.c 
编译: 
cd /home/springshine/LAMP/httpd-2.2.3/modules/mappers/ 
/usr/local/apache2/bin/apxs -c mod_rewrite.c 
/usr/local/apache2/bin/apxs -i -a -n mod_rewrite mod_rewrite.la 
若是没出错,在/usr/local/apache2/modules/ 中就会有mod_rewrite.so了 
7.若是启动服务的时候老是出现这个提示Redirecting to /bin/systemctl start httpd.service 
/bin/systemctl start httpd.service 启动 
8.Invalid command ‘ProxyPass’, perhaps misspelled or defined by a module … 
看看配置文件httpd,问题出在 ProxyPass 这个环节: 
ProxyPass /vict_service http://localhost:8080/vict_service 
也就是要为 /vict_service 这个请求路径匹配一个实际可用的路径,既然提示ProxyPass命令无效,那么确定是某个地方的设置问题。 
解决的方法就在httpd这个配置文件里,找到如下两条:

#LoadModule proxy_module modules/mod_proxy.so #LoadModule proxy_http_module modules/mod_proxy_http.so
  • 1
  • 2

前面有# 号,说明被注释掉了,不起做用,把#号去掉,就能够了。

相关文章
相关标签/搜索