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
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
# 安装依赖,否则会报错
yum install -y expat-develcd /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
# 安装依赖,否则会报错
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
yum install -y libxml2cd /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-somake
make install
三、httpd配置文件
cat /usr/local/httpd/apache/conf/httpd.confServerRoot "/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 noneRequire all denied
</Directory>
DocumentRoot "/usr/local/httpd/apache/htdocs"
<Directory "/usr/local/httpd/apache/htdocs">Options Indexes FollowSymLinksAllowOverride NoneRequire 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\"" combinedLogFormat "%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 NoneOptions NoneRequire all granted
</Directory>
<IfModule headers_module>RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>TypesConfig conf/mime.typesAddType application/x-compress .ZAddType 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>