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 you@example.com
<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>
相关推荐
坤昱1 天前
cfs调度类深入解刨——最新内核细节分析2
linux·服务器·cfs·cfs调度·eevdf调度·eevdf·kernel 7.1
艾莉丝努力练剑1 天前
【Linux:文件】Ext系列文件系统进阶
linux·运维·服务器·c++·文件系统·文件io·ext
海市公约1 天前
Linux核心基础命令与权限管理实战指南
linux·运维·服务器·vim·权限管理·系统监控·命令行
mixboot1 天前
Linux 进程工作目录查看利器:pwdx 命令详解
linux·运维·服务器
之歆1 天前
Day16_JavaScript 轮播图与事件工程实战(下篇)
服务器·开发语言·前端·javascript·网络·性能优化
zhz52141 天前
服务器等保加固实施报告
运维·服务器·信创·国密·等保
s_w.h1 天前
【 linux 】文件系统
linux·运维·服务器·算法·bash
早睡身体真不戳1 天前
【无标题】
java·服务器·windows
小快说网安1 天前
云服务器抗 DDoS 只靠基础防护够吗?
运维·服务器·ddos
biter down1 天前
15:YAML配置文件
服务器·数据库·python