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>
相关推荐
sunshine-sm18 分钟前
CentOS Steam 9安装 MySQL 8
linux·运维·服务器·数据库·mysql·centos·centos stream
一路向北North1 小时前
apache poi 导出复杂的excel表格
apache·excel
尚久龙1 小时前
安卓学习 之 用户登录界面的简单实现
android·运维·服务器·学习·手机·android studio·安卓
high20111 小时前
【 运维相关】-- HTTP 压测/负载发生器之新秀 oha
运维·网络协议·http
呆萌小新@渊洁2 小时前
linux升级系统,重启出现Minimal BASH-like line editingis supported
linux·服务器
東雪蓮☆2 小时前
从零开始掌握 Web 与 Nginx:入门详解
运维·服务器·前端·nginx
青铜发条3 小时前
【python】python进阶——网络编程
运维·服务器·网络
勇闯逆流河3 小时前
【Linux】Linux常用指令合集
linux·运维·服务器
AD钙奶-lalala4 小时前
HTTP response code 200 206 416详解
网络·网络协议·http
sun03224 小时前
使用 javax.net.ssl.HttpsURLConnection 发送 HTTP 请求_以及为了JWT通信选用OSS的Jar的【坑】
http·.net·ssl