Apache HTTP服务器(Linux离线编译安装)

Apache HTTP服务器(Linux离线编译安装)

Apache是普通服务器,本身只支持html即普通网页。可以通过插件支持PHP,还可以与Tomcat连通(单向Apache连接Tomcat,就是说通过Apache可以访问Tomcat资源。反之不然)。

Apache和Tomcat都可以做为独立的web服务器来运行,但是Apache不能解释java程序(jsp,serverlet)

一、下载软件包

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

apr和apr-util https://apr.apache.org/download.cgi

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

二、开始编译

1、编译安装apr

sh 复制代码
cd /data/businessServer
tar xf apr-1.7.4.tar.gz 
cd apr-1.7.4/
# 编译
./configure --prefix=/usr/local/httpd/apr
make
make install

2、编译安装apr-util

sh 复制代码
# 安装依赖,否则会报错
yum install -y expat-devel

cd /data/businessServer
tar xf apr-util-1.6.3.tar.gz 
cd apr-util-1.6.3/
./configure --prefix=/usr/local/httpd/apr-util --with-apr=/usr/local/httpd/apr/bin/apr-1-config
make
make install

3. 编译安装pcre

sh 复制代码
# 安装依赖,否则会报错
yum install gcc-c++

cd /data/businessServer
tar xf pcre-8.45.tar.gz
cd pcre-8.45/
./configure --prefix=/usr/local/httpd/pcre --with-apr=/usr/local/httpd/apr/bin/apr-1-config
make
make install

4. 编译安装httpd

sh 复制代码
yum install -y  libxml2


cd /data/businessServer
tar xf httpd-2.4.58.tar.gz
cd httpd-2.4.58/
./configure --prefix=/usr/local/httpd/apache --with-apr=/usr/local/httpd/apr/bin/apr-1-config --with-apr-util=/usr/local/httpd/apr-util/bin/apu-1-config --with-pcre=/usr/local/httpd/pcre/bin/pcre-config  --enable-dav --enable-so

make
make install

三、httpd配置文件

sh 复制代码
cat /usr/local/httpd/apache/conf/httpd.conf




ServerRoot "/usr/local/httpd/apache"
# 用于指定Apache运行的根目录
Listen 80
# 监听端口
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin [email protected]
<Directory />
    AllowOverride none
    Require all denied
</Directory>
DocumentRoot "/usr/local/httpd/apache/htdocs"
<Directory "/usr/local/httpd/apache/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
<Files ".ht*">
    Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access_log" common
</IfModule>
<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/usr/local/httpd/apache/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "/usr/local/httpd/apache/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>
<IfModule headers_module>
    RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
相关推荐
玩转4G物联网37 分钟前
零基础玩转物联网-串口转以太网模块如何快速实现与TCP服务器通信
服务器·网络·物联网·网络协议·tcp/ip·http·fs100p
派阿喵搞电子1 小时前
Ubuntu下有关UDP网络通信的指令
linux·服务器·网络
程序员JerrySUN1 小时前
全面理解 Linux 内核性能问题:分类、实战与调优策略
java·linux·运维·服务器·单片机
Theodore_10221 小时前
大数据(2) 大数据处理架构Hadoop
大数据·服务器·hadoop·分布式·ubuntu·架构
hie988942 小时前
HTTP常见的请求方法、响应状态码、接口规范介绍
http
huangyuchi.2 小时前
【Linux】LInux下第一个程序:进度条
linux·运维·服务器·笔记·进度条·c/c++
蔡蓝2 小时前
设计模式-建造者模式
服务器·设计模式·建造者模式
搬码临时工2 小时前
外网访问内网服务器常用的三种简单操作步骤方法,本地搭建网址轻松让公网连接
服务器·网络·智能路由器
黑客老李3 小时前
JavaSec | SpringAOP 链学习分析
java·运维·服务器·开发语言·学习·apache·memcached
这儿有一堆花3 小时前
安全访问家中 Linux 服务器的远程方案 —— 专为单用户场景设计
linux·服务器·安全