03 編譯安裝apache的簡易配置
1.監聽埠,默認為80,在主配置文件 /etc/httpd24/httpd.conf中可以更改
2.持久連接
Include /etc/httpd24/extra/httpd-default.conf
主配置文件中取消該注釋,並且到該文件中作相應具體修改
KeepAlive On
#開啟持久連接
MaxKeepAliveRequests 100
#持久連接斷開判斷條件一,處理100個請求
KeepAliveTimeout 5
#條件二,超時5秒
副作用,對並發訪問量大的伺服器,持久連接會使某些請求得不到相應,可以考慮使用時間較短的持久連接,apache2.4支持毫秒級的持久連接(有個疑問,怎麼設置 可以設置成0.2 嗎?)
3.MPM
可能用到的命令, (編譯安裝我切換工作模式,httpd -l 貌似顯示不出來我靜態編譯的工作模式,rpm安裝包可以顯示),httpd -M 可以查看當前載入模式
在主配置文件中可以選擇工作模式,這裡我有個疑問,event模式去哪裡了??有知道的大大麻煩指點下
同時需要注釋
# Server-pool management (MPM specific)
Include /etc/httpd24/extra/httpd-mpm.conf
prefork的配置:
ServerLiMIT 20 伺服器允許配置的進程數上限
ThreadLimit 200 設置每個子進程可配置的線程數上限 MaxClients 4000 請求最大線程數,超過進入等待隊列 MinSpareThreads 25 最小空閑線程數 MaxSpareThreads 75 最大空閑線程數 ThreadsPerChild 200 每個子進程的線程數 MaxRequestsPerChild 0 設置每個子進程在其生存周期內最大的請求數量,0為無限
4.配置指令實現動態模塊載入
LoadModule 5.文檔頁面路徑 DocumentRoot "/var/www/html
同時注釋
# Virtual hosts
#Include /etc/httpd24/extra/httpd-vhosts.conf
給文檔路徑以訪問許可權
DocumentRoot "/var/html"
Options None
AllowOverride None
Require all granted
ServerName 暫改為 www.test.com
在所在路徑下建一個簡單的html
echo "Hello World" > /var/html/index.com
添加hosts後可以訪問了
6. 日誌設定
日誌定義設定
CustomLog logs/access_log combined
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
%h:客戶端IP地址;
%l: Remote logname (from identd, if supplied). -表示為空; %u: Remote user, (from auth; may be bogus if return status (%s) is 401); %t:Time the request was received (standard english format),伺服器收到請求的時間; %r:First line of request,請求報文的道行信息(method url version); %>s: 響應狀態碼; %b: 響應報文的大小,單位是位元組,不包括響應報文首部; %{Referer}i:請求報文當中"referer"首部的值;當前資源的訪問入口,即從哪個頁面中的超鏈接跳轉而來;
%{User-Agent}i:請求報文當中"User-Agent"首部的值;即發出請求用到的應用程序;
對應的日誌圖片
7.虛擬主機配置
注釋DocumentRoot ,啟用vhost
# Virtual hosts
Include /etc/httpd24/extra/httpd-vhosts.conf
或者新加入自己設定的配置文件
# Virtual hosts
#Include /etc/httpd24/extra/httpd-vhosts.conf
Include /etc/httpd24/vhosts
<1>基於IP
<2>基於埠
<3>基於域名
簡單的基於域名的虛擬主機因該配置如下
ServerName www.test01.com
DocumentRoot "/data/vhost/one"
ErrorLog /usr/local/apache24/logs/www.test01.com/Error_Log
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 "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %I %O" combinedio
CustomLog "/usr/local/apache24/logs/www.test01.com/access_log" common
Options None
AllowOverride None
Require all granted
echo "Hello World ! test01" > /data/vhost/one
echo "Hello World ! test02" > /data/vhost/two
記得添加日誌所需的目錄
測試如下


※hadoop源碼解析之hdfs內部結構分析
※對 Servlet 的改進——Struts2 引入
※圖像工具包VintaSoftImaging.NET SDK v8.5,新增獨立web服務
※UIDebuggingInformationOverlay在OC語法中使用
※使用 zabbix 自動發現監控 MySQL
TAG:達人科技 |
※php+Swoole——編譯安裝
※centos7下靜默安裝oracle11G圖解配置 2
※centos7下靜默安裝oracle11G圖解配置 1
※phpmyadmin安裝與配置
※redhat6.3安裝配置oracle11gR2詳細步驟
※Mathematica 11.2軟體安裝教程
※hive on spark 安裝配置
※uefi+gpt安裝Win10/7原版鏡像系統安裝詳細教程
※Photoshop cc 2018年破解版安裝包資源及安裝教程
※linux下mariadb安裝、配置
※安裝oracle 11g伺服器
※原創:Centos 7 源碼編譯安裝 Nginx 1.13
※Audition cc 2018 for mac安裝
※Centos7 安裝python3
※2017正版photoshop安裝和破解教程
※Calamares 3.2通用Linux安裝程序框架新版發布
※Adobe illustrator 2018Mac版安裝教程
※Mastercam 2017軟體安裝教程
※uefi+gpt分區安裝win7圖文教程 uefi加gpt模式安裝win7 64位的方法
※虛擬機裡面安裝Openfiler 2.99