apache瘦身大行动---够用就好
决定为自己的apache减肥。ok现在就开始吧 系统平台:redhat7.3 软件版本:apache_1.3.28.tar.gz 安装的模块:core,access,alias,auth,dir,log_config,mime 说明 core模块就不用多说。一定是要的,不要也不行 1、虚拟目录的实现Alias mod_alias [Alias,ScriptAl
决定为自己的apache减肥。ok现在就开始吧系统平台:redhat7.3
软件版本:apache_1.3.28.tar.gz
安装的模块:core,access,alias,auth,dir,log_config,mime
说明
core模块就不用多说。一定是要的,不要也不行
1、虚拟目录的实现Alias mod_alias [Alias,ScriptAlias]
2、基于客户端hostname,ip的访问控制 mod_access [Allow,Deny,Order]
3、基本的用户认证 mod_auth [AuthUserFile,AuthGroupFile]
4、自定义的访问日志 mod_log_config [LogFormat,CustomLog]
5、默认的主页 mod_dir [DirectoryIndex]
6、可以定义的character set, content- encoding, handler, content-language和MIME mod_mime
apache的安装。决定要安装的模块实际的安装过程是简单的
./configure --prefix=/www/apache --disable-module=all
--enable-module=alias
--enable-module=access --enable-module=auth
--enable-module=log_config
--enable-module=dir --enable-module=mime
make
make install
查看安装的模块/www/apache/bin/httpd -l
Compiled-in modules:
http_core.c
mod_log_config.c
mod_mime.c
mod_dir.c
mod_alias.c
mod_access.c
mod_auth.c
最后让我们看看安装了这些模块具体到配置文件中是怎样使用的
配置文件举例
# =================================================
# Basic settings
# =================================================
ServerType standalone
ServerRoot "/usr/local/apache"
PidFile /usr/local/apache/logs/httpd.pid
ScoreBoardFile /usr/local/apache/logs/httpd.scoreboard
ResourceConfig /dev/null
AccessConfig /dev/null
# =================================================
# Performance settings
# =================================================
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 0
# =================================================
# Apache's modules
# =================================================
ClearModuleList
AddModule mod_log_config.c
AddModule mod_mime.c
AddModule mod_dir.c
AddModule mod_access.c
AddModule mod_auth.c
AddModule mod_alias.c
# =================================================
# General settings
# =================================================
Port 80
User apache
Group apache
ServerAdmin Webmaster@www.abc.com
UseCanonicalName Off
ServerSignature Off
HostnameLookups Off
ServerTokens Prod
#——————————————
###mod_dir模块
#----------------------------------
DirectoryIndex index.html
DocumentRoot "/www/vhosts"
# =================================================
# Access control
#
#mod_access 模块
=================================================
Options None
AllowOverride None
Order deny,allow
Deny from all
Order allow,deny
Allow from all
Order allow,deny
Allow from all
#==========================================
#basic auth
#
#mod-auth模块
#=========================================
AuthType Basic
AuthName "基本的用户认证"
AuthUserFile /www/apache/passwd/passwords
Require user zhangshan lisi
# =================================================
# MIME encoding
#
#mod_mime模块
=================================================
TypesConfig /usr/local/apache/conf/mime.types
DefaultType text/plain
AddEncoding x-compress Z
AddEncoding x-gzip gz tgz
AddType application/x-tar .tgz
# =================================================
# Logs
#
#log_config模块
=================================================
LogLevel warn
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%h %l %u %t "%r" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
ErrorLog /usr/local/apache/logs/error_log
CustomLog /usr/local/apache/logs/access_log combined
# =================================================
# Virtual hosts
# =================================================
NameVirtualHost *
DocumentRoot "/www/vhosts/www.abc.com"
ServerName "www.abc.com"
ErrorLog logs/www.abc.com/error_log
CustomLog logs/www.abc.com/access_log combined
#=====================================================
#虚拟目录
#
#mod-alias模块
#=====================================================
Alias /icons/ /www/vhosts/icons/
DocumentRoot "/www/vhosts/www.chinaunix.com"
ServerName "www.chinaunix.com"
ErrorLog logs/www.chinaunix.com/error_log
CustomLog logs/www.chinaunix.com/access_log combined
配置文件中都标出了每个模块的使用方法。这里就不多说。希望喜欢“苗条”的同志赶快行动起来吧。最后不要忘了把你的瘦身方案拿出来大家分享

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

要在 Apache 中設置 CGI 目錄,需要執行以下步驟:創建 CGI 目錄,如 "cgi-bin",並授予 Apache 寫入權限。在 Apache 配置文件中添加 "ScriptAlias" 指令塊,將 CGI 目錄映射到 "/cgi-bin" URL。重啟 Apache。

Apache 連接數據庫需要以下步驟:安裝數據庫驅動程序。配置 web.xml 文件以創建連接池。創建 JDBC 數據源,指定連接設置。從 Java 代碼中使用 JDBC API 訪問數據庫,包括獲取連接、創建語句、綁定參數、執行查詢或更新以及處理結果。

當 Apache 80 端口被佔用時,解決方法如下:找出佔用該端口的進程並關閉它。檢查防火牆設置以確保 Apache 未被阻止。如果以上方法無效,請重新配置 Apache 使用不同的端口。重啟 Apache 服務。

有 3 種方法可在 Apache 服務器上查看版本:通過命令行(apachectl -v 或 apache2ctl -v)、檢查服務器狀態頁(http://<服務器IP或域名>/server-status)或查看 Apache 配置文件(ServerVersion: Apache/<版本號>)。

Apache 無法啟動,原因可能有以下幾點:配置文件語法錯誤。與其他應用程序端口衝突。權限問題。內存不足。進程死鎖。守護進程故障。 SELinux 權限問題。防火牆問題。軟件衝突。

如何查看 Apache 版本?啟動 Apache 服務器:使用 sudo service apache2 start 啟動服務器。查看版本號:使用以下方法之一查看版本:命令行:運行 apache2 -v 命令。服務器狀態頁面:在 Web 瀏覽器中訪問 Apache 服務器的默認端口(通常為 80),版本信息顯示在頁面底部。

啟動 Apache 的步驟如下:安裝 Apache(命令:sudo apt-get install apache2 或從官網下載)啟動 Apache(Linux:sudo systemctl start apache2;Windows:右鍵“Apache2.4”服務並選擇“啟動”)檢查是否已啟動(Linux:sudo systemctl status apache2;Windows:查看服務管理器中“Apache2.4”服務的狀態)啟用開機自動啟動(可選,Linux:sudo systemctl

要從 Apache 中刪除多餘的 ServerName 指令,可以採取以下步驟:識別並刪除多餘的 ServerName 指令。重新啟動 Apache 使更改生效。檢查配置文件驗證更改。測試服務器確保問題已解決。
