apache安装

2018-11-29  本文已影响0人  minda_22f8

apache安装

软件下载

apache httpd

http://httpd.apache.org/download.cgi

APR 和 APR-Util

http://apr.apache.org/download.cgi

PCRE

https://sourceforge.net/projects/pcre/files/pcre/

软件版本列表

软件安装

上传文件至安装目录

此处选用/usr/local/soft

解压文件

tar -xzf /usr/local/soft/apr-1.6.5.tar.gz -C /usr/local/
tar -xzf /usr/local/soft/apr-util-1.6.1.tar.gz -C /usr/local/
tar -xzf /usr/local/soft/pcre-8.42.tar.gz -C /usr/local/
tar -xzf /usr/local/soft/httpd-2.4.37.tar.gz -C /usr/local/

创建安装目录

mkdir /usr/local/apr
mkdir /usr/local/apr-util
mkdir /usr/local/pcre
mkdir /usr/local/httpd

安装编译文件

./configure --prefix=/usr/local/httpd --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-ssl=/usr/local/openssl --enable-mods-shared=all --with-mpm=worker --enable-rewrite --enable-ssl
make
make install

环境配置

开启对应端口
Listen 443
Listen 3129
Listen 3127

正向反向用

LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_module modules/mod_proxy.so

https用

LoadModule ssl_module modules/mod_ssl.so

rewrite用

LoadModule rewrite_module modules/mod_rewrite.so

<VirtualHost *:3129>
# ServerAdmin webmaster@jsoft.cn
ServerName 11.16.53.33
#ProxyPreserveHost On
#ProxyPass / https://api.mch.weixin.qq.com/
ProxyRequests On #正向代理
ProxyVia On #正向代理
#实验结果:正向代理 Rewrite 不生效
#RewriteEngine On
#RewriteCond %{SERVER_PORT} ^3129$
#RewriteCond %{SERVER_PORT} !^443$
#RewriteCond %{SERVER_PORT} ^80$
#RewriteRule ^(.*)$ http://11.16.53.33:8001[L,P]
#RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
</VirtualHost>

<VirtualHost *:3127>
# ServerAdmin webmaster@jsoft.cn
ServerName 11.16.53.33
#实验结果:反向代理 Rewrite 生效
RewriteEngine On #重写地址(改变目标地址)时使用
#RewriteCond %{SERVER_PORT} ^3127$
RewriteRule ^(.*)$ https://11.16.53.33
#RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

#普通的跳转时使用
ProxyPreserveHost On  
ProxyPass /test http://11.16.53.33:8000/
</VirtualHost>

https

<VirtualHost *:443>     # 必须有一个虚拟主机,这样才可以使用跳转功能和使用443端口访问
SSLEngine on
SSLCertificateFile /usr/local/httpd/certs/server.crt
SSLCertificateKeyFile /usr/local/httpd/certs/server.key
#重写地址(改变目标地址)时使用
RewriteEngine On
#RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ https://www.baidu.com

#普通的跳转时使用
ProxyPreserveHost On  
ProxyPass /test http://11.16.53.33:8000/
</VirtualHost>

安装gcc
参考https://www.jb51.net/article/103633.htm
http://gcc.gnu.org/下载gcc安装包 gcc-4.8.2.tar.gz
ftp://ftp.gnu.org/gnu/gmp/ 下载GMP安装包 gmp-5.1.3 .tar.bz2
http://ftp.gnu.org/gnu/mpfr/ 下载MPFR安装包 mpfr-3.1.2.tar.gz
http://www.cise.ufl.edu/mirrors/GNU/pub/gnu/mpc 下载MPC安装包 mpc-1.0.1.tar.gz

附录
错误1 安装 apr-util

make[1]: Entering directory `/usr/local/apr-util-1.6.1'
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/usr/local/apr-util-1.6.1/include -I/usr/local/apr-util-1.6.1/include/private  -I/usr/local/apr/include/apr-1    -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: error: expat.h: No such file or directory
xml/apr_xml.c:66: error: expected specifier-qualifier-list before ‘XML_Parser’
xml/apr_xml.c: In function ‘cleanup_parser’:
xml/apr_xml.c:364: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:365: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c: At top level:
xml/apr_xml.c:384: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
xml/apr_xml.c: In function ‘apr_xml_parser_create’:
xml/apr_xml.c:401: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:402: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:410: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:411: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:412: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:424: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:424: error: ‘default_handler’ undeclared (first use in this function)
xml/apr_xml.c:424: error: (Each undeclared identifier is reported only once
xml/apr_xml.c:424: error: for each function it appears in.)
xml/apr_xml.c: In function ‘do_parse’:
xml/apr_xml.c:434: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:438: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:442: error: ‘apr_xml_parser’ has no member named ‘xp_err’
xml/apr_xml.c:442: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c: In function ‘apr_xml_parser_geterror’:
xml/apr_xml.c:500: error: ‘apr_xml_parser’ has no member named ‘xp_err’
xml/apr_xml.c:500: error: ‘apr_xml_parser’ has no member named ‘xp_err’
make[1]: *** [xml/apr_xml.lo] Error 1

1解决方案
https://sourceforge.net/projects/expat/files/
tar -xjvf ./soft/expat-2.2.6.tar.bz2 -C ./
./configure  
make
make install




错误2:安装pcre
checking windows.h usability... no
checking windows.h presence... no
checking for windows.h... no
configure: error: Invalid C++ compiler or C++ compiler flags

解决方案 安装 gcc-c++
参考 https://blog.csdn.net/qq1031893936/article/details/80396499
你可以去 http://rpmfind.net/ 这个网站挨个搜索下载下来。
链接:https://pan.baidu.com/s/1QDwYE1WC_vngJsqNSkZ5bQ 密码:ny2d
rpm -Uvh *.rpm --nodeps --force




错误3:报错:/usr/local/openssl/lib/libssl.a: could not read symbols: Bad value
删除openssl旧包
重新解压、重新编译
./config -fPIC --prefix=/usr/local/openssl/ enable-shared
make
make install
上一篇下一篇

猜你喜欢

热点阅读