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

前面有# 號,說明被註釋掉了,不起做用,把#號去掉,就能夠了。

相關文章
相關標籤/搜索