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>
相关推荐
DC_BLOG29 分钟前
IPv6(四)
运维·服务器·网络·ip
shelby_loo29 分钟前
通过 Docker 部署 MySQL 服务器
服务器·mysql·docker
ZBzibing35 分钟前
[游戏技术]L4D服务器报错解决
服务器·游戏
沈艺强35 分钟前
伊犁linux 创建yum 源过程
linux·运维·服务器
拾光师39 分钟前
linux命令行快捷键
linux·运维·服务器
Dola_Pan3 小时前
Linux文件IO(二)-文件操作使用详解
java·linux·服务器
城南云小白4 小时前
Linux网络服务只iptables防火墙工具
linux·服务器·网络
从心归零4 小时前
sshj使用代理连接服务器
java·服务器·sshj
咩咩大主教4 小时前
C++基于select和epoll的TCP服务器
linux·服务器·c语言·开发语言·c++·tcp/ip·io多路复用
羌俊恩4 小时前
视频服务器:GB28181网络视频协议
服务器·网络·音视频